SSLCommerz and bKash
Pay through SSLCommerz with a test bKash wallet, get the POST redirect and the signed IPN, and validate the payment.
Try it in the demo.
The situation: your app sells in Bangladesh through SSLCommerz. Customers pay with cards, mobile wallets (bKash, Nagad, Rocket) or internet banking. You need to test the success, fail and cancel redirects, the IPN with its verify_sign, and the order validation call.
You need: your app's SSLCommerz client pointing at http://127.0.0.1:8026, and its IPN handler URL.
Steps
- In Payments > Gateways, edit SSLCommerz. On Merchant, set
store_idandstore_passwdto what your app sends, and the Notification endpoint to an endpoint for your IPN URL. - In your app, start a payment. The session answer sends the browser to SendMock's checkout page, with tabs: Cards, Mobile banking, Net banking.
- Open Mobile banking and pick bKash. Enter
01770000001and press Confirm, the code123456and Confirm, the PIN12121and Confirm and pay. - SendMock sends the browser back to your
success_urlby POST with SSLCommerz's fields (status=VALID,tran_id,val_id, ...), and posts the IPN. - Your app calls the order validation API with
val_id; SendMock answers from the payment.
Try 01770000002 (insufficient balance) for the fail path, and Cancel payment in the test controls for the cancel path.
In your code
A test that starts an SSLCommerz checkout and pays it with the test bKash wallet, as a customer would on the checkout page.
The examples call SendMock's REST API with each language's usual HTTP client and test framework. JavaScript, Go, Java, Rust, Ruby and C# use the small call helper shown under Test helper on their page in Connect your app.
payment=$(sendmock payments checkout create --provider sslcommerz --amount-minor 150000 --currency BDT --json)
checkout=$(sendmock payments checkout complete "$(jq -r '.id' <<<"$payment")" pay --method-key bkash --entries '{"number":"01770000001","otp":"123456","pin":"12121"}' --json)
jq -e '.state == "completed"' <<<"$checkout" >/dev/nullWhat you should see
The payment in Payments with its redirect (POST, with the fields) and IPN in the timeline, and the IPN in Webhooks > Deliveries.
Try it in the demo
- Open Payments > Gateways, press Edit SSLCommerz, and on Checkout press Open a test checkout.
- Open the Mobile banking tab and pick bKash.
- Enter
01770000001, Confirm;123456, Confirm;12121, Confirm and pay. - The result says the browser returns by POST, with
VALIDamong the fields.