Menu

WeChat Pay

Note: To learn about the features of WeChat Pay, there's an overviewhere

You can integrate with ourDirectmodel or ourHostedmodel.

All modes of payment are available through a single payment method code: WECHATPAY-SSL.

The default WeChat Pay mode is QR Code, with a time-out of 2 hours.

Direct payment request

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService merchantCode="YOUR_MERCHANT_CODE" version="1.4">
  <submit>
    <order orderCode="YOUR_ORDER_CODE"><!--Use a unique order code each time-->

       <description>Description here</description>
      <amount currencyCode="CNY" value="1000" exponent="2" />
      <paymentDetails>
        <WECHATPAY-SSL />
      </paymentDetails>
    </order>
  </submit>
</paymentService>

Time-out: paymentDetails

To override the time-out, include the element transactionTimeOut and set a value between 1 and 120 minutes.

Copied!
<paymentDetails>
  <WECHATPAY-SSL>
    <transactionTimeOut>10</transactionTimeOut>
  </WECHATPAY-SSL>
</paymentDetails>

Direct payment response

For QR Code payments we’ll return a base 64 encoded QR Code image. The image will be in PNG format and 256px.

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <reply>
    <orderStatus orderCode="YOUR_ORDER_CODE">
      <payment>
        <paymentMethod>WECHATPAY-SSL</paymentMethod>
        <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit" />
        <lastEvent>SENT_FOR_AUTHORISATION</lastEvent>
      </payment>
      <qrCode><![CDATA[iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQAAAAB0CZXLAAABdElEQVR42u2YQY7EIAwEyYln5KcJ/inP4ITXbkOkiTLa1Z7SEogZJaQuLey2IekvIy1gAQtYwAL+AJRkY9eGqfVs/r6xAWK/tvesNg3YHMMiF9CSLYoJdI0utqSdFDCNxWTimR2w8DtJAYQcBCJlvsTky4FIf2nXfPaHlwM6xHripGz/z179csACrECXQPIRtswGWMr4p2waLYk8a/pn4lAAkfI6TUARdRsb0HO11+5b5rvmZeUz5FgApL+L7eHGhAD6k3pgyzrcrN9MjAHoUdMjg7xX0cIIYHd6vqy4brfdZADMvqysHzCukHwxRIC36+ohl5BBJe3aEh0QRQRix8NNJgXQXeAsiHkcqYQNEFSTYcUJI9eNDdCZPmc0vWi9hA2I1j12SnAwl5s/MABxjBqtOwSW/HDOejswrhc0rPhq4xkB9ZrowTZWOIGCI7lMUuiACLlZTVzsPNgSAeN6AXduXhz1XhYpgHXrvoAFLGAB/wZ+ALLupPVI2cwlAAAAAElFTkSuQmCC]]></qrCode>
    </orderStatus>
  </reply>
</paymentService>

Hosted payment page request

Our HPP integration supports QR Code payments only. For a detailed guide to HPP payments see ourWPG Integration guide.

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <submit>
    <order orderCode="YOUR_ORDER_CODE" installationId="YOUR_INSTALLATION_ID">
      <description>Description here</description>
      <amount value="1000" currencyCode="CNY" exponent="2" />
      <paymentMethodMask>
        <include code="ALL" />
      </paymentMethodMask>
      <shopper>
        <shopperEmailAddress>demo@worldpay.com</shopperEmailAddress>
      </shopper>
    </order>
  </submit>
</paymentService>

Time-out: shopper

To override the time-out, include the element transactionTimeOut and set a value between 1 and 120 minutes.

Copied!
<shopper>
  <shopperEmailAddress>jshopper@myprovider.com</shopperEmailAddress>
  <transactionTimeOut>10</transactionTimeOut>
</shopper>

Hosted payment page response

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <reply>
    <orderStatus orderCode="YOUR_ORDER_CODE">
      <reference id="6931085378">https://payments.worldpay.com/app/hpp/integration/wpg/corporate?OrderKey=YOUR_MERCHANT_CODE%5EYOUR_ORDER_CODE&amp;Ticket=00154824253466102qNhTlodef8SQjIDdjyy9Ow&amp;source=sc6</reference>
    </orderStatus>
  </reply>
</paymentService>

We recommend that you append the following parameters to the redirect URL:

  • country
  • language
  • successURL
  • cancelURL

Order notifications

Once you submit a request to Worldpay we dispatch a SHOPPER_REDIRECTED order notification.

SHOPPER_REDIRECTED

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <notify>
    <orderStatusEvent orderCode="YOUR_ORDER_CODE">
      <payment>
        <paymentMethod>WECHATPAY-SSL</paymentMethod>
        <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        <lastEvent>SHOPPER_REDIRECTED</lastEvent>
      </payment>
      <journal journalType="SHOPPER_REDIRECTED">
        <bookingDate>
          <date dayOfMonth="17" month="01" year="2019"/>
        </bookingDate>
      </journal>
    </orderStatusEvent>
  </notify>
</paymentService>

SENT_FOR_AUTHORIZATION

