Skip to content

Commit 8b0a899

Browse files
authored
Update README.md
1 parent a55d235 commit 8b0a899

File tree

1 file changed

+103
-31
lines changed

1 file changed

+103
-31
lines changed

README.md

Lines changed: 103 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
12
<p align="center" >
2-
<img src="https://www.bkash.com/sites/all/themes/bkash/logo.png?87980">
3+
<img src="https://www.bkash.com/images/favicon.png">
34
</p>
45

56
<h1 align="center">bKash(BD) Mobile Finance Payment Gateway Flutter Package</h1>
@@ -18,61 +19,132 @@ This is a [Flutter package](https://pub.dartlang.org/packages/flutter_bkash) for
1819
1920
Check the package in <a target="_blank" href="https://github.com/codeboxrcodehub/flutter-bkash" rel="noopener">github</a> and also available in <a href="https://pub.dartlang.org/packages/flutter_bkash" rel="noopener nofollow" target="_blank">flutter/dart package</a>
2021
## How to use:
21-
2222
Depend on it, Run this command With Flutter:
23-
2423
```
2524
$ flutter pub add flutter_bkash
2625
```
27-
2826
This will add a line like this to your package's `pubspec.yaml` (and run an implicit **`flutter pub get`**):
29-
3027
```
3128
dependencies:
32-
flutter_bkash: ^1.0.0
29+
flutter_bkash: ^0.1.3
30+
```
31+
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more. Import it, Now in your Dart code, you can use:
3332
```
34-
35-
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
36-
Import it
37-
38-
Now in your Dart code, you can use:
39-
40-
`
4133
import 'package:flutter_bkash/flutter_bkash.dart';
42-
`
34+
```
35+
## Features
36+
- Pay using bKash without an agreement
37+
- Create a bKash agreement for future payments
38+
- Pay using bKash with an agreement
4339

4440
## Usage
45-
4641
Official Link for API documentation and demo checkout
4742
- [bKash API Specifications](https://developer.bka.sh/v1.2.0-beta/reference)
4843
- [bKash Payment Checkout Demo](https://merchantdemo.sandbox.bka.sh/frontend/checkout)
4944

50-
Examples for see the `/example` folder.
45+
### Initialize the `FlutterBkash` instance:
5146

52-
**Here is the example code**
47+
***Sandbox***
5348
```
5449
final flutterBkash = FlutterBkash();
50+
```
51+
***Production***
52+
```
53+
final flutterBkash = FlutterBkash(
54+
credentials: BkashCredentials(
55+
username: "app_username",
56+
password: "app_password",
57+
appKey: "app_key",
58+
appSecret: "app_secret",
59+
isSandbox: false,
60+
),
61+
);
62+
```
63+
> Make sure to replace the provided credentials with your own bKash sandbox or production credentials depending on your development environment.
64+
65+
### Pay without Agreement
66+
To make a payment without an agreement, use the `pay` method:
67+
68+
***Request***
69+
```
70+
final result = await flutterBkash.pay(
71+
context: context, // BuildContext context
72+
amount: 100.0, // amount as double
73+
merchantInvoiceNumber: "invoice123",
74+
);
75+
```
76+
***Response***
77+
```
78+
BkashPaymentResponse(
79+
trxId: AFI60BAC94,
80+
payerReference: ,
81+
paymentId: TR0011fd4uZMS1687062024354,
82+
customerMsisdn: 01877722345,
83+
merchantInvoiceNumber: tranId,
84+
_executeTime: 2023-06-18T10:22:31:623 GMT+0600
85+
)
86+
```
87+
### Create Agreement
88+
To create a new agreement, use the `createAgreement` method:
89+
90+
***Request***
91+
```
92+
final result = await flutterBkash.createAgreement(context: context);
93+
```
94+
***Response***
95+
```
96+
BkashAgreementResponse(
97+
payerReference: ,
98+
paymentId: TR0000RCHQGmX1687063332607,
99+
customerMsisdn: 01877722345,
100+
agreementId: TokenizedMerchant02P1AIJ7G1687063381235,
101+
_executeTime: 2023-06-18T10:43:01:235 GMT+0600
102+
)
103+
```
104+
### Pay with Agreement
105+
To make a payment with an existing agreement, use the `payWithAgreement` method:
55106

107+
***Request***
108+
```
109+
final result = await flutterBkash.payWithAgreement(
110+
context: context, // BuildContext context
111+
amount: 100.0, // type as double
112+
agreementId: "agreement123",
113+
merchantInvoiceNumber: "invoice123",
114+
);
115+
```
116+
***Response***
117+
```
118+
BkashPaymentResponse(
119+
trxId: AFI60BAC94,
120+
payerReference: ,
121+
paymentId: TR0011fd4uZMS1687062024354,
122+
customerMsisdn: 01877722345,
123+
merchantInvoiceNumber: tranId,
124+
_executeTime: 2023-06-18T10:22:31:623 GMT+0600
125+
)
126+
```
127+
### Error Handling
128+
The methods mentioned above may throw a `BkashFailure` exception in case of an error. You can catch and handle the exception using a try-catch block:
129+
```
56130
try {
57-
final bkashPaymentResponse = await flutterBkash.pay(
58-
context: context,
59-
amount: double.parse(amount),
60-
marchentInvoiceNumber: "tranId",
61-
);
62-
63-
print(bkashPaymentResponse);
64-
} on BkashFailure catch (e, st) {
65-
print(e.message, error: e, stackTrace: st);
66-
} catch (e) {
67-
print("Something went wrong");
131+
// Make a payment or create an agreement
132+
} on BkashFailure catch (e) {
133+
// Handle the error
134+
print(e.message);
68135
}
69136
```
70137

138+
Examples for see the `/example` folder.
139+
140+
**Here is the example code**
141+
```
142+
Example Code implement here.
143+
```
144+
71145
### Importance Notes
72146
- Read the comments in the example of code
73147
- See the documents and demo checkout [bKash API Specifications](https://developer.bka.sh/v1.2.0-beta/reference), [bKash Payment Checkout Demo](https://merchantdemo.sandbox.bka.sh/frontend/checkout)
74-
<!-- - **intent** - it would be 'sale' or 'authorization' -->
75-
<!-- - Payment status return as 'paymentSuccess', 'paymentFailed', 'paymentError', 'paymentClose', find on this keyword of the payment status, then you get the data of response on specific status. -->
76148

77149

78150
## Contributing
@@ -86,4 +158,4 @@ Contributions to the **flutter_bkash** package are welcome. Please note the foll
86158

87159
flutter_bkash package is licensed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause).
88160

89-
Copyright 2022 [Codeboxr.com Team](https://codeboxr.com/team-codeboxr/). We are not affiliated with bKash and don't give any guarantee.
161+
Copyright 2023

0 commit comments

Comments
 (0)