This project demonstrates how to integrate the bKash Tokenized Checkout API using Java Spring Boot, with static sandbox credentials and payloads.
- β Get access token using app credentials
- β
Create a payment session and get
bkashURLfor redirect - β Handle callback after customer completes payment
- β Execute the payment to confirm success
- β
Capture and log final transaction info (
trxID,amount, etc.)
This section explains the available endpoints in the Spring Boot application and how the bKash payment integration works step by step.
- Purpose: Starts the payment process.
- How it works:
- The backend first generates an access token by calling bKashβs
/token/grantAPI. - Then it creates a payment session using bKashβs
/checkout/createendpoint. - The response contains a
bkashURLwhich is returned to the frontend. - The frontend should redirect the user to this URL so they can complete the payment in the bKash interface.
- The backend first generates an access token by calling bKashβs
GET /pay
β Returns bkashURL (example):
https://sandbox.payment.bkash.com/?paymentId=TR001...&hash=...Method: GET
Endpoint: /callback
Purpose: Handles the response from bKash after the customer completes (or cancels) the payment.
| Parameter | Type | Description |
|---|---|---|
paymentID |
String | The unique ID for this payment |
status |
String | Payment status: success, failure, or cancel |
signature |
String | Optional bKash-provided signature |
If status=success, the flow is:
- Extract
paymentIDfrom query params. - Call
getToken()again to fetch a valid token. - Call
executePayment(paymentID, token)to finalize the transaction. - You may store the response (which contains
trxID, amount, etc.) in your database. - Return the result to the frontend/user.
Success JSON Example:
{
"paymentID": "TR0011Pplo8lS1752517035835",
"trxID": "CGF20N477Q",
"transactionStatus": "Completed",
"amount": "100",
"currency": "BDT",
"intent": "sale",
"paymentExecuteTime": "2025-07-15T00:17:41:194 GMT+0600",
"merchantInvoiceNumber": "Inv123456",
"payerReference": "017XXXXXXXX",
"customerMsisdn": "01929918378",
"statusCode": "0000",
"statusMessage": "Successful"
}