Accept a GrabPay payment
Learn how to accept GrabPay, a common payment method in Southeast Asia.
Note
Subscriptions and using GrabPay for future payments aren’t currently supported. Reach out to Stripe support for any support queries on these features.
GrabPay is a single-use payment method. Customers pay with GrabPay by redirecting from your app to GrabPay, authorizing the payment, then returning to your app where you get immediate notification on whether the payment succeeded or failed.
Note
Learn more about activating GrabPay in the Dashboard.
Set up StripeServer-side
First, you need a Stripe account. Register now.
Use our official libraries for access to the Stripe API from your application:
Create a PaymentIntentServer-side
A PaymentIntent represents your intent to collect payment from a customer and tracks the lifecycle of the payment process.
Create a PaymentIntent
on your server and specify the amount
to collect and sgd
or myr
as the currency. There is no minimum charge amount for GrabPay so the payment amount can be as low as 1. If you have an existing Payment Intents integration, add grabpay
to the list of payment method types.
Retrieve the client secret
The PaymentIntent includes a client secret that the client side uses to securely complete the payment process. You can use different approaches to pass the client secret to the client side.
Submit the payment to StripeClient-side
When a customer clicks to pay with GrabPay, use Stripe.js to submit the payment to Stripe. Stripe.js is the foundational JavaScript library for building payment flows. It automatically handles complexities like the redirect described below, and enables you to extend your integration to other payment methods. Include the Stripe.js script on your checkout page by adding it to the head
of your HTML file.
<head> <title>Checkout</title> <script src="https://js.stripe.com/v3/"></script> </head>
Create an instance of Stripe.js with the following JavaScript on your checkout page.
// Set your publishable key. Remember to change this to your live publishable key in production! // See your keys here: https://dashboard.stripe.com/apikeys const stripe = Stripe(
);'pk_test_TYooMQauvdEDq54NiTphI7jx'
To create a payment on the client side, add a Pay with GrabPay button and use stripe.
to handle the redirect away from your page and to complete the payment.
<button type="button" id="grabpay-button">Pay with GrabPay</button> <div id="error-message"></div>
const button = document.getElementById('grabpay-button'); button.addEventListener('click', async function() { // By this point, the PaymentIntent should have already been created // Pass the clientSecret of the PaymentIntent to confirmGrabPayPayment stripe.confirmGrabPayPayment(clientSecret, { // Return URL where the customer should be redirected after the authorization return_url: 'https://example.com/checkout/complete', }); });
Pass the client secret of the PaymentIntent
object that you created in Step 2 to stripe.
.
Additionally, add a return_
to this function to indicate where Stripe should redirect the user after they complete the payment on Grab’s website.
When your customer submits a payment, Stripe redirects them to the return_
and includes the following URL query parameters. The return page can use them to get the status of the PaymentIntent so it can display the payment status to the customer.
When you specify the return_
, you can also append your own query parameters for use on the return page.
Parameter | Description |
---|---|
payment_ | The unique identifier for the PaymentIntent . |
payment_ | The client secret of the PaymentIntent object. For subscription integrations, this client_secret is also exposed on the Invoice object through confirmation_ |
When the customer is redirected back to your site, you can use the payment_
to query for the PaymentIntent and display the transaction status to your customer.
<h2>Payment result</h2> <div class="payment-result"> </div> <script> // Check if we're returning from a redirect. const url = new URL(window.location.href); const paymentIntentClientSecret = url.searchParams.get( "paymentIntentClientSecret" ); if (paymentIntentClientSecret) { stripe.retrievePaymentIntent(paymentIntentClientSecret).then(function(result) { const paymentIntent = result.paymentIntent; document.querySelector(".payment-result").textContent = paymentIntent.status; }); } </script>
Test your integration
When testing, the client side redirect brings you to a Stripe-hosted GrabPay test payment page where you can either authorize or fail the test payment.
Supported currencies
Stripe users in Malaysia and Singapore can accept GrabPay payments from customers in Malaysia and Singapore respectively. Review the supported currencies and GrabPay transaction limits below:
Country | Customer country | Supported currency | Transaction limits |
---|---|---|---|
Singapore (SG) | Singapore (SG) | SGD | GrabPay SG |
Malaysia (MY) | Malaysia (MY) | MYR | GrabPay MY |