Skip to content

Commit 32aebb2

Browse files
authored
Update README.md
1 parent 04b71cb commit 32aebb2

File tree

1 file changed

+50
-49
lines changed

1 file changed

+50
-49
lines changed

README.md

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -46,61 +46,62 @@ examples for see the `/example` folder.
4646

4747
**Here is the example code**
4848
```
49-
BkashPayment(
50-
// amount of your bkash payment
51-
amount: '20',
52-
// intent would be (sale / authorization)
53-
intent: 'sale',
54-
// accessToken: '', // if the user have own access token for verify payment
55-
// currency: 'BDT', // bkash url for create payment, when you implement on you project then it be change as your production create url createBKashUrl: 'https://merchantserver.sandbox.bka.sh/api/checkout/v1.2.0-beta/payment/create',
56-
// bkash url for execute payment, , when you implement on you project then it be change as your production create url
57-
executeBKashUrl: 'https://merchantserver.sandbox.bka.sh/api/checkout/v1.2.0-beta/payment/execute',
58-
// for script url, when you implement on production the set it live script js
59-
scriptUrl: 'https://scripts.sandbox.bka.sh/versions/1.2.0-beta/checkout/bKash-checkout-sandbox.js',
49+
BkashPayment(
50+
// amount of your bkash payment
51+
amount: '20',
52+
// intent would be (sale / authorization)
53+
intent: 'sale',
54+
// accessToken: '', // if the user have own access token for verify payment
55+
// currency: 'BDT', // bkash url for create payment, when you implement on you project then it be change as your production create url
56+
createBKashUrl: 'https://merchantserver.sandbox.bka.sh/api/checkout/v1.2.0-beta/payment/create',
57+
// bkash url for execute payment, , when you implement on you project then it be change as your production create url
58+
executeBKashUrl: 'https://merchantserver.sandbox.bka.sh/api/checkout/v1.2.0-beta/payment/execute',
59+
// for script url, when you implement on production the set it live script js
60+
scriptUrl: 'https://scripts.sandbox.bka.sh/versions/1.2.0-beta/checkout/bKash-checkout-sandbox.js',
6061
61-
// the return value from the package
62-
// status => 'paymentSuccess', 'paymentFailed', 'paymentError', 'paymentClose' // data => return value of response paymentStatus: (status, data) {
63-
dev.log('return status => $status');
64-
dev.log('return data => $data');
65-
66-
// when payment success
67-
if (status == 'paymentSuccess') {
68-
if (data['transactionStatus'] == 'Completed') {
69-
Style.basicToast('Payment Success');
70-
}
71-
}
62+
// the return value from the package
63+
// status => 'paymentSuccess', 'paymentFailed', 'paymentError', 'paymentClose' // data => return value of response paymentStatus: (status, data) {
64+
dev.log('return status => $status');
65+
dev.log('return data => $data');
66+
67+
// when payment success
68+
if (status == 'paymentSuccess') {
69+
if (data['transactionStatus'] == 'Completed') {
70+
Style.basicToast('Payment Success');
71+
}
72+
}
7273
73-
// when payment failed
74-
else if (status == 'paymentFailed') {
75-
if (data.isEmpty) {
76-
Style.errorToast('Payment Failed');
77-
} else if (data[0]['errorMessage'].toString() != 'null'){
78-
Style.errorToast("Payment Failed ${data[0]['errorMessage']}");
79-
} else {
80-
Style.errorToast("Payment Failed");
81-
}
82-
}
74+
// when payment failed
75+
else if (status == 'paymentFailed') {
76+
if (data.isEmpty) {
77+
Style.errorToast('Payment Failed');
78+
} else if (data[0]['errorMessage'].toString() != 'null'){
79+
Style.errorToast("Payment Failed ${data[0]['errorMessage']}");
80+
} else {
81+
Style.errorToast("Payment Failed");
82+
}
83+
}
8384
84-
// when payment on error
85-
else if (status == 'paymentError') {
86-
Style.errorToast(jsonDecode(data['responseText'])['error']);
87-
}
85+
// when payment on error
86+
else if (status == 'paymentError') {
87+
Style.errorToast(jsonDecode(data['responseText'])['error']);
88+
}
8889
89-
// when payment close on demand closed the windows
90-
else if (status == 'paymentClose') {
91-
if (data == 'closedWindow') {
92-
Style.errorToast('Failed to payment, closed screen');
93-
} else if (data == 'scriptLoadedFailed') {
94-
Style.errorToast('Payment screen loading failed');
95-
}
96-
}
97-
// back to screen to pop()
98-
Navigator.of(context).pop();
99-
},
100-
)
90+
// when payment close on demand closed the windows
91+
else if (status == 'paymentClose') {
92+
if (data == 'closedWindow') {
93+
Style.errorToast('Failed to payment, closed screen');
94+
} else if (data == 'scriptLoadedFailed') {
95+
Style.errorToast('Payment screen loading failed');
96+
}
97+
}
98+
// back to screen to pop()
99+
Navigator.of(context).pop();
100+
},
101+
)
101102
```
102103

103104
### Importance Notes
104105
- Read the comments in the example of code
105106
- **intent** - it would be 'sale' or 'authorization'
106-
- 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.
107+
- 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.

0 commit comments

Comments
 (0)