We return a QR Code or Jump URL we dispatch a SENT_FOR_AUTHORISATION order notification.

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <notify>
    <orderStatusEvent orderCode="YOUR_ORDER_CODE">
      <payment>
        <paymentMethod>WECHATPAY-SSL</paymentMethod>
        <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        <lastEvent>SENT_FOR_AUTHORISATION</lastEvent>
      </payment>
      <journal journalType="SENT_FOR_AUTHORISATION" description="WECHAT_PAYMENT_ID">
        <bookingDate>
          <date dayOfMonth="17" month="01" year="2019"/>
        </bookingDate>
      </journal>
    </orderStatusEvent>
  </notify>
</paymentService>

AUTHORISED

Once the shopper completes the payment and authorisation is confirmed by WeChat Pay we dispatch an AUTHORISED notification.

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <notify>
    <orderStatusEvent orderCode="YOUR_ORDER_CODE">
      <payment>
        <paymentMethod>WECHATPAY-SSL</paymentMethod>
        <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        <lastEvent>AUTHORISED</lastEvent>
        <balance accountType="IN_PROCESS_AUTHORISED">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        </balance>
      </payment>
      <journal journalType="AUTHORISED">
        <bookingDate>
          <date dayOfMonth="17" month="01" year="2019"/>
        </bookingDate>
        <accountTx accountType="IN_PROCESS_AUTHORISED">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        </accountTx>
      </journal>
    </orderStatusEvent>
  </notify>
</paymentService>

REFUSED

For payments that time-out we dispatch a REFUSED notification.

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <notify>
    <orderStatusEvent orderCode="YOUR_ORDER_CODE">
      <payment>
        <paymentMethod>WECHATPAY-SSL</paymentMethod>
        <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        <lastEvent>REFUSED</lastEvent>
      </payment>
      <journal journalType="REFUSED" description="QR Code has expired">
        <bookingDate>
          <date dayOfMonth="17" month="01" year="2019"/>
        </bookingDate>
      </journal>
    </orderStatusEvent>
  </notify>
</paymentService>

CAPTURED

After a delay of 15 minutes your authorised payment will automatically be captured and we will dispatch a CAPTURED notification.

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <notify>
    <orderStatusEvent orderCode="YOUR_ORDER_CODE">
      <payment>
        <paymentMethod>WECHATPAY-SSL</paymentMethod>
        <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        <lastEvent>CAPTURED</lastEvent>
        <balance accountType="IN_PROCESS_CAPTURED">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        </balance>
      </payment>
      <journal journalType="CAPTURED">
        <bookingDate>
          <date dayOfMonth="17" month="01" year="2019"/>
        </bookingDate>
        <accountTx accountType="IN_PROCESS_CAPTURED" batchId="12">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        </accountTx>
        <accountTx accountType="IN_PROCESS_AUTHORISED" batchId="12">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="debit"/>
        </accountTx>
      </journal>
    </orderStatusEvent>
  </notify>
</paymentService>

SENT_FOR_REFUND

When a refund request has been submitted to WeChat Pay we will dispatch a SENT_FOR_REFUND notification.

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <notify>
    <orderStatusEvent orderCode="YOUR_ORDER_CODE">
      <payment>
        <paymentMethod>WECHATPAY-SSL</paymentMethod>
        <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        <lastEvent>SENT_FOR_REFUND</lastEvent>
        <balance accountType="IN_PROCESS_CAPTURED">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        </balance>
      </payment>
      <journal journalType="SENT_FOR_REFUND">
        <bookingDate>
          <date dayOfMonth="17" month="01" year="2019"/>
        </bookingDate>
        <accountTx accountType="IN_PROCESS_CAPTURED" batchId="13">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="debit"/>
        </accountTx>
      </journal>
    </orderStatusEvent>
  </notify>
</paymentService>

REFUND_FAILED

When a refund request is rejected we'll dispatch a REFUND_FAILED notification.

Copied!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//Worldpay//DTD Worldpay PaymentService v1//EN"
"http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="YOUR_MERCHANT_CODE">
  <notify>
    <orderStatusEvent orderCode="YOUR_ORDER_CODE">
      <payment>
        <paymentMethod>WECHATPAY-SSL</paymentMethod>
        <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        <lastEvent>REFUND_FAILED</lastEvent>
        <balance accountType="IN_PROCESS_CAPTURED">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        </balance>
      </payment>
      <journal journalType="REFUND_FAILED" description="REASON_FOR_FAILURE" >
        <bookingDate>
          <date dayOfMonth="17" month="01" year="2019"/>
        </bookingDate>
        <accountTx accountType="IN_PROCESS_CAPTURED" batchId="13">
          <amount value="1000" currencyCode="CNY" exponent="2" debitCreditIndicator="credit"/>
        </accountTx>
      </journal>
    </orderStatusEvent>
  </notify>
</paymentService>

Testing

The WeChat Pay simulator is available in the Worldpay Secure Test environment.

All requests return the same encoded QR code, allowing you to test the synchronous response and the embedding of the QR code image within your checkout page.

Orders will automatically authorise following a 15 second delay.

You can simulate other scenarios by using the following magic values in the amount field of your request.

StatusAmountResponseDescription
ERROR32000<![CDATA[Internal error]]>An internal error occurred between Worldpay and WeChat Pay.
SHOPPER_CANCELLED43000N/AOrder will automatically expire after a 15 second delay.