Learn about WeChat Pay, a digital wallet popular with customers from China. #
WeChat Pay serves as a digital wallet integrated into the popular Chinese superapp known as WeChat. Over the years, it has gained significant prominence as an essential payment solution for businesses seeking to connect with Chinese consumers, both domestically and internationally. WeChat has transformed into a comprehensive ecosystem, offering Chinese shoppers the convenience of chatting, browsing products or services, and making payments seamlessly within a unified platform. This integration has made the shopping experience as effortless as having a friendly conversation with your companions, all in one place.
特徴 #
顧客ロケーション | 中国の消費者 華僑 中国人旅行者 |
---|---|
通貨の処理 | CNY、GBP、USD、EUR、HKD |
決済通貨 | GBP, EUR, USD, HKD |
最低取引額 | 制限なし |
最大取引額 | 50,000 USD |
払い戻し | ✅ |
一部払い戻し | ✅ |
複数回の一部払い戻し | ✅ |
チャージバック | ❌ |
サブプロダクト #
Payment case | 製品 | 支払いシナリオの説明 |
---|---|---|
QR Code | ウェブ決済 | On Desktop browser, after selecting WeChatPay as a payment method merchant checkout, a QR code appears. The shopper then opens WeChat app on their mobile phone and scans the barcode displayed on the browser page to complete the payment. |
QR Code | Quick Pay | On point of sale, Merchants can display the QR code on the terminal and shoppers can open their WeChat app on their mobile phones to scan the QR code to complete payment. |
Mobile H5 Flows | H5 payment | On the mobile browser, a shopper selects WeChatPay as a payment method on Merchant checkout, and as redirected from the browser into the WeChatPay app to complete the payment before being redirected back to the Merchant browser. |
Mobile – In WeChat app | Official Account | Usually popular in more Chinese speaking markets, Merchants can consider building a profile page on the WeChat social site and prompt shoppers to select products and complete payment within the WeChat social site environment. |
Mobile – In WeChat app | Mini Program | Another spin on Official Accounts, a Mini Program is like a website within the WeChat social site where more customizations from the Merchant are possible and shoppers can select products and complete payment within that environment. |
支払いの流れ #
QR Code #
Mobile H5 Flows #
Mobile – In WeChat app #
統合方式 #
支払い方法の列挙値: wechat_pay
There are two integration methods for Wechat pay
- ダイレクトAPI
- チェックアウト
統合方式 | Wechat Pay subproduction | terminal_type列挙値 |
---|---|---|
ダイレクトAPI | ウェブ決済 | ウェブ |
ダイレクトAPI | Quick Pay | SCAN_CODE |
ダイレクトAPI | H5 Payment | WAP |
ダイレクトAPI | Official Account Payment | OFFICIAL_ACCOUNT |
ダイレクトAPI | Mini Program | MINI_PROGRAM |
統合方式 | Wechat Pay subproduction | terminal_type列挙値 |
---|---|---|
チェックアウト | ウェブ決済 | You don’t need to identify the terminal type in checkout. Checkout will automatically generate a QR code or redirect to WeChat App based on their device. |
チェックアウト | H5 Payment | You don’t need to identify the terminal type in checkout. Checkout will automatically generate a QR code or redirect to WeChat App based on their device. |
ダイレクトAPI #
PaymentIntentは、顧客から支払いを収集する意図を表すオブジェクトで、支払いプロセスのライフサイクルを追跡します。サーバー上にPaymentIntentを作成し、収集する金額とサポートする通貨を指定します。
PaymentIntentの作成 #
APIを直接統合する場合、PaymentIntentを作成し、1ステップでURLを取得することができます。以下は、PaymentIntentを作成するデモです:
- ウェブ決済
- H5 Payment
- Quick Pay
- Official Account Payment
ウェブ決済 #
リクエスト
{
"amount":20,
"currency":"CNY",
"confirm":true,
"payment_method_options":{
"wechat_pay":{
"terminal_type":"WEB",
"os_type":"IOS",
"client_ip":"192.168.0.1"
}
},
"payment_method_data":{
"type":"wechat_pay"
},
"return_url":"https://wooshpay.com"
}
応答
{
"id": "pi_1666625039547498496",
"object": "payment_intent",
"created": 1686189348000,
"livemode": false,
"currency": "CNY",
"amount": 20,
"status": "requires_action",
"client_secret": "pi_1666625039547498496_secret_qGj2VEg4khXSWkXvRI7Y3yZe",
"next_action": {
"type": "wechat_pay_display_qr_code",
"wechat_pay_display_qr_code": {
"image_data_url": "weixin://wxpay/bizpayurl?pr=lJhTByDzz"
}
},
"payment_method_types": [
"wechat_pay",
],
"confirmation_method": "automatic",
"payment_method_options": {
"wechat_pay": {
"terminal_type": "WEB",
"os_type": "IOS",
"client_ip": "192.168.0.1"
}
},
"return_url": "https://wooshpay.com",
"payment_method": "pm_1666625039430057984",
"capture_method": "automatic"
}
について image_data_url
from wechat_pay_display_qr_code
from 次のアクション
can be opened, from the link, the merchant can generate corresponding QR codes. Then use the corresponding QR code to charge.
H5 Payment #
リクエスト
{
"amount": 20,
"currency": "CNY",
"confirm": true,
"payment_method_options": {
"wechat_pay": {
"terminal_type": "WAP",
"client_ip": "192.168.124.133" //customer's mobile's ip
}
},
"payment_method_data": {
"type": "wechat_pay"
},
"return_url": "yourwebsite"
}
応答
{
"id": "pi_1666625208749916160",
"object": "payment_intent",
"created": 1686189389000,
"livemode": false,
"currency": "CNY",
"amount": 20,
"status": "requires_action",
"client_secret": "pi_1666625208749916160_secret_BeEXcbvAQNUkrV9C6ZFjOamS",
"next_action": {
"type": "wechat_pay_redirect_to_web",
"wechat_pay_redirect_to_web": {
"url": "https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx08095629694611f41b32df91d6ea160000&package=3449031350&redirect_url=https%3A%2F%2Fwooshpay.com"
}
},
"payment_method_types": [
"wechat_pay"
],
"confirmation_method": "automatic",
"payment_method_options": {
"wechat_pay": {
"terminal_type": "WAP",
"os_type": "IOS",
"client_ip": "172.31.5.62"
}
},
"return_url": "https://wooshpay.com",
"payment_method": "pm_1666625208624087040",
"capture_method": "automatic"
}
について url
from wechat_pay_redirect_to_web
from 次のアクション
can be opened, from the link, the customer will be direct to the wechat APP for payment, and be direct to return_url
after payment.
Quick Pay #
リクエスト
{
"amount":10,
"currency":"CNY",
"confirm":true,
"payment_method_options":{
"wechat_pay":{
"terminal_type":"SCAN_CODE",
"os_type":"IOS",
"client_ip":"192.168.0.1"
}
},
"payment_method_data":{
"type":"wechat_pay",
"wechat_pay":{
"payment_code":"132993614656096754"
}
},
"return_url":"https://yourweb.com"
}
応答
{
"id": "pi_1666627489012645888",
"object": "payment_intent",
"created": 1686189932000,
"livemode": false,
"currency": "CNY",
"amount": 10,
"status": "requires_action",
"client_secret": "pi_1666627489012645888_secret_t6oeKYYGb9egt3koNMsntfSg",
"payment_method_types": [
"wechat_pay"
],
"confirmation_method": "automatic",
"payment_method_options": {
"wechat_pay": {
"terminal_type": "SCAN_CODE",
"os_type": "IOS",
"client_ip": "192.168.0.1"
}
},
"return_url": "https://yourweb.com",
"payment_method": "pm_1666627488878428160",
"capture_method": "automatic"
}
The password-free payment can be paid directly, otherwise the customer needs to enter the password, fingerprint, etc. on the mobile phone to pay.
Official Account Payment #
リクエスト
{
"amount": 20,
"currency": "CNY",
"confirm": true,
"payment_method_options": {
"wechat_pay": {
"terminal_type": "OFFICIAL_ACCOUNT",
"client_ip": "192.168.0.1",
"openid": ""
}
},
"payment_method_data": {
"type": "wechat_pay"
}
}
応答
{
"id": "pi_1666626536515567616",
"object": "payment_intent",
"created": 1686189705000,
"livemode": false,
"currency": "CNY",
"amount": 20,
"status": "requires_payment_method",
"client_secret": "pi_1666626536515567616_secret_CcrukFKgxbPp7UEAxodLlNRD",
"last_payment_error": {
"code": "payment_method_provider_decline",
"message": "service error. Please try it again.",
"payment_method": {
"id": "pm_1666626536389738496",
"object": "payment_method",
"created": 1686189705000,
"livemode": false,
"type": "wechat_pay",
"billing_details": {}
},
"decline_code": "invalid_request_error"
},
"payment_method_types": [
"wechat_pay"
],
"confirmation_method": "automatic",
"payment_method_options": {
"wechat_pay": {
"openid": "",
"terminal_type": "OFFICIAL_ACCOUNT",
"client_ip": "192.168.0.1"
}
},
"payment_method": "pm_1666626536389738496",
"capture_method": "automatic"
}
wechat_pay_official_account_params
from 次のアクション
contains some parameters you need to use in the front end. Below is an example on how to use the parameters. js example
function onBridgeReady(){
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId":"wx7a154c094f74e84f",
"timeStamp":"1682239457",
"nonceStr":"kLRl3fI6FiP8PXxNNAiytwuQBdoCWXvZ",
"package":"prepay_id=wx23164417189051acf8825c57d275230000",
"signType":"MD5",
"paySign":"703868ed93842f83c9dff4d80d0cad67"
},
function(res){
if(res.err_msg == "get_brand_wcpay_request:ok" ) {} // Using the above method to judge the front-end return, the WeChat team solemnly reminds: res.err_msg will return ok after the user's payment is successful, but it does not guarantee that it is absolutely reliable.
}
);
}
if (typeof WeixinJSBridge == "undefined"){
if( document.addEventListener ){
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
}else if (document.attachEvent){
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
}
}else{
onBridgeReady();
}
Mini Program #
リクエスト
{
"amount": 20,
"currency": "GBP",
"confirm": true,
"payment_method_options": {
"wechat_pay": {
"terminal_type": "MINI_PROGRAM",
"client_ip": "192.168.0.1",
"openid": "ojt**********QnCY"
}
},
"payment_method_data": {
"type": "wechat_pay"
}
}
応答
{
"id": "pi_1684807723566235648",
"object": "payment_intent",
"created": 1690524438000,
"livemode": true,
"currency": "GBP",
"amount": 20,
"status": "requires_action",
"client_secret": "pi_1684807723566235648_secret_V3rhLjnidzwNnc7UomZJzzxc",
"next_action": {
"type": "wechat_pay_mini_program_params",
"wechat_pay_mini_program_params": {
"appId": "***********",
"timeStamp": "1690524439",
"nonceStr": "VVdQaFzG9LjOSNyGNLFbt7NZAn2oE87z",
"signType": "MD5",
"paySign": "9d0a90a35935d71d7a0f5f33689030fe",
"package": "prepay_id=wx281407195596079e2b5253415099630000"
}
},
"payment_method_types": [
"wechat_pay",
],
"confirmation_method": "automatic",
"payment_method_options": {
"wechat_pay": {
"openid": "**********",
"terminal_type": "MINI_PROGRAM",
"client_ip": "192.168.0.1"
}
},
"payment_method": "pm_1684807723448795136",
"capture_method": "automatic"
}
チェックアウト #
You can also utilize WeChat Pay via checkout hosted by WooshPay. To support payments, a Checkout Session must satisfy all of the following conditions:
- すべての行項目の価格は同じ通貨でなければなりません。異なる通貨で商品を購入する場合は、通貨ごとにチェックアウトセッションを作成してください。
- 使用できるのは1回限りの項目のみです。
Enable wechat pay as a payment method
新しいチェックアウト・セッションを作成する際には、以下のことが必要です:
Add Wechat Pay to the list of payment_method_types(支払い方法タイプ
.すべての 行目
同じ通貨を使う。
セッションの作成 #
リクエスト
{
"cancel_url": "https://wooshpay.com",
"mode": "payment",
"success_url": "https://wooshpay.com",
"payment_method_types": [
"wechat_pay"
],
"line_items": [
{
"price_data": {
"currency": "CNY",
"unit_amount": 100,
"product_data": {
"name": "fengli",
"url": "www.baidu.com"
}
},
"quantity": 1
}
]
}
応答
{
"id": "cs_1666627733867724800",
"object": "checkout.session",
"created": 1686189991000,
"livemode": false,
"currency": "CNY",
"customer": "",
"mode": "payment",
"status": "open",
"url": "https://checkouttest.wooshpay.com/pay/cs_test_1666627733867724800?key=pk_test_NTE1OTU5NzQ3NTQ2MTM5ODkzNzcxOktFZ0xlam1KbUxUb2gyUUNqWVVoaGpDSjE2NjkzNDUwMDgxMTE=",
"cancel_url": "https://wooshpay.com",
"line_items": {
"object": "list",
"data": [
{
"id": "li_1666627733993553920",
"object": "item",
"currency": "CNY",
"description": "fengli",
"price": {
"id": "price_1666627734022914048",
"object": "price",
"created": 1686189991000,
"livemode": false,
"active": true,
"currency": "CNY",
"product": {
"id": "prod_1666627734064857088",
"object": "product",
"created": 1686189991000,
"livemode": false,
"active": true,
"name": "fengli",
"url": "www.baidu.com",
"updated": 1686189991000
},
"type": "one_time",
"unit_amount": 100,
"billing_scheme": "per_unit"
},
"quantity": 1,
"amount_subtotal": 100,
"amount_total": 100
}
]
},
"payment_intent": "pi_1666627734450733056",
"payment_method_types": [
"wechat_pay"
],
"payment_status": "unpaid",
"success_url": "https://wooshpay.com",
"amount_subtotal": 100,
"amount_total": 100,
"billing_address_collection": "auto",
"expires_at": 1686276390865,
"payment_link": "",
"client_secret": "pi_1666627734450733056_secret_jajX5Fe4Qlp6VGEm0ftP1wcZ"
}
You can access the checkout counter through the url, and select WeChat payment. If the client is a web page, it will generate a QR code and you can scan the code for payment. If the client is a mobile terminal, it will directly jump to the WeChat APP for payment.
次のステップ #
必要に応じて、統合にさらに機能を追加することができます。
ウェブフックの作成 #
統合が自動的にリアクションをトリガーできるように、WooshPayアカウントのイベントをリッスンします。enabled_eventsとurlにフォーカスしたWebhookを作成します。
払い戻しの作成 #
顧客に資金を返済するために返金を作成します。部分払い戻しを行うこともできますが、すべての支払い方法が対応しているわけではありません。部分払い戻しとは、元の取引金額の一部のみを払い戻すことです。