Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void doPay() {
- int rand = new Random().nextInt();
- /*Mandatory Field*/
- MandatoryFieldModel mandatoryFieldModel = new MandatoryFieldModel("", "", "200",
- "trans_" + rand, CurrencyType.BDT, SdkType.TESTBOX, SdkCategory.BANK_LIST);
- /*Call for the payment*/
- PayUsingSSLCommerz.getInstance().setData(this, mandatoryFieldModel, new OnPaymentResultListener() {
- @Override
- public void transactionSuccess(TransactionInfo transactionInfo) {
- // If payment is success and risk label is 0.
- if (transactionInfo.getRiskLevel().equals("0")) {
- Log.d(TAG, "Transaction Successfully completed");
- Log.d(TAG, transactionInfo.getTranId());
- Log.d(TAG, transactionInfo.getBankTranId());
- Log.d(TAG, transactionInfo.getAmount());
- Log.d(TAG, transactionInfo.getStoreAmount());
- Log.d(TAG, transactionInfo.getTranDate());
- Log.d(TAG, transactionInfo.getStatus());
- }
- // Payment is success but payment is not complete yet. Card on hold now.
- else {
- Log.d(TAG, "Transaction in risk. Risk Title : " + transactionInfo.getRiskTitle().toString());
- }
- }
- @Override
- public void transactionFail(TransactionInfo transactionInfo) {
- // Transaction failed
- Log.e(TAG, "Transaction Fail");
- }
- @Override
- public void error(int errorCode) {
- switch (errorCode) {
- // Your provides information is not valid.
- case ErrorKeys.USER_INPUT_ERROR:
- Log.e(TAG, "User Input Error");
- break;
- // Internet is not connected.
- case ErrorKeys.INTERNET_CONNECTION_ERROR:
- Log.e(TAG, "Internet Connection Error");
- break;
- // Server is not giving valid data.
- case ErrorKeys.DATA_PARSING_ERROR:
- Log.e(TAG, "Data Parsing Error");
- break;
- // User press back button or canceled the transaction.
- case ErrorKeys.CANCEL_TRANSACTION_ERROR:
- Log.e(TAG, "User Cancel The Transaction");
- break;
- // Server is not responding.
- case ErrorKeys.SERVER_ERROR:
- Log.e(TAG, "Server Error");
- break;
- // For some reason network is not responding
- case ErrorKeys.NETWORK_ERROR:
- Log.e(TAG, "Network Error");
- break;
- }
- }
- });
- }
Add Comment
Please, Sign In to add comment