GoPay

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:

  1. 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)
  2. 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:

  1. Create payment instructions for users (see example below).
  2. Send the charge API request to Midtrans.
  3. 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.
  1. Handle notifications from Midtrans.

📘

Instruction Example For QR Code

  1. Tap Pay using GoPay.
  2. Click Pay Now. QR code will be displayed.
  3. Open Gojek app or GoPay app on your mobile phone.
  4. Scan the QR code.
  5. Verify your payment details and then click Pay.
  6. Verify your Security PIN and finish your transaction.


📘

Instruction Example For Deeplink

  1. Tap Pay using GoPay.
  2. You will be redirected to Gojek app or GoPay App.
  3. Verify your payment details and then click Pay.
  4. 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 AttributeDescriptionTypeRequired
payment_typeSet GoPay payment method. Value: gopay.StringRequired
transaction_detailsThe details of the specific transaction such as order_id and gross_amount.ObjectRequired
item_detailsDetails of the item(s) purchased by the customer.ObjectRequired
customer_detailsDetails of the customer.ObjectRequired
gopayCharge details using GoPay.ObjectRequired



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 AttributeDescriptionType
status_codeStatus code of transaction charge result.String
status_messageDescription of transaction charge result.String
transaction_idTransaction ID given by Midtrans.String
order_idOrder ID specified by you.String
gross_amountTotal amount of transaction in IDR.String
payment_typeTransaction payment method.String
transaction_timeTimestamp of transaction in ISO 8601 format. Time Zone: GMT+7.String
transaction_statusStatus of GoPay transaction. Possible values are
pending, settlement, expire, deny.
String
actionsActions 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_codeResponse code from payment channel provider.String
channel_response_messageResponse message from payment channel provider.String
signature_keyCombination 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 ParameterDescriptionType
order_idOrder ID sent on the Charge Request.String
resultResult 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.

  1. Set enable_callback parameter in the charge request to true.
  2. Set callback_url with the deeplink URL redirecting to E-commerce apps (via API request / configure in Dashboard > Settings > Payments)
  3. Handle redirection with above parameters.