WeChat

Overview

Introduction

WeChat is a payment method which allows to process payments in different currencies by using e-wallets in China. This method supports purchases and refunds.

This article provides information about working with the WeChat method: general insights are presented in the Overview section, while information about the actions required to process payments and perform other actions is presented in the sections that follow.

General information

Payment method type digital wallet payments
Payment instruments digital wallets
Countries and regions CN
Payment currencies CNY, EUR, HKD, JPY, SGD, THB, USD *
Currency conversion On ecommpay side
One-time purchases +
Credential-on-file purchases
Full refunds +
Partial refunds +
Payouts
Chargebacks
Notes
  • to perform payments, a customer must have a Chinese bank card linked to the application
  • in some cases there is a limit for payment lifetime—2 hours. For more information refer to the ecommpay key account manager
Onboarding and access fee refer to your ecommpay key account manager, additional information available in the ecommpay shop
Note: * For exact information on available currencies refer to the ecommpay key account manager.

Interaction diagram

Payment processing by using the WeChat method involves the merchant's web service, one of ecommpay interfaces, the ecommpay payment platform, and technical facilities of the WeChat service.



Operations support

Various platform interfaces can be used to process payments and perform operations using the WeChat method. Purchases can be processed by using Payment Page, Gate and Dashboard (using payment links), refunds—by using Gate and Dashboard.

Processing scenarios

To perform a purchase by using the WeChat method, you need to redirect the customer to the WeChat service, while to make a refund, you need to receive a request from the customer and notify the customer about the result of the refund via the web service.

Purchases by using Payment Page

General information

To process a purchase through Payment Page by using the WeChat method, the merchant's web service is required to send a request with all required parameters and signature to the ecommpay URL and receive a callback with the result. The full sequence and special aspects of purchase processing are provided below.



Figure 4. Purchase processing by using Payment Page: step-by-step description
  1. A customer initiates a purchase in the web service.
  2. The web service sends the request for opening Payment Page to the specified ecommpay URL.
  3. The request for opening Payment Page is sent to the payment platform.
  4. The payment platform receives the request and validates the required parameters and signature.
  5. Payment Page is generated based on the project and request parameters.
  6. Payment Page is displayed to the customer.
  7. The customer selects the WeChat method.
  8. The payment platform receives the request for processing the payment by using the WeChat method.
  9. The payment platform processes the request and sends it to the WeChat service.
  10. The request is processed on the WeChat service side.
  11. The data for redirecting the customer to the WeChat service is sent from the WeChat service to the payment platform.
  12. The data for redirecting the customer is sent from the payment platform to Payment Page.
  13. The customer is redirected to the WeChat service.
  14. The customer completes all required payment steps.
  15. The purchase is processed in the WeChat service.
  16. The result information is displayed to the customer in the WeChat service.
  17. The customer is redirected to Payment Page.
  18. The WeChat service sends a notification about the result to the payment platform.
  19. The payment platform sends the payment result callback to the web service.
  20. The payment platform sends the result information to Payment Page.
  21. The result information is displayed to the customer on Payment Page.

Information about the formats of requests and callbacks used for processing payments by using the WeChat method via Payment Page is presented further in this section; general information about working with the Payment Page API is presented in Interaction concepts.

Request format

There are several things you need to consider when sending purchase requests by using the WeChat method:

  1. The following parameters required for any payment must be specified:
    • project_id—project identifier obtained from ecommpay during integration
    • payment_id—payment identifier unique within the project
    • payment_currency—payment currency code in the ISO-4217 alpha-3 format
    • payment_amount—payment amount in the smallest currency unit
    • customer_id—customer identifier unique within the project
  2. The following parameters required for any payment must be specified: project_id, payment_id, payment_currency, payment_amount, customer_id.
  3. In some cases, it is required to specify the language_code parameter—language code to open Payment Page. For more information, see Interface language support.
  4. If you need to have the payment form displayed with the WeChat method selected, set the force_payment_method parameter to wechat.
  5. Additionally, any other parameters available for working with Payment Page can be used (details).
  6. After all target parameters are specified, generate a signature (details).

Thus, a correct request for opening the payment form using the WeChat method must contain the project identifier, basic payment information (identifier, amount, and currency code), customer identifier, language code and signature.

