功能没有在android中启动

时间:2018-01-23 07:08:23

标签: android stripe-payments

我正在尝试在Android应用中实施Stripe付款。

我有一个按钮,可以打开一个警告对话框,确认用户是否要付款:

 btnPagar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    builder = new AlertDialog.Builder(getContext(), android.R.style.Theme_Material_Dialog_Alert);
                } else {
                    builder = new AlertDialog.Builder(getContext());
                }
                builder.setTitle("Order # "+numero+" Payment")
                        .setMessage("Are you sure you want to confirm and pay this Sdock Order # "+numero+"?")
                        .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                // continue with delete

                                //PONER AQUI DATOS DE LA TARJETA


                                String num_tarjeta_encriptada = nT;
                                String num_tarjeta_desencriptada = nT;


                                try {
                                    num_tarjeta_desencriptada = decrypt(num_tarjeta_encriptada,AppConfig.REBU);
                                    Log.d("HOLA PERFIL", "DESENCRIPTADA TARJETA " + num_tarjeta_desencriptada);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }



                                try {
                                    aTi = Integer.parseInt(aT);
                                } catch(NumberFormatException nfe) {
                                    System.out.println("Could not parse " + nfe);
                                }


                                try {
                                    mTi = Integer.parseInt(mT);
                                } catch(NumberFormatException nfe) {
                                    System.out.println("Could not parse " + nfe);
                                }
Log.d("DATOS TAR","DATOS TARJETA PAGO:"+num_tarjeta_desencriptada+" "+aTi+" "+mTi+" "+cT);

                                onClickSomething(num_tarjeta_desencriptada,aTi,mTi,cT);


                            }
                        })
                        .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                // do nothing
                            }
                        })
                        .setIcon(android.R.drawable.ic_dialog_alert)
                        .show();

            }
        });

函数onClickSomething(num_tarjeta_desencriptada,aTi,mTi,cT);应执行卡验证,令牌生成以及向远程服务器发送令牌和付款信息。

这是功能:

 public void onClickSomething(String cardNumber, Integer cardExpMonth, Integer cardExpYear, String cardCVC) {




        Card card = new Card(
                cardNumber,
                cardExpMonth,
                cardExpYear,
                cardCVC
        );
        Log.d("DATOS TAR","DATOS TARJETA PAGO onckli:"+cardNumber+" "+cardExpMonth+" "+cardExpYear+" "+cardCVC);
        card.validateNumber();
        card.validateCVC();

        Stripe stripe = new Stripe(getActivity(), "pk_test_...");
        stripe.createToken(
                card,
                new TokenCallback() {
                    public void onSuccess(Token token) {
                        // Send token to your server

                        Toast toast=Toast.makeText(getActivity(),"TOKEN GENERATED, SECURE ",Toast.LENGTH_SHORT);
                        toast.setMargin(50,50);
                        toast.show();
                        Log.d("MI ID","response token :"+token);
                        DetalleSdocksFragment.DatabaseTask databaseTask = new DetalleSdocksFragment.DatabaseTask("SENDTOKEN", token);
                        databaseTask.execute();
                    }
                    public void onError(Exception error) {
                        // Show localized error message
                        Toast toast=Toast.makeText(getActivity(),error.toString(),Toast.LENGTH_SHORT);
                        toast.setMargin(50,50);
                        toast.show();
                    }
                }
        );
    }

问题是永远不会调用此函数。我正在使用从未显示的Log.d输入进行检查。

我无法找出代码中的错误。

0 个答案:

没有答案