Guest User

Untitled

a guest
May 27th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. private void doPay() {
  2.  
  3. int rand = new Random().nextInt();
  4.  
  5. /*Mandatory Field*/
  6. MandatoryFieldModel mandatoryFieldModel = new MandatoryFieldModel("", "", "200",
  7. "trans_" + rand, CurrencyType.BDT, SdkType.TESTBOX, SdkCategory.BANK_LIST);
  8.  
  9. /*Call for the payment*/
  10. PayUsingSSLCommerz.getInstance().setData(this, mandatoryFieldModel, new OnPaymentResultListener() {
  11. @Override
  12. public void transactionSuccess(TransactionInfo transactionInfo) {
  13.  
  14. // If payment is success and risk label is 0.
  15. if (transactionInfo.getRiskLevel().equals("0")) {
  16. Log.d(TAG, "Transaction Successfully completed");
  17. Log.d(TAG, transactionInfo.getTranId());
  18. Log.d(TAG, transactionInfo.getBankTranId());
  19. Log.d(TAG, transactionInfo.getAmount());
  20. Log.d(TAG, transactionInfo.getStoreAmount());
  21. Log.d(TAG, transactionInfo.getTranDate());
  22. Log.d(TAG, transactionInfo.getStatus());
  23. }
  24. // Payment is success but payment is not complete yet. Card on hold now.
  25. else {
  26. Log.d(TAG, "Transaction in risk. Risk Title : " + transactionInfo.getRiskTitle().toString());
  27. }
  28.  
  29. }
  30.  
  31. @Override
  32. public void transactionFail(TransactionInfo transactionInfo) {
  33. // Transaction failed
  34. Log.e(TAG, "Transaction Fail");
  35. }
  36.  
  37. @Override
  38. public void error(int errorCode) {
  39. switch (errorCode) {
  40. // Your provides information is not valid.
  41. case ErrorKeys.USER_INPUT_ERROR:
  42. Log.e(TAG, "User Input Error");
  43. break;
  44. // Internet is not connected.
  45. case ErrorKeys.INTERNET_CONNECTION_ERROR:
  46. Log.e(TAG, "Internet Connection Error");
  47. break;
  48. // Server is not giving valid data.
  49. case ErrorKeys.DATA_PARSING_ERROR:
  50. Log.e(TAG, "Data Parsing Error");
  51. break;
  52. // User press back button or canceled the transaction.
  53. case ErrorKeys.CANCEL_TRANSACTION_ERROR:
  54. Log.e(TAG, "User Cancel The Transaction");
  55. break;
  56. // Server is not responding.
  57. case ErrorKeys.SERVER_ERROR:
  58. Log.e(TAG, "Server Error");
  59. break;
  60. // For some reason network is not responding
  61. case ErrorKeys.NETWORK_ERROR:
  62. Log.e(TAG, "Network Error");
  63. break;
  64. }
  65. }
  66. });
  67. }
Add Comment
Please, Sign In to add comment