WeChat

Overview

WeChat (微信支付) is a Chinese payment service that allows customers to perform purchases and receive refunds by using WeChat Pay mobile application on base of WeChat messenger. Purchases are performed by using Payment Page and Gate, refunds—by using Gate.

General information

Payment method type E-wallet payments
Countries and regions China
Payment currencies CNY, EUR, HKD, JPY, SGD, THB, USD*
Currency conversion On ECommPay side
Purchases +
Payouts
Stored credentials payments
Full refunds +
Partial refunds +
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 the ECommPay key account manager
Note: * For exact information on available currencies refer to the ECommPay key account manager.

Interaction diagram

Payment processing by using the WeChat payment method requires merchant's web service, one of ECommPay interfaces, and the ECommPay payment platform, as well as WeChat service which is supported interactions with banks.



Operations support

  Interfaces Amounts
Payment Page CMS Plug-ins Gate Dashboard (Old Dashboard) minimum maximum
Purchases + +
Full refunds +
Partial refunds +

Processing scenarios

To perform a purchase operation, you need to redirect a customer to the WeChat service, while to initiate a refund, you need to receive a request from a customer via your web service.

Figure: Purchase by using Payment Page procedure



Figure: Purchase by using Gate procedure



Figure: Refund by using Gate procedure



The sections that follow provide detailed information about what you need to perform payments and how you can analyse the information on payments and operations.

Purchases by using Payment Page

General information

In the WeChat method, to perform a purchase by using Payment Page, the merchant web service should send a request with all the required parameters and signature to the ECommPay URL and get the callback with the payment result from the payment platform. When opening Payment Page, you can have Payment Page opened with the WeChat method selected. For more information about preselecting payment methods, see in Preselecting payment method.

The full sequence and particularities of the purchase process are provided below.



Figure: Purchase sequence in the Payment Page method:

  1. A customer initiates a purchase on the merchant's web service.
  2. The web service sends the request for Payment Page opening to the specified ECommPay URL.
  3. The request for opening is redirected to the payment platform.
  4. The payment platform performs the initial request processing that involves validation of the required parameters and signature.
  5. Requested Payment Page is generated into the ECommPay payment platform as specified in the project settings and the request parameters.
  6. Payment Page is displayed to the customer.
  7. The customer selects WeChat method.
  8. The payment platform receives the purchase request for payment processing.
  9. The payment platform performs the internal purchase request processing and sends it to the WeChat service.
  10. The purchase request is processed on the WeChat service side.
  11. The service generates the data for redirecting the customer to its payment form and sends it to the payment platform.
  12. The payment platform sends the customer redirection data to Payment Page.
  13. The customer is redirected to the WeChat service.
  14. The customer completes all the payment steps required.
  15. The payment is processed on WeChat side.
  16. The result is displayed to the customer on the service.
  17. The customer is redirected to Payment Page.
  18. WeChat sends the result notification to the payment platform.
  19. The payment platform sends a callback with the payment result to the web service.
  20. The payment platform sends the result to Payment Page.
  21. A page with the payment result information is displayed to the customer on Payment Page.

The sections that follow discuss in more details the request format and the Payment Page parameters to use in the WeChat payment method and provide the information on the format of callbacks with payment results. For the general information on how to use the API, see Payment Page API Description.

Request format

There are several things you need to consider when requesting a payment through the WeChat method:

  1. You must provide values for the basic minimum of parameters. Listed below are the parameters that are mandatory for any payment method:
    • project_id—the project ID obtained from ECommPay
    • payment_id—payment ID unique within the project
    • payment_currency—payment currency in ISO-4217 alpha-3 format
    • payment_amount—payment amount in minor units
    • customer_id—ID of the customer within the project.
  2. In some cases, there is more mandatory parameter:
  3. If you need to have payment form displayed with the WeChat method selected, set the force_payment_method parameter to wechat.
  4. If required, you can also add any other additional parameters Payment Page supports.
  5. After you specify all the parameters you need, you must create the signature for the request. For instructions on how to sign a payment request, see Signature generation and verification.

Thus, a correct payment request in the WeChat method must include project, customer, and payment IDs, the currency and the amount of a payment in the appropriate currency, as shown in the following example:

