flutter-bkash icon indicating copy to clipboard operation
flutter-bkash copied to clipboard

Create Payment Response , Execute Payment Response also needed for sandbox validation, which is absent in this package

Open sakib556 opened this issue 2 years ago • 6 comments
trafficstars

This package only return us the response like : BkashPaymentResponse(trxId: AGP10BWXOB, payerReference: , paymentId: TR0011hi0k0wq1690281134967, customerMsisdn: 01619777282, merchantInvoiceNumber: tranId, _executeTime: 2023-07-25T16:33:53:131 GMT+0600)

But as a merchant i need these 2 response to validate my sandbox merchant account and then i will get the live payment credentials from the pgwbkash merchant website (1) Need the Create Payment Response like this - { "statusCode": "0000", "statusMessage": "Successful", "paymentID": "TR0011ON1565154754797", "bkashURL": "https://sandbox.payment.bkash.com/redirect/tokenized/?paymentID=TR0011O N1565154754797&hash=Cg-Z)16.)d5E_BLhHIMmoxcm.LDMVQ.oI9o_v6qQU32nc7i2mUtDbP0_cVtIswrS-Rct1rJzJWEIPLk6cXFgRBT)rn6Q7!E.u91565154754979&mode=0011&apiVersion=v1.2.0-beta", "callbackURL": "yourURL.com", "successCallbackURL": "yourURL.com?paymentID=TR0011ON1565154754797&status=success", "failureCallbackURL": "yourURL.com?paymentID=TR0011ON1565154754797&status=failure", "cancelledCallbackURL": "yourURL.com?paymentID=TR0011ON1565154754797&status=cancel", "amount": "15", "intent": "sale", "currency": "BDT", "paymentCreateTime": "2019-08-07T11:12:34:978 GMT+0600", "transactionStatus": "Initiated", "merchantInvoiceNumber": "MER1231" } (2) Need the Execute Payment Response like this : { "statusCode": "0000", "statusMessage": "Successful", "paymentID": "TR0011ON1565154754797", "payerReference": "01770618575", "customerMsisdn": "01770618575", "trxID": "6H7801QFYM", "amount": "15", "transactionStatus": "Completed", "paymentExecuteTime": "2019-08-07T11:15:56:336 GMT+0600", "currency": "BDT", "intent": "sale", "merchantInvoiceNumber": "MER1231" }

sakib556 avatar Jul 25 '23 19:07 sakib556

@dev-masum, Please see it and if possible to update our package.

rdnasim avatar Jul 26 '23 02:07 rdnasim

@rdnasim we have all api implemetations for testing and custom implementation mentioned in Bkash developer documentation. Please add it in out package documentation that any package user can test all apis of bkash through BkashApi() class

final bkashApis  = BkashApi();

bkashApis.createToken(...);
bkashApis.createAgreement(...);
bkashApis.payWithAgreement(...);
bkashApis.payWithoutAgreement(...);
bkashApis.executePayWithoutAgreement(...);
bkashApis.executePayWithAgreement(...);
bkashApis.executeCreateAgreement(...);

all those methods mentions on Bkash Doc

dev-masum avatar Jul 27 '23 12:07 dev-masum

To solve the problem download this project & set your bKash sandbox credentials in \example\lib\main.dart like the following:

final flutterBkash = FlutterBkash(
  bkashCredentials: const BkashCredentials(
    username: "sandboxTokenizedUser02",
    password: "sandboxTokenizedUser02@12345",
    appKey: "4f6o0cjiki2rfm34kfdadl1eqq",
    appSecret: "2is7hdktrekvrbljjh44ll3d9l1dtjo4pasmjvs5vl5qr3fug4b",
    isSandbox: true,
  ),
);

Goto \lib\src\utils\api_helper.dart and print the response.body in the case of statuscode 200

switch (response.statusCode) {
    case 200:
      print(response.body);
      return right(json.decode(response.body) as Map<String, dynamic>);
    case 400:
      return left(BkashFailure(message: "Bad Request"));
    case 401:
      return left(BkashFailure(message: "Unauthorized Access"));
    case 403:
      return left(BkashFailure(message: "Forbidden"));
    case 404:
      return left(BkashFailure(message: "Not Found"));
    case 500:
      return left(BkashFailure(message: "Internal Server Error"));
    default:
      return left(BkashFailure());
}

Now run \example\lib\main.dart and perform a payment. Then you get your JSON responses in debug console 😊

mr-mamun-50 avatar Aug 04 '23 10:08 mr-mamun-50

ok thanks brother

sakib556 avatar Aug 05 '23 17:08 sakib556

Sandbox endpoint: https:// => .sandbox.bka.sh Production endpoint: https:// => .pay.bka.sh

is this DOT required on endpoint? collected from https://developer.bka.sh/docs

hellotazim avatar Nov 03 '23 08:11 hellotazim

@hellotazim Yes, It is required. Because it is the part of their domain.

dev-masum avatar Nov 03 '23 10:11 dev-masum