{
   "project_id": 120,
   "payment_id": "580",
   "payment_amount": 1000,
   "payment_currency": "EUR",
   "customer_id": "customer1",
   "language_code": "zh", 
   "signature": "kUi2x9dKHAVNU0FYldOcZzUCwX6R\/ekpZhkIQg=="
}
Figure 5. Example of sufficient data in a purchase request
{
   "project_id": 120,
   "payment_id": "580",
   "payment_amount": 1000,
   "payment_currency": "EUR",
   "customer_id": "customer1",
   "language_code": "zh", 
   "signature": "kUi2x9dKHAVNU0FYldOcZzUCwX6R\/ekpZhkIQg=="
}

Callback format

The WeChat method uses the standard format for callbacks to deliver purchase results. For more information, see Callbacks.

The following is the example of a callback with information about a 100,00 EUR purchase made in the 238 project.

Figure 6. Example of callback data indicating that the purchase has been processed
 {
        "project_id": 238,
        "payment": {
            "id": "TEST_154866061847343331",
            "type": "purchase",
            "status": "success",
            "date": "2019-01-28T08:07:22+0000",
            "method": "wechat",
            "sum": {
                "amount": 100,
                "currency": "EUR"
            },
            "description": "TEST_1548660618473453"
        },
        "operation": {
            "id": 9227000002916,
            "type": "sale",
            "status": "success",
            "date": "2019-01-28T08:07:22+0000",
            "created_date": "2019-01-28T08:06:40+0000",
            "request_id": "67af98801524dfa9c5cddb1a09129",
            "sum_initial": {
                "amount": 100,
                "currency": "EUR"
            },
            "sum_converted": {
                "amount": 100,
                "currency": "EUR"
            },
            "provider": {
                "id": 1173,
                "payment_id": "423163569",
                "date": "2019-01-28T08:07:22+0000",
                "auth_code": ""
            },
            "code": "0",
            "message": "Success"
        },
        "signature": "yuuYzrj3kD1cGJrJMo8oJqiyD7GgoTS+mvRA=="
    }

The following is the example of a callback with information about a declined purchase.

Figure 7. Example of callback data indicating that the purchase has been declined
{
        "project_id": 238,
        "payment": {
            "id": "TEST_154996862174000",
            "type": "purchase",
            "status": "decline",
            "date": "2019-02-12T10:56:22+0000",
            "method": "wechat",
            "sum": {
                "amount": 10000,
                "currency": "USD"
            },
            "description": "TEST_154996862174000"
        },
        "customer": {
            "id": "1"
        },
        "operation": {
            "id": 9172000003183,
            "type": "sale",
            "status": "decline",
            "date": "2019-02-12T10:56:22+0000",
            "created_date": "2019-02-12T10:56:18+0000",
            "request_id": "11d4aabf869cb74c0681927ad7",
            "sum_initial": {
                "amount": 10000,
                "currency": "USD"
            },
            "sum_converted": {
                "amount": 10000,
                "currency": "USD"
            },
            "provider": {
                "id": 1169,
                "payment_id": "",
                "auth_code": ""
            },
            "code": "20105",
            "message": "Insufficient funds on customer account"
        },
        "signature": "ghmnbvc1oVdS/mE0AlVJRrqn7HiBOEIObz2tN5SLw=="
    }
}

Useful links

The following articles can be useful when implementing purchases via Payment Page:

Purchases by using Gate

General information

To process a purchase through Gate by using the WeChat method, the merchant's web service is required to do the following:

  1. Send a request with all the required parameters and signature to the ecommpay URL.
  2. Receive an intermediate callback from the payment platform and redirect the customer to the WeChat service.
  3. Receive the final callback from the payment platform.

The full sequence and special aspects of purchase processing are provided below.



Figure 8. Purchase processing by using Gate: step-by-step description
  1. A customer initiates a purchase by using the WeChat method in the web service.
  2. The web service sends the request for processing the purchase by using Gate to the specified ecommpay URL.
  3. The payment platform receives the request.
  4. The payment platform validates the required parameters and signature in the request.
  5. The payment platform sends the response to the web service with information about the receipt of the request and its validity (details).
  6. The payment platform performs further processing of the request (with parameter consistency check) and sends it to the WeChat service.
  7. The request is processed on the WeChat service side.
  8. The WeChat service sends the redirection data to the payment platform.
  9. The payment platform sends the callback with the redirection data to the web service.
  10. The customer is redirected to the WeChat service.
  11. The customer completes all required payment steps.
  12. The purchase is processed in the WeChat service.
  13. The result is displayed to the customer.
  14. The customer is redirected to the web service.
  15. The WeChat service sends the payment result notification to the payment platform.
  16. The payment platform sends the payment result callback to the web service.
  17. The customer receives the payment result information from the web service.

