codeboxrcodehub / flutter-bkash

Flutter/dart package for payment gateway bKash (Bangladesh)
https://pub.dev/packages/flutter_bkash
BSD 3-Clause "New" or "Revised" License
16 stars 15 forks source link

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

Closed sakib556 closed 1 week ago

sakib556 commented 1 year ago

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" }

rdnasim commented 1 year ago

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

dev-masum commented 1 year ago

@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

mr-mamun-50 commented 1 year ago

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 😊

sakib556 commented 1 year ago

ok thanks brother

hellotazim commented 1 year ago

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

dev-masum commented 1 year ago

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