GoPay is an E-Wallet . Users can pay using the Gojek app, GoPay app or any QRIS compatible app. The user flow is different for web browser (on a computer or a tablet) and mobile phone:
- QR Code - This is the user flow on a web browser (on a computer or a tablet). User is shown a QR code and asked to scan using any QRIS compatible app, such as Gojek app or GoPay app. (Sequence Diagram for QR Code)
- Deeplink - This is the user flow on a mobile device. User gets redirected to the Gojek app or GoPay app to finish payment. (Sequence Diagram Deeplink). For more details related to redirection to Gojek and GoPay app, please read this article.
By default, GoPay Deeplink and QRIS's transaction expiry is 15 minutes (min 20s, max 7 days). For custom expiry, please refer to this section.
Sequence Diagram for QR Code
Sequence Diagram for Deeplink
The steps to integrate with GoPay are as follows:
- Create payment instructions for users (see example below).
- Send the charge API request to Midtrans.
- Alter payment flow depending on the device used:
- On a computer or tablet: Show QR code image (on a computer or a tablet).
- On a mobile device: Redirect user with the deeplink URL that given from the response.
- Handle notifications from Midtrans.
Instruction Example For QR Code
- Tap Pay using GoPay.
- Click Pay Now. QR code will be displayed.
- Open Gojek app or GoPay app on your mobile phone.
- Scan the QR code.
- Verify your payment details and then click Pay.
- Verify your Security PIN and finish your transaction.
Instruction Example For Deeplink
- Tap Pay using GoPay.
- You will be redirected to Gojek app or GoPay App.
- Verify your payment details and then click Pay.
- Verify your Security PIN and finish your transaction.
In summary:
Send a Charge API request with the details of the transaction such as payment_type
:gopay
, transaction_details
, item_details
, and customer_details
. Successful request returns a deeplink redirect URL or QR code image URL.
GoPay Charge API Request
{
"payment_type": "gopay",
"transaction_details": {
"order_id": "order03",
"gross_amount": 275000
},
"item_details": [
{
"id": "id1",
"price": 275000,
"quantity": 1,
"name": "Bluedio H+ Turbine Headphone with Bluetooth 4.1 -"
}
],
"customer_details": {
"first_name": "Budi",
"last_name": "Utomo",
"email": "[email protected]",
"phone": "081223323423"
},
"gopay": {
"enable_callback": true,
"callback_url": "someapps://callback"
}
}
JSON Attribute | Description | Type | Required |
---|---|---|---|
payment_type | Set GoPay payment method. Value: gopay . | String | Required |
transaction_details | The details of the specific transaction such as order_id and gross_amount . | Object | Required |
item_details | Details of the item(s) purchased by the customer. | Object | Required |
customer_details | Details of the customer. | Object | Required |
gopay | Charge details using GoPay. | Object | Required |
GoPay Charge Response and Notifications
{
"status_code": "201",
"status_message": "GO-PAY billing created",
"transaction_id": "e48447d1-cfa9-4b02-b163-2e915d4417ac",
"order_id": "SAMPLE-ORDER-ID-01",
"gross_amount": "10000.00",
"payment_type": "gopay",
"transaction_time": "2017-10-04 12:00:00",
"transaction_status": "pending",
"actions": [{
"name": "generate-qr-code",
"method": "GET",
"url": "https://api.midtrans.com/v2/gopay/e48447d1-cfa9-4b02-b163-2e915d4417ac/qr-code"
},
{
"name": "deeplink-redirect",
"method": "GET",
"url": "gojek://gopay/merchanttransfer?tref=1509110800474199656LMVO&amount=10000&activity=GP:RR&callback_url=someapps://callback?order_id=SAMPLE-ORDER-ID-01"
},
{
"name": "get-status",
"method": "GET",
"url": "https://api.midtrans.com/v2/e48447d1-cfa9-4b02-b163-2e915d4417ac/status"
},
{
"name": "cancel",
"method": "POST",
"url": "https://api.midtrans.com/v2/e48447d1-cfa9-4b02-b163-2e915d4417ac/cancel",
"fields": []
}
],
"channel_response_code": "200",
"channel_response_message": "Success",
"currency": "IDR"
}
{
"status_code": "201",
"status_message": "midtrans payment notification",
"transaction_id": "1c28dbbb-8596-48e4-85d7-9f1382db8a1f",
"order_id": "order03",
"gross_amount": "275000.00",
"payment_type": "gopay",
"transaction_time": "2016-06-19 15:50:12",
"transaction_status": "pending",
"signature_key": "40747f7f8f489c423c8ed72879ca8cb28dcd0c03fc9a192138667c4588f91486ae46094a6695d9fddbce0abab8055fd483b65ecf59e3c43d4a22cc024326993a"
}
{
"status_code": "200",
"status_message": "midtrans payment notification",
"transaction_id": "1c28dbbb-8596-48e4-85d7-9f1382db8a1f",
"order_id": "order03",
"gross_amount": "275000.00",
"payment_type": "gopay",
"transaction_time": "2016-06-19 15:54:42",
"transaction_status": "settlement",
"signature_key": "973d175e6368ad844b5817882489e6b22934d796a41a0573c066b1e64532dc0001087b87d877a3eac37cba20a733e1305f5e62739e65ff501d5d33c5ac62530f"
}
"status_code": "202",
"status_message": "midtrans payment notification",
"transaction_id": "1c28dbbb-8596-48e4-85d7-9f1382db8a1f",
"order_id": "order03",
"gross_amount": "275000.00",
"payment_type": "gopay",
"transaction_time": "2016-06-20 15:50:12",
"transaction_status": "expire",
"signature_key": "53c6e2e3639a6b5c09b9103aa343f00cfd0168c6a69a2d4f2203bdc58072531ad7b340ea01725538996a7827c4ce091fb94d0aa70778a20c69d3f9991e0f65eb"
}
JSON Attribute | Description | Type |
---|---|---|
status_code | Status code of transaction charge result. | String |
status_message | Description of transaction charge result. | String |
transaction_id | Transaction ID given by Midtrans. | String |
order_id | Order ID specified by you. | String |
gross_amount | Total amount of transaction in IDR. | String |
payment_type | Transaction payment method. | String |
transaction_time | Timestamp of transaction in ISO 8601 format. Time Zone: GMT+7. | String |
transaction_status | Status of GoPay transaction. Possible values arepending , settlement , expire , deny . | String |
actions | Actions which can be performed with this transaction. Use generate-qr-code action to render the QR code image (PNG format). Use deeplink-redirect action to redirect to Gojek apps. | Array(Object) |
channel_response_code | Response code from payment channel provider. | String |
channel_response_message | Response message from payment channel provider. | String |
signature_key | Combination of parameters such as order_id , status_code , gross_amount , server_key to verify integrity of payload/response. | String |
Note
Possible error codes are 400, 401, 402, 406, 410
Implementing GoPay Deeplink Callback
In addition to the standard mobile apps flow, you can implement deeplink callback to redirect customer back from GoPay to your app.
Prerequisites
E-commerce needs to prepare a deeplink which accepts two query parameters.
Query Parameter | Description | Type |
---|---|---|
order_id | Order ID sent on the Charge Request. | String |
result | Result of the transaction to decide what kind of page to show to customer. Possible values are success or failure . | String |
Note
It is highly recommended to avoid using value passed on
result
to update status on backend. There is HTTP notification for this use case.
The steps to integrate with GoPay deeplink (Please look into the GoPay Charge API Request for sample implementation) are given below.
- Set
enable_callback
parameter in the charge request totrue
. - Set
callback_url
with the deeplink URL redirecting to E-commerce apps (via API request / configure in Dashboard > Settings > Payments) - Handle redirection with above parameters.