Information about the formats of requests and callbacks used for processing payments by using the WeChat method via Gate is presented further in this section. General information about working with the Gate API is presented in Interaction concepts.

Request format

There are several things you need to consider when sending purchase requests by using the WeChat method:

  1. To initiate each purchase, send a separate POST request to the /v2/payment/wallet/wechat/sale endpoint. This endpoint belongs to the group /v2/payment/wallet/{payment_method}/sale.
  2. Each request must include the following objects and parameters:
    • Object general—general purchase information:
      • project_id—project identifier obtained from ecommpay during integration
      • payment_id—payment identifier unique within the project
      • signature—request signature generated after all required parameters are specified (details—in the Signature generation and verification) (details)
    • Object payment—payment information:
      • amount—payment amount in the smallest currency unit
      • currency—payment currency code in the ISO-4217 alpha-3 format
      • description—payment description
    • Object customer—customer information:
      • id—customer identifier unique within the project
      • ip_address—customer IP address relevant for the initiated payment
  3. Additionally, depending on the payment processing provider, it is recommended to specify the following objects and parameters:
    • Object customer—customer information:
      • email—customer email address
      • phone—customer phone number, must be specified using a country code and without punctuation or special characters, for example 19121234567, you can read more about the format in the FAQ section

    If any of these parameters are missing, the payment platform may send the list of missing parameters in a callback requesting additional information submission (details are available in Submission of additional payment information).

  4. Additionally, any other parameters included in the specification can be used.

Thus, a correct purchase request by using the WeChat method must contain the project identifier, basic payment information (identifier, amount, and currency code), customer information, as well as signature.

{
  "general": {
    "project_id": 200,
    "payment_id": "TEST_1559134591371-pz-2",
    "signature": "leNRGu/zTi7tB7T1HPmvelSMQmmWyDUcq3rJKqtw=="
  },
  "customer": {
    "ip_address": "192.0.2.0",
    "id": "customer123",
    "email": "customer@example.com",
    "phone": "19121234567"
  },
  "payment": {
    "amount": 1000,
    "currency": "EUR",
    "description": "test payment"
  }
}
Figure 9. Example of sufficient data in a purchase request
{
  "general": {
    "project_id": 200,
    "payment_id": "TEST_1559134591371-pz-2",
    "signature": "leNRGu/zTi7tB7T1HPmvelSMQmmWyDUcq3rJKqtw=="
  },
  "customer": {
    "ip_address": "192.0.2.0",
    "id": "customer123",
    "email": "customer@example.com",
    "phone": "19121234567"
  },
  "payment": {
    "amount": 1000,
    "currency": "EUR",
    "description": "test payment"
  }
}

Formats of the customer redirection data

To redirect a customer from the web service to the WeChat site, you must receive a callback from the payment platform containing the display_data array. This array can contain one or more objects with the following parameters:

  • type—object type
  • title—object title
  • data—data corresponding to the object type

The display_data array is formed taking into account the following conditions:

  • The object containing data for displaying the QR code is always present in the array. The value of the data parameter depends on the value of the type parameter which can have one of the following values:
    • qr_url—QR code is passed as a link the image. In this case the data parameter contains a URL.
    • qr_img—QR code is passed as an image. In this case the data parameter contains a string encoded using the Base64 scheme.
    • qr_data—QR code is passed as a string. In this case the data parameter contains a string which should be used to generate a QR code on the web service side.
  • In addition to the object containing the data for displaying the QR-code the display_data array can contain one or several objects with additional information. The type parameter of such objects is assigned the add_info value, while the data parameter can contain various information.
  • If the array contains one or more objects with additional information, then the array includes an object with the information on the lifespan of the QR code (starting when the code is created on the WeChat side). The title parameter of such an object is assigned the QR Code Timeout value, while the lifespan is specified in seconds in the data parameter.

The following is the callback fragment containing the string to be used to generate a QR code as well as the lifespan of the code.

 "display_data": [
            {
                "type": "qr_data",
                "title": "QR code",
                "data": "weixin://wxpay/bizpayurl?pr=dMrSpJG"
            },
            {
                "type": "add_info",
                "title": "QR Code Timeout",
                "data": "600"
            }
        ]

Callback format

The WeChat method uses the standard format for callbacks to deliver purchase results. For more information, see Callbacks.

The following is the example of a callback with information about a 1.00 EUR purchase made in the 238 project.

