Pay with gateway token
For later payment with one-off transactions, users can store payment information and make purchases on your website or app later using the stored information.
- Build the Payment Method Selection Page
- Create a page to present the user's stored payment methods for selection.
- You can use the details stored on your server or retrieve the user's stored payment methods from EVO Cloud. See the chapter on retrieving gateway tokens for more details.
Prepare for Recurring Payments For recurring payments, your server needs to choose the stored payment method to initiate the payment.
Make the Payment Request Once the user chooses a stored payment method, you can make an HTTP POST request to the EVO Cloud endpoint:
POST /g2/v1/payment/mer/{sid}/payment
Body Parameter | Required | Description |
---|---|---|
merchantTransInfo | M | The reference for the payment, including a unique merchantTransID and merchantTransTime to specify the time you initiate the request. |
transAmount | M | The currency and value of the payment. The value must follow the currency's minor unit. |
paymentMethod | M | Set paymentMethod.type to token , with paymentMethod.token.value specified from your stored token information. |
transInitiator | M | The information of the terminal to initiate the transaction. |
storeInfo | O | Supplemental store information. Required if your store is assigned multiple MCCs in EVO Cloud to indicate which MCC you are using for this payment. |
tradeInfo | O | If paymentMethod.token is an Alipay token, specify this field to indicate detailed information about this payment. |
webhook | O | The URL to receive notifications. Specify this to get notifications from EVO Cloud after the payment succeeds. |
metadata | O | Custom reference information that you can specify in the request, echoed back in the response. |
Here is an example of making a $10 payment using the token created in the previous step:
bash
curl -X POST https://{EVO_Cloud_DOMAIN_NAME.com}/g2/v1/payment/mer/{sid}/payment \
-H "Content-Type: application/json" \
-H "DateTime: 2021-12-31T08:30:59+0800" \
-H "MsgID: 2d21a5715c034efb7e0aa383b885fc7a" \
-H "SignType: SHA256" \
-H "Authorization: YOUR_MESSAGE_SIGNATURE" \
-d '{
"merchantTransInfo": {
"merchantTransID": "37693fac0946498f8afe35b9ffdcfe89",
"merchantTransTime": "2021-12-31T08:30:59+08:00"
},
"transAmount": {
"currency": "USD",
"value": "10.00"
},
"paymentMethod": {
"type": "token",
"token": {
"value": "pmt_9ab5560fb00c2fe9a56606593a8af294"
}
},
"webhook": "https://YOUR_COMPANY.com/WEBHOOK",
"metadata": "This is a metadata"
}'
TIP
Your next steps depend on whether the payment response contains an action
object. See chapter Payment for more details.