EPayWidget.run(
    { payment_id: 'X03936', 
      payment_amount: 10000, 
      payment_currency: 'EUR', 
      project_id: 239,    
      customer_id: 'customer1',
      language_code: zh, 
      signature: "kUi2x9U0FYldJrxh4yo+52Kt8KU\/RLCvhtT4DqtVUkDJrOcZzUCwX6R\/ekpZhkIQg=="
    }
)

For information about all parameters available in the WeChat method , see Payment Page invocation parameters.

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 an information about successful 100,00 EUR purchase on account 2626324568 in the 238 project.

Figure: Example of a successful purchase callback

 {
        "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": "yuuYzrj3kD1cKFh6Ba66wmDUY2a+CUnsiPrp5Q+ZYgrxBGJrJMo8oJqiyD7GgoTS+mvRA=="
    }

The following is the example of a callback for a purchase declined due to insufficient funds on the customer account.

Figure: Example of a declined purchase callback

{
        "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/mE0AlVOUDbbNqlXO/+e0Vt05S8vyeI14MBiRz0yJRrqn7HiBOEIObz2tN5SLw=="
    }
}

Related topics

The following topics might be useful when implementing payments through Payment Page:

Purchases by using Gate

General information

In the WeChat methods, when processing a purchase by using Gate, the merchant web service is required to do the following:

  1. Send a request with all the required parameters and signature to the ECommPay URL.
  2. Perform the redirection of a customer to the WeChat service.
  3. Get the callback with the payment result from the payment platform.

The following diagram provides the detailed picture of the payment processing procedure.



Figure: Purchase by using Gate

  1. A customer initiates a purchase through WeChat on the merchant's web service side.
  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 for processing the purchase from Gate.
  4. The payment platform performs the initial request processing that includes validation of the required parameters and signature.
  5. The payment platform sends the response with request receipt confirmation and correctness check result to the web service. For more information, see Response format.
  6. The payment platform performs the internal payment request processing and redirects the request to the WeChat service.
  7. The request is processed on the WeChat side.
  8. The WeChat service sends the data for redirecting the customer to the WeChat service to the payment platform.
  9. The payment platform sends the callback with the redirection data in the display_data object to the web service.
  10. The customer scans the QR code for redirection from the web service to the WeChat service.
  11. The customer completes all the payment steps required.
  12. The payment is processed on the WeChat side.
  13. The result is displayed to the customer.
  14. The customer is redirected to the merchant's web service.
  15. The WeChat service sends the payment result notification to the payment platform.
  16. The payment platform sends a callback to the web service.
  17. The customer receives the payment result on the web service.

The sections that follow discuss in more details the request format and the Gate parameters to use in the WeChat payment method and provide the information on the format of callbacks with purchase results.

Request format

There are several things you must consider when using purchase requests in the WeChat method:
  1. You send purchase requests by sending the /v2/payment/wallet/wechat/sale request by using HTTP method POST. This is e-wallets request group /v2/payment/wallet/{payment_method}/sale.
  2. The following objects and parameters must be specified in any request:
    • general—general purchase information:
      • project_id—project identifier
      • payment_id—unique purchase identifier
      • signature—signature created after you specify all the required parameters. For more information about signature generation, see Signature generation and verification
    • customer—customer information:
      • id—the ID of the customer within the merchant project
      • ip_address—customer IP address
    • payment—purchase information:
      • amount—purchase amount
      • currency—payout currency in the ISO-4217 alpha-3 format
      • description—description
  3. Additionally, depending on the payment processing provider, it is recommended to specify the phone number and e-mail address of the customer. If the request is missing the parameters, the list of parameters is sent in the clarification callback. For more details, see Additional payment information submission.

    It is recommended to use the following object and parameters:

    • Object customer—customer information:
      • email—email address
      • phone—phone number without the + sign, for example 861234567890
  4. The currency of purchase can only be one of the following: CNY, EUR, HKD, JPY, SGD, THB, USD.
  5. If required, you can also add any other additional parameters Gate supports.
  6. After you specify all the parameters you need, you must create the signature for the request. For instructions on how to sign a payment request, see Signature generation and verification.

Thus, a correct payment request in the WeChat method must include project and payment IDs, customer information, currency, amount, and description of the purchase, as shown in the following example:

Figure: Example of a purchase request