Figure 10. Example of callback data indicating that the purchase has been processed
 {
        "project_id": 238,
        "payment": {
            "id": "TEST_154866061847343331",
            "type": "purchase",
            "status": "success",
            "date": "2019-01-28T08:07:22+0000",
            "method": "wechat",
            "sum": {
                "amount": 100,
                "currency": "EUR"
            },
            "description": "TEST_1548660618473453"
        },
        "operation": {
            "id": 9227000002916,
            "type": "sale",
            "status": "success",
            "date": "2019-01-28T08:07:22+0000",
            "created_date": "2019-01-28T08:06:40+0000",
            "request_id": "67af98801524dfa9c5cddb1a09129",
            "sum_initial": {
                "amount": 100,
                "currency": "EUR"
            },
            "sum_converted": {
                "amount": 100,
                "currency": "EUR"
            },
            "provider": {
                "id": 1173,
                "payment_id": "423163569",
                "date": "2019-01-28T08:07:22+0000",
                "auth_code": ""
            },
            "code": "0",
            "message": "Success"
        },
        "signature": "yuuYzrj3kD1cGJrJMo8oJqiyD7GgoTS+mvRA=="
    }

The following is the example of a callback with information about a declined purchase.

Figure 11. Example of callback data indicating that the purchase has been declined
{
        "project_id": 238,
        "payment": {
            "id": "TEST_154996862174000",
            "type": "purchase",
            "status": "decline",
            "date": "2019-02-12T10:56:22+0000",
            "method": "wechat",
            "sum": {
                "amount": 10000,
                "currency": "USD"
            },
            "description": "TEST_154996862174000"
        },
        "customer": {
            "id": "1"
        },
        "operation": {
            "id": 9172000003183,
            "type": "sale",
            "status": "decline",
            "date": "2019-02-12T10:56:22+0000",
            "created_date": "2019-02-12T10:56:18+0000",
            "request_id": "11d4aabf869cb74c0681927ad7",
            "sum_initial": {
                "amount": 10000,
                "currency": "USD"
            },
            "sum_converted": {
                "amount": 10000,
                "currency": "USD"
            },
            "provider": {
                "id": 1169,
                "payment_id": "",
                "auth_code": ""
            },
            "code": "20105",
            "message": "Insufficient funds on customer account"
        },
        "signature": "ghmnbvc1oVdS/mE0AlVJRrqn7HiBOEIObz2tN5SLw=="
    }
}

Useful links

The following articles can be useful when implementing purchases via Gate:

Refunds by using Gate

General information

To perform a refund through Gate by using the WeChat method, send a request with all required parameters and signature to the ecommpay URL and receive a callback with the result. In some cases, for one payment you can perform only one partial refund, then to make additional refunds for this payment you need to contact the technical support of the payment system. For more information refer to your ecommpay key account manager. The full sequence and special aspects of refund performing are provided below.



Figure 12. Refund performing by using Gate: step-by-step description
  1. A customer initiates a refund.
  2. The web service sends the request for performing the refund by using Gate to the specified ecommpay URL.
  3. The payment platform receives the request.
  4. The payment platform validates the required parameters and signature in the request.
  5. The payment platform sends the response to the web service with information about the receipt of the request and its validity (details).
  6. The payment platform performs further processing of the request (with parameter consistency check) and sends it to the WeChat service.
  7. The refund is processed on the side of the WeChat service.
  8. The WeChat service sends the result notification to the payment platform.
  9. The payment platform sends the result callback to the web service.
  10. The customer receives the refund result information from the web service.

Information about the formats of requests and callbacks used for performing refunds by using the WeChat method via Gate is presented further in this section. General information about working with the Gate API is presented in Interaction concepts.

Request format

There are several things you need to consider when sending refund requests by using the WeChat method:

  1. To initiate each refund, send a separate POST request to the /v2/payment/wallet/wechat/refund endpoint. This endpoint belongs to the group /v2/payment/wallet/{payment_method}/refund.
  2. Each request must include the following objects and parameters:
    • Object general—general refund information:
      • project_id—project identifier obtained from ecommpay during integration
      • payment_ididentifier of the payment that needs to be refundedpayment identifier
      • signature—request signature generated after all required parameters are specified (details—in the Signature generation and verification)
    • Object payment—refund information:
      • description—refund description or comment
      • amount—refund amount in the smallest currency unit (required for a partial refund)
    • Object customer—customer information:
      • ip_address—customer IP address relevant for the initiated refund
  3. Additionally, any other parameters included in the specification can be used.

Thus, a correct refund request by using the WeChat method must contain the project and payment identifiers, description of the refund, the customer IP address, signature, and, if necessary, the refund amount.

  "general": {    
    "project_id": 239,    
    "payment_id": "refund_02",   
    "signature": "of8k9xerKSK4SwKJ7KLTZYO56lCv+f1M0Sf/7eg=="
  },  
   "customer": {    
     "ip_address": "192.0.2.0" 
 },  
  "payment": {    
    "amount": 10000,    
    "description": "refund_02"
}
Figure 13. Example of sufficient data in a refund request
  "general": {    
    "project_id": 239,    
    "payment_id": "refund_02",   
    "signature": "of8k9xerKSK4SwKJ7KLTZYO56lCv+f1M0Sf/7eg=="
  },  
   "customer": {    
     "ip_address": "192.0.2.0" 
 },  
  "payment": {    
    "amount": 10000,    
    "description": "refund_02"
}

Callback format

The WeChat method uses the standard format for callbacks to deliver refund results. For more information, see Callbacks.

The following is the example of a callback with information about a 100.00 USD refund made in the 238 project.

Figure 14. Example of callback data indicating that the refund has been processed
{
        "project_id": 238,
        "payment": {
            "id": "refund_02",
            "type": "purchase",
            "status": "refunded",
            "date": "2019-02-19T14:25:25+0000",
            "method": "wechat",
            "sum": {
                "amount": 10000,
                "currency": "USD"
            },
            "description": "test_02"
        },
        "account": {
            "number": "2626324568"
        },
        "operation": {
            "id": 14153000003282,
            "type": "refund",
            "status": "success",
            "date": "2019-02-19T14:25:25+0000",
            "created_date": "2019-02-19T14:25:24+0000",
            "request_id": "9d11b2ca618ec3ba0f588af8af3c4fc9f5fa58f174",
            "sum_initial": {
                "amount": 10000,
                "currency": "USD"
            },
            "sum_converted": {
                "amount": 10000,
                "currency": "USD"
            },
            "provider": {
                "id": 413,
                "payment_id": "105887607",
                "date": "2019-02-19T14:25:24+0000",
                "auth_code": ""
            },
            "code": "0",
            "message": "Success"
        },
        "signature": "of8k9xerKSKpFBRKLTZYO56lCv+f1M0Sf/7eg=="
    }

The following is the example of a callback with information about a declined refund.

Figure 15. Example of callback data indicating that the refund has been declined
{
        "project_id": 198,
        "payment": {
            "id": "ECT_TEST_15428009030783",
            "type": "purchase",
            "status": "success",
            "date": "2018-11-23T13:46:39+0000",
            "method": "wechat",
            "sum": {
                "amount": 10000,
                "currency": "EUR"
            },
            "description": "ECT_TEST_1542800903078"
        },
        "customer": {
            "id": "1"
        },
        "operation": {
            "id": 13792000002073,
            "type": "refund",
            "status": "decline",
            "date": "2018-11-30T09:25:36+0000",
            "created_date": "2018-11-30T09:25:33+0000",
            "request_id": "d848450ce489a81f86522434873a99f534e2c",
            "sum_initial": {
                "amount": 10000,
                "currency": "EUR"
            },
            "sum_converted": {
                "amount": 10000,
                "currency": "EUR"
            },
            "provider": {
                "id": 413,
                "payment_id": "",
                "auth_code": ""
            },
            "code": "3283",
            "message": "Refund amount more than init amount"
        },
        "signature": "AO081Lg6GT/+VIR1DAqn57Ypq8MxSMtpOBca0mhZ9ag=="
    }

Useful links

The following articles can be useful when implementing refunds via Gate:

Analysis of payments results

As with other payment methods ecommpay offers, when using the WeChat method, you have several options to analyse the information about payments and operations performed by using the method—alone or in conjunction with other methods.

You can load and analyse all the necessary information in Dashboard, for instance you can use the analytic panels on the Analytics tab to this end.

Also, you can export the information for further analysis by using third party analytical tools. The following options are available:

  • Dashboard allows you to download reports in CSV and XLS formats—by using the tools on the Payments tab. You can perform export as a one-time download to your local computer or have payment data regularly exported and delivered to email addresses you specify.
  • Data API allows you to have payment information exported in JSON format and delivered to a URL you specify. The payment information is exported by using the /operations/get queries.

If you have any further questions regarding payment data analysis, contact ecommpay technical support.