【问题标题】:Where do I get response in Citrus payment integration in Android我在哪里可以在 Android 中的 Citrus 支付集成中获得响应
【发布时间】:2016-06-16 19:34:33
【问题描述】:

我在安卓应用中集成了柑橘支付网关。我不知道从哪里得到响应。如果交易成功或失败。

这是我的代码..问题是每当交易完成或成功时,柑橘支付库都会显示一个带有适当消息的屏幕,当我点击返回时,我会在 onActivityResult 中得到结果......我想要结果之后立即交易完成..谢谢 我从这里开始:http://www.citruspay.com/DevelopersGuide/android/plugandplay.html

 if (res.equalsIgnoreCase("true")) {

                        setupCitrusConfigs();
                        CitrusFlowManager.startShoppingFlow(CheckOut.this,
                                User_Email, Txt_Phone.getText().toString(), String.valueOf(Amt_Payable));

                    }

                     private void setupCitrusConfigs() {

        CitrusFlowManager.initCitrusConfig("kkkkkkk-signup",
                "dfdffgfdgfdgffdgdfgdfgdfgdfgfdg", "fgfgfdgfdg-signin",
                "fgfdgdfgfdgfgfdgfgdfffd", getResources().getColor(R.color.white),
                CheckOut.this, Environment.SANDBOX, "vvvvvvvvd", sandboxBillGeneratorURL,
                returnUrlLoadMoney);
    }

     @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);
        // check if the request code is same as what is passed  here it is 2
        Log.d("CheckOut","request code " + requestCode + " resultcode " + resultCode);
        if(requestCode == Constants.REQUEST_CODE_PAYMENT && resultCode == RESULT_OK && data != null) {
            // You will get data here if transaction flow is started through pay options other than wallet
            TransactionResponse transactionResponse = data.getParcelableExtra(Constants
                    .INTENT_EXTRA_TRANSACTION_RESPONSE);
            // You will get data here if transaction flow is started through wallet
            ResultModel resultModel = data.getParcelableExtra(ResultFragment.ARG_RESULT);

            // Check which object is non-null
            if(transactionResponse != null && transactionResponse.getJsonResponse() != null) {

                try {

                    JSONObject json = new JSONObject(transactionResponse.getJsonResponse());
                    String Status =  json.getString("TxStatus");

                    if(Status.equalsIgnoreCase("SUCCESS")){

                        db.EmptyCart();
                        Intent i = new Intent(CheckOut.this, MainActivity.class);
                        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                        startActivity(i);

                        Log.e("Trans", "Transaction Successfull " + Status);

                    }else {
                        Log.e("Trans","Transaction Failed "+Status);
                    }

                } catch (JSONException e1) {
                    e1.printStackTrace();
                }


                // Decide what to do with this data
                Log.d(TAG, "transaction response" + transactionResponse.getJsonResponse());

            } else if(resultModel != null && resultModel.getTransactionResponse() != null){
                // Decide what to do with this data

                try {

                    JSONObject json = new JSONObject(resultModel.getTransactionResponse().getJsonResponse());
                    String Status =  json.getString("TxStatus");

                    if(Status.equalsIgnoreCase("SUCCESS")){

                        db.EmptyCart();
                        Intent i = new Intent(CheckOut.this, MainActivity.class);
                        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                        startActivity(i);

                        Log.e("Trans", "Transaction Successfull " + Status);

                    }else {
                        Log.e("Trans","Transaction Failed "+Status);
                    }

                } catch (JSONException e1) {
                    e1.printStackTrace();
                }

            } else {

                Log.d(TAG, "Both objects are null!");
            }
        }



    }

【问题讨论】:

  • 欢迎来到 SO 我们需要您的一些代码才能为您提供适当的帮助。
  • 这是很多代码...您可以尝试制作一个MVCE,以便您的问题更简洁吗?如果您的问题只是关于柑橘,我们不需要整个应用程序

标签: android payment-gateway citrus-pay


【解决方案1】:

使用借记卡付款

CitrusClient citrusClient = CitrusClient.getInstance(context); // Activity Context
// No need to call init on CitrusClient if already done.

DebitCardOption debitCardOption = new DebitCardOption("Card Holder Name", "4111111111111111", "123", Month.getMonth("12"), Year.getYear("18"));

Amount amount = new Amount("5");
// Init PaymentType     
PaymentType.PGPayment pgPayment = new PaymentType.PGPayment(amount, BILL_URL, debitCardOption, new CitrusUser("developercitrus@gmail.com","9876543210"));

citrusClient.simpliPay(pgPayment, new Callback<TransactionResponse>() {

     @Override
     public void success(TransactionResponse transactionResponse) { }

     @Override
     public void error(CitrusError error) { }
  });

使用信用卡支付

CitrusClient citrusClient = CitrusClient.getInstance(context); // Activity Context
// No need to call init on CitrusClient if already done.

CreditCardOption creditCardOption = new CreditCardOption("Card Holder Name", "4111111111111111", "123", Month.getMonth("12"), Year.getYear("18"));

Amount amount = new Amount("5");
// Init PaymentType     
PaymentType.PGPayment pgPayment = new PaymentType.PGPayment(amount, BILL_URL, creditCardOption, new CitrusUser("developercitrus@gmail.com","9876543210"));

citrusClient.simpliPay(pgPayment, new Callback<TransactionResponse>() {

     @Override
     public void success(TransactionResponse transactionResponse) { }

     @Override
     public void error(CitrusError error) { }
  });

使用网上银行选项付款

CitrusClient citrusClient = CitrusClient.getInstance(context); // Activity Context
// No need to call init on CitrusClient if already done.

NetbankingOption netbankingOption = new NetbankingOption("ICICI Bank","CID001");

// Init Net Banking PaymentType     
PaymentType.PGPayment pgPayment = new PaymentType.PGPayment(amount, BILL_URL, netbankingOption, new CitrusUser("developercitrus@gmail.com","9876543210"));

citrusClient.simpliPay(pgPayment, new Callback<TransactionResponse>() {

     @Override
     public void success(TransactionResponse transactionResponse) { }

     @Override
     public void error(CitrusError error) { }
  });

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-12
  • 2015-12-27
  • 2016-07-28
  • 2011-02-24
相关资源
最近更新 更多