{
  "general": {
    "project_id": 200,
    "payment_id": "TEST_1559134591371-pz-2",
    "signature": "leNRGu/zTi7tB7T1HPmvelS7k6xZnJP6A8CpU74zrBdFd0ATe
                           CJjfr3dcxwEo6FgBqHDJMQmmWyDUcq3rJKqtw=="
  },
  "customer": {
    "ip_address": "185.123.193.224",
    "id": "customer123",
    "email": "customer@example.com",
    "phone": "861234567890"
  },
  "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 an information about successful 1.00 EUR purchase in the 238 project.

Figure: Example of a successful purchase callback

 {
        "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": "yuuYzrj3kD1cKFh6Ba66wmDUY2a+CUnsiPrp5Q+ZYgrxBGJrJMo8oJqiyD7GgoTS+mvRA=="
    }

The following is the example of a callback for a purchase declined due to insufficient funds on customer account.

Figure: Example of a declined purchase callback

{
        "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/mE0AlVOUDbbNqlXO/+e0Vt05S8vyeI14MBiRz0yJRrqn7HiBOEIObz2tN5SLw=="
    }
}

Related topics

The following topics might be useful when implementing payments through Gate:

Refund by using Gate

General information

You can make a full or partial refund to the customer through WeChat payment method. 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.

In WeChat method any refund is performed as follows: merchant's web service sends a request with all the required parameters and signature to ECommPay URL, and receives a callback with the payment result. The full sequence of the refund process is provided below.



Figure: Refund sequence in the Payment Page method

  1. A customer orders a refund by using merchant's web service.
  2. Merchant's web service sends the refund request for processing the refund by using Gate to the appropriate ECommPay URL.
  3. Gate redirects the request to the ECommPay payment platform.
  4. The payment platform performs all the necessary check and processes the request.
  5. The reply with the request processing results is sent to the merchant's web service. For more information, see Response format.
  6. The payment platform redirects the refund request to the WeChat service.
  7. The refund is processed on WeChat side.
  8. WeChat sends the result notification to the payment platform.
  9. The payment platform sends a callback with the payment result to the web service.
  10. The customer receives the information about the receipt of the requested funds from the web service.

The sections that follow discuss in more details the request format and the Gate parameters to use in the WeChat payment method and provide the information on the format of callbacks with refund results.

Request format

There are several things you must consider when using refund requests in the WeChat method:
  1. You perform refunds by sending the /v2/payment/wallet/wechat/refund/ request by using POST (HTTP) method. This is a request group for e-wallet payments: /v2/payment/wallet/{payment_method}/refund
  2. The following objects and parameters must be specified in any request:
    • general—general payment information:
      • project_id—project identifier
      • payment_id—unique payment identifier
      • signature—signature created after you specify all the required parameters. For more information about signature generation, see Signature generation and verification
    • customer—customer information:
      • ip_address—customer IP address
    • payment—refund information:
      • amount—amount (for partial refunds)
      • description—refund description or comment
  3. If required, you can also add any other additional parameters Gate supports.

Thus, a correct refund request in the WeChat method must include project and payment IDs, customer IP address, currency and amount (for partial refunds) of the refund, as shown in the following example:

Figure: Example of a refund request

  "general": {    
    "project_id": 239,    
    "payment_id": "refund_02",   
    "signature": "of8k9xerKBR4XL1QFaDH3p9Mh0CIcjmOwSwKJ7KLTZYO56lCv+f1M0Sf/7eg=="
  },  
    "customer": {    
     "ip_address": "1.2.3.4" 
 },  
    "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.

Here is an example of callback with an information about successful 100.00 USD refund for the customer account 2626324568 in the 238 project.

Figure: Example of a successful refund callback

{
        "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": "of8k9xerKSKpFBR4XL1QFaDH3p9Mh0CIcjmOwSwKJ7KLTZYO56lCv+f1M0Sf/7eg=="
    }

Here is an example of callback for a refund declined as the amount in the refund requested is greater than the amount in the initial payment.

Figure: Example of a declined refund callback

{
        "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": "d848450ce489c6293ef711269d2746527eaad747-995c67b9e87b97da81f86522434873a99f534e2c",
            "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/+VIRKN/C3Fh4qq7eL/X83wtvK2Ap9XTFAV7uHcrzXFse5nX1DAqn57Ypq8MxSMtpOBca0mhZ9ag=="
    }

Related topics

The following topics might be useful when implementing payments through 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.