跳转到内容

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.

  1. 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.
  1. Prepare for Recurring Payments For recurring payments, your server needs to choose the stored payment method to initiate the payment.

  2. 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 ParameterRequiredDescription
merchantTransInfoMThe reference for the payment, including a unique merchantTransID and merchantTransTime to specify the time you initiate the request.
transAmountMThe currency and value of the payment. The value must follow the currency's minor unit.
paymentMethodMSet paymentMethod.type to token, with paymentMethod.token.value specified from your stored token information.
transInitiatorMThe information of the terminal to initiate the transaction.
storeInfoOSupplemental store information. Required if your store is assigned multiple MCCs in EVO Cloud to indicate which MCC you are using for this payment.
tradeInfoOIf paymentMethod.token is an Alipay token, specify this field to indicate detailed information about this payment.
webhookOThe URL to receive notifications. Specify this to get notifications from EVO Cloud after the payment succeeds.
metadataOCustom 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.