{"title":"Mini Program for API-only","category":"default","creationDate":1567783140,"content":"<p>Make WeChat Pay available to your shopper on WeChat Mini Program with an API only integration.<\/p>\n<h2>Requirements<\/h2>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">Requirement<\/th>\n<th style=\"text-align: left;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><strong>Integration type<\/strong><\/td>\n<td style=\"text-align: left;\">Make sure that you have built an <a href=\"\/pt\/online-payments\/build-your-integration\/advanced-flow?platform=Web&amp;integration=API%20only\">API-only integration<\/a>. <\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>Setup steps<\/strong><\/td>\n<td style=\"text-align: left;\">Before you begin, <a href=\"\/pt\/payment-methods\/add-payment-methods\">add WeChat Pay Mini Program in your test Customer Area<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Preparation<\/h2>\n<p>Before you can accept WeChat Pay payments in your Mini Program:<\/p>\n<ol>\n<li>Create a <a href=\"https:\/\/developers.weixin.qq.com\/miniprogram\/en\/dev\/#Apply-for-an-account\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Mini Program account<\/a> with WeChat.<\/li>\n<li>\n<p>Contact our <a href=\"https:\/\/ca-test.adyen.com\/ca\/ca\/contactUs\/support.shtml?form=other\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Support Team<\/a> or your implementation manager and provide your:<\/p>\n<ul>\n<li>Mini Program AppID<\/li>\n<li>Entity name<\/li>\n<li>Currency<\/li>\n<\/ul>\n<p>These details are required to ensure that payments made with your Mini Program are settled to your Adyen account.<\/p>\n<\/li>\n<\/ol>\n<h2>Overview of payment flow<\/h2>\n<p>The diagram shows the flow of a Mini Program payment.<\/p>\n<div id=\"mermaid-69ea630dd7028-wrapper\"><div id=\"mermaid-69ea630dd7028\" class=\"mermaid-shortcode loading\">CnNlcXVlbmNlRGlhZ3JhbQpw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aW5pIHByb2dyYW0KICAgIG5vdGUgb3ZlciBXZUNoYXQgTWluaSBQcm9ncmFtOiBIYW5kbGUgcmVkaXJlY3QKICAgIG5vdGUgb3ZlciBXZUNoYXQgTWluaSBQcm9ncmFtOiBTaG93IHBheW1lbnQgcmVzdWx0CgogICAgQWR5ZW4tPj5NZXJjaGFudCBTZXJ2ZXI6IFdlYmhvb2sgYXV0aG9yaXNhdGlvbiBtZXNzYWdlIChhc3luY2hyb25vdXMpCgo=<\/div><\/div>\n<p>Follow the steps below to enable Mini Program payments.<\/p>\n<div class=\"sc-notice info\"><div>\n<p>Make all calls to Adyen from your server, not from your Mini Program.<\/p>\n<\/div><\/div>\n<h2>Step 1: Allow Adyen domains<\/h2>\n<p>Allow-list the following domains in your Mini Program settings:<\/p>\n<ul>\n<li><code>https:\/\/[YOUR_MERCHANT_PREFIX]-checkout-live.adyenpayments.com<\/code><\/li>\n<\/ul>\n<p>Find your <code>merchant prefix<\/code> in the <strong>Customer Area<\/strong>, by selecting <strong>Developers &gt; API URLs<\/strong>. Select the data center closest to your server.<\/p>\n<h2>Step 2: Get the user's openid<\/h2>\n<ol>\n<li>Use <span translate=\"no\"><strong>wx.login()<\/strong><\/span> to get <code>jsCode<\/code> in the success callback.<\/li>\n<li>\n<p>Use <span translate=\"no\"><strong>wx.request()<\/strong><\/span> to make the following call that returns the user's <code>openid<\/code> in the response:<\/p>\n<p><code>https:\/\/api.weixin.qq.com\/sns\/jscode2session?appid=${appId}&amp;secret=${secret}&amp;js_code=${jsCode}&amp;grant_type=authorization_code<\/code><\/p>\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><span translate=\"no\"><strong>appID<\/strong><\/span><\/td>\n<td>Available in your Mini Program Account.<\/td>\n<\/tr>\n<tr>\n<td><span translate=\"no\"><strong>secret<\/strong><\/span><\/td>\n<td>Available in your Mini Program Account.<\/td>\n<\/tr>\n<tr>\n<td><span translate=\"no\"><strong>jsCode<\/strong><\/span><\/td>\n<td>Obtained during the wx.login() call.<\/td>\n<\/tr>\n<tr>\n<td><span translate=\"no\"><strong>grant_type<\/strong><\/span><\/td>\n<td>Set to <span translate=\"no\"><strong>authorization_code<\/strong><\/span>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ol>\n<p>Refer to the WeChat <a href=\"https:\/\/developers.weixin.qq.com\/miniprogram\/en\/dev\/framework\/open-ability\/login.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Mini Program Login<\/a> documentation for a detailed flow.<\/p>\n<h2>Step 3: Make a payment request<\/h2>\n<ol>\n<li>\n<p>Use the WeChat function <span translate=\"no\"><strong>wx.request()<\/strong><\/span> to make a request to your server.<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"'Example of a payments request to your server'\" :id=\"''\" :code-data=\"[{&quot;language&quot;:&quot;JavaScript&quot;,&quot;tabTitle&quot;:&quot;&quot;,&quot;content&quot;:&quot;\\\/\\\/ Make a payment request to your server\\n\\nwx.request({\\n   url: '{YOUR_SERVER_URL_TO_MAKE_PAYMENTS}',\\n   method: 'POST',\\n   header: {\\n      \\&quot;content-type\\&quot;: \\&quot;application\\\/json\\&quot;,\\n   },\\n   data: {\\n\\n      \\\/\\\/ Mandatory fields\\n      paymentMethod: {\\n         type: \\&quot;wechatpayMiniProgram\\&quot;,\\n         openid: \\&quot;{OPEN_ID_OBTAINED_IN_STEP_2}\\&quot;\\n      },\\n\\n      \\\/\\\/ Optional fields that may be assigned at server\\n      reference: \\&quot;{YOUR_ORDER_NUMBER}\\&quot;,\\n      amount: {\\n         currency: \\&quot;CNY\\&quot;,\\n         value: 1000\\n      }\\n\\n   },\\n   \\\/\\\/ Get payment response in \\&quot;res.data\\&quot;\\n   success(res) {\\n\\n      \\\/\\\/ Store paymentData to be used in 'Step 4 - chech payment result'\\n      const encryptedPaymentData = res.data.paymentData;\\n\\n      \\\/\\\/ Handle redirect to make payment with WeChat Pay\\n      const payload = res.data.redirect.data;\\n      wx.requestPayment({\\n         ...payload,\\n\\n         \\\/\\\/ Refer to 'Step 4 - check payment result', for complete code\\n         complete(res) {\\n            ...\\n         }\\n      })\\n   }\\n});&quot;}]\" :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<\/li>\n<li>\n<p>Make a  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments<\/a> request.<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"'Example \/payments request'\" :id=\"'example-payments-request-6690925811'\" :code-data=\"[{&quot;language&quot;:&quot;bash&quot;,&quot;tabTitle&quot;:&quot;&quot;,&quot;content&quot;:&quot;curl https:\\\/\\\/[ACCOUNT-PREFIX]-checkout-live.adyenpayments.com\\\/checkout\\\/v72\\\/payments \\\\\\n-H 'x-api-key: ADYEN_API_KEY' \\\\\\n-H 'content-type: application\\\/json' \\\\\\n-d '{\\n    \\&quot;merchantAccount\\&quot;: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n    \\&quot;reference\\&quot;: \\&quot;JEP22U_698826xxxxx\\&quot;,\\n    \\&quot;countryCode\\&quot;: \\&quot;CN\\&quot;,\\n    \\&quot;amount\\&quot;: {\\n        \\&quot;currency\\&quot;: \\&quot;CNY\\&quot;,\\n        \\&quot;value\\&quot;: 1000\\n    },\\n    \\&quot;paymentMethod\\&quot;:{\\n        \\&quot;type\\&quot;: \\&quot;wechatpayMiniProgram\\&quot;,\\n        \\&quot;openid\\&quot;: \\&quot;{OPEN_ID_OBTAINED_IN_STEP_2}\\&quot;\\n    }\\n}'&quot;}]\" :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<p>When the  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments<\/a> request is received by Adyen, a POST request is automatically sent from Adyen to the WeChat Server to place the order and to get the <code>prepay_id<\/code>, which is required to execute <span translate=\"no\"><strong>wx.requestPayment()<\/strong><\/span> and to trigger the payment on WeChat.<\/p>\n<p>The value for <code>prepay_id<\/code> is returned as part of the  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments<\/a> response, and is contained in <code>redirect.data.package<\/code>.<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"'Example \/payments response'\" :id=\"''\" :code-data='[{\"language\":\"JavaScript\",\"tabTitle\":\"\",\"content\":\"{\\n   \\\"resultCode\\\": \\\"Pending\\\",\\n   \\\"action\\\": {\\n      \\\"paymentData\\\": \\\"Ab02b4c0!...\\\",\\n      \\\"paymentMethodType\\\": \\\"wechatpayMiniProgram\\\",\\n      \\\"type\\\": \\\"qrCode\\\"\\n   },\\n   \\\"details\\\": [{\\n      \\\"key\\\": \\\"resultCode\\\",\\n      \\\"type\\\": \\\"text\\\"\\n   }],\\n   \\\"paymentData\\\": \\\"Ab02b4c0!...\\\",\\n   \\\"redirect\\\": {\\n      \\\"data\\\": {\\n         \\\"timeStamp\\\": \\\"{TIMESTAMP}\\\",\\n         \\\"package\\\": \\\"prepay_id={PREPAY_ID_FROM_WECHAT}\\\",\\n         \\\"paySign\\\": \\\"{SIGNATURE_GENERATED_USING_THESE_FIELDS}\\\",\\n         \\\"appId\\\": \\\"{APP_ID}\\\",\\n         \\\"signType\\\": \\\"MD5\\\",\\n         \\\"nonceStr\\\": \\\"{NONCE_STRING}\\\"\\n      }\\n   }\\n}\"}]' :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<\/li>\n<\/ol>\n<p><br\/><\/p>\n<ol start=\"3\">\n<li>Use the WeChat function <span translate=\"no\"><strong>wx.requestPayment()<\/strong><\/span> to handle the redirect received in the  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments<\/a> response.<\/li>\n<\/ol>\n<h2>Step 4: Check the payment result<\/h2>\n<p>When the shopper completes the payment:<\/p>\n<ol>\n<li>\n<p>Use <span translate=\"no\"><strong>wx.request()<\/strong><\/span> (also used in step 3) to check the payment result.<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"'Example of a payments request to your server'\" :id=\"''\" :code-data=\"[{&quot;language&quot;:&quot;JavaScript&quot;,&quot;tabTitle&quot;:&quot;&quot;,&quot;content&quot;:&quot;complete(res) {\\n   \\\/\\\/ Make a payment result check to your server\\n   wx.request({\\n      url: '{YOUR_SERVER_URL_TO_PERFORM_PAYMENTS_DETAILS}',\\n      method: 'POST',\\n      header: {\\n         \\&quot;content-type\\&quot;: \\&quot;application\\\/json\\&quot;,\\n      },\\n      data: {\\n         \\\/\\\/ Mandatory fields\\n         paymentData: encryptedPaymentData,\\n         details: {\\n            paymentStatus: res.errMsg\\n         }\\n      }\\n   });\\n}&quot;}]\" :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<\/li>\n<li>\n<p>Make a  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\/details\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments\/details<\/a> request.<\/p>\n<p>The value for <code>paymentStatus<\/code> is returned in <code>res.errMsg<\/code> and is one of these:<\/p>\n<ul>\n<li>requestPayment:ok<\/li>\n<li>requestPayment:fail cancel<\/li>\n<li>requestPayment:fail (detail message)<\/li>\n<\/ul>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"'Example \/payments\/details request'\" :id=\"''\" :code-data=\"[{&quot;language&quot;:&quot;Unset&quot;,&quot;tabTitle&quot;:&quot;&quot;,&quot;content&quot;:&quot;curl https:\\\/\\\/[ACCOUNT-PREFIX]-checkout-live.adyenpayments.com\\\/checkout\\\/v72\\\/payments \\\\\\n-H 'x-api-key: ADYEN_API_KEY' \\\\\\n-H 'content-type: application\\\/json' \\\\\\n-d '{\\n\\t\\&quot;paymentData\\&quot;: \\&quot;Ab02b4c0!...\\&quot;\\n    \\&quot;details\\&quot; : {\\n        \\&quot;paymentStatus\\&quot; : \\&quot;requestPayment:ok\\&quot;\\n    }\\n}'&quot;}]\" :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<p>Receive the  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\/details\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments\/details<\/a> response.<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"'Example \/payments\/details response'\" :id=\"''\" :code-data='[{\"language\":\"Unset\",\"tabTitle\":\"\",\"content\":\"{\\n    \\\"additionalData\\\" : {\\n        \\\"acquirerResponseCode\\\" : \\\"*************\\\",\\n        \\\"wechatpay.openid\\\" : \\\"*************\\\"\\n    },\\n    \\\"pspReference\\\" : \\\"PPKFQ89R6QRXGN82\\\",\\n    \\\"resultCode\\\" : \\\"Authorised\\\",\\n    \\\"amount\\\" : {\\n        \\\"currency\\\" : \\\"CNY\\\",\\n        \\\"value\\\" : 1000\\n    },\\n    \\\"merchantReference\\\" : \\\"LEDVRK_62471\\\"\\n}\"}]' :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<\/li>\n<\/ol>\n<h2>Step 5: Show the payment result<\/h2>\n<p>Use the <code>resultCode<\/code> that you received in the  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/payments\/details\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/payments\/details<\/a> response to present the payment result to your shopper.<\/p>\n<p> <\/p>\n<p>The <code>resultCode<\/code> values you can receive for WeChat Pay are:<\/p>\n<p> <\/p>\n<table>\n<thead>\n<tr>\n<th>resultCode<\/th>\n<th>Description<\/th>\n<th>Action to take<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>Authorised<\/strong><\/td>\n<td>The payment was successful.<\/td>\n<td>Inform the shopper that the payment has been successful. <br> You will receive the funds in 2-3 days.<\/td>\n<\/tr>\n<tr>\n<td><strong>Error<\/strong><\/td>\n<td>There was an error when the payment was being processed.<\/td>\n<td>Inform the shopper that there was an error processing their payment. The response contains a <code>refusalReason<\/code>, indicating the cause of the error.<\/td>\n<\/tr>\n<tr>\n<td><strong>Pending<\/strong> or <br> <strong>Received<\/strong><\/td>\n<td>The payment order was successfully received.<\/td>\n<td>Inform the shopper that you have received their order, and are waiting for the payment to clear. <br> You will receive the final result of the payment in an <a href=\"\/pt\/development-resources\/webhooks\/webhook-types\">AUTHORISATION webhook<\/a>. If successful, you will receive the funds in 2 days.<\/td>\n<\/tr>\n<tr>\n<td><strong>Refused<\/strong><\/td>\n<td>The payment was refused by the shopper's bank.<\/td>\n<td>Ask the shopper to try the payment again using a different payment method.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Test and go live<\/h2>\n<p>WeChat Pay does not have a test platform. If you have a personal WeChat account, test the following scenarios:<\/p>\n<ul>\n<li>Cancel the transaction when you are asked to verify the payment (recommended).<\/li>\n<li>Make a live WeChat Pay payment with a low value.<\/li>\n<\/ul>\n<p>Check the status of a WeChat Pay payment in your <strong>Customer Area<\/strong> &gt; <strong>Transactions<\/strong> &gt; <strong>Payments<\/strong>.<\/p>\n<h2 id=\"see-also\">See also<\/h2>\n<div class=\"see-also-links output-inline\" id=\"see-also\">\n<ul><li><a href=\"https:\/\/developers.weixin.qq.com\/miniprogram\/en\/dev\/framework\/quickstart\/\"\n                        target=\"_blank\"\n                         class=\"external\">\n                    About Mini Programs\n                <\/a><\/li><li><a href=\"\/online-payments\/build-your-integration\/advanced-flow?platform=Web&amp;integration=API%20only\"\n                        target=\"_self\"\n                        >\n                    API only integration guide\n                <\/a><\/li><li><a href=\"\/development-resources\/webhooks\"\n                        target=\"_self\"\n                        >\n                    Webhooks\n                <\/a><\/li><li><a href=\"https:\/\/docs.adyen.com\/api-explorer\/#\/CheckoutService\/latest\/overview\"\n                        target=\"_blank\"\n                         class=\"external\">\n                    API Explorer\n                <\/a><\/li><\/ul><\/div>\n","url":"https:\/\/docs.adyen.com\/pt\/payment-methods\/wechat-pay\/wechat-pay-mini-program\/api-only","articleFields":{"description":"How to offer WeChat Pay through WeChat Mini Program with an API-only integration.","parameters":{"payment_method":"WeChat Pay Mini Program","country_code":"CN","currency":"CNY","payment_method_type":"wechatpayMiniProgram","return_url":"https:\/\/your-company.example.com\/checkout?shopperOrder=12xy..","channel":"Web","integration":"API-only","platform":"Web"}},"algolia":{"url":"https:\/\/docs.adyen.com\/pt\/payment-methods\/wechat-pay\/wechat-pay-mini-program\/api-only","title":"Mini Program for API-only","content":"Make WeChat Pay available to your shopper on WeChat Mini Program with an API only integration.\nRequirements\n\n\n\nRequirement\nDescription\n\n\n\n\nIntegration type\nMake sure that you have built an API-only integration. \n\n\nSetup steps\nBefore you begin, add WeChat Pay Mini Program in your test Customer Area.\n\n\n\nPreparation\nBefore you can accept WeChat Pay payments in your Mini Program:\n\nCreate a Mini Program account with WeChat.\n\nContact our Support Team or your implementation manager and provide your:\n\nMini Program AppID\nEntity name\nCurrency\n\nThese details are required to ensure that payments made with your Mini Program are settled to your Adyen account.\n\n\nOverview of payment flow\nThe diagram shows the flow of a Mini Program payment.\nCnNlcXVlbmNlRGlhZ3JhbQpwYXJ0aWNpcGFudCBXZUNoYXQgTWluaSBQcm9ncmFtCnBhcnRpY2lwYW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ncmFtOiBIYW5kbGUgcmVkaXJlY3QKICAgIG5vdGUgb3ZlciBXZUNoYXQgTWluaSBQcm9ncmFtOiBTaG93IHBheW1lbnQgcmVzdWx0CgogICAgQWR5ZW4tPj5NZXJjaGFudCBTZXJ2ZXI6IFdlYmhvb2sgYXV0aG9yaXNhdGlvbiBtZXNzYWdlIChhc3luY2hyb25vdXMpCgo=\nFollow the steps below to enable Mini Program payments.\n\nMake all calls to Adyen from your server, not from your Mini Program.\n\nStep 1: Allow Adyen domains\nAllow-list the following domains in your Mini Program settings:\n\nhttps:\/\/[YOUR_MERCHANT_PREFIX]-checkout-live.adyenpayments.com\n\nFind your merchant prefix in the Customer Area, by selecting Developers &gt; API URLs. Select the data center closest to your server.\nStep 2: Get the user's openid\n\nUse wx.login() to get jsCode in the success callback.\n\nUse wx.request() to make the following call that returns the user's openid in the response:\nhttps:\/\/api.weixin.qq.com\/sns\/jscode2session?appid=${appId}&amp;secret=${secret}&amp;js_code=${jsCode}&amp;grant_type=authorization_code\n\n\n\nParameter\nDescription\n\n\n\n\nappID\nAvailable in your Mini Program Account.\n\n\nsecret\nAvailable in your Mini Program Account.\n\n\njsCode\nObtained during the wx.login() call.\n\n\ngrant_type\nSet to authorization_code.\n\n\n\n\n\nRefer to the WeChat Mini Program Login documentation for a detailed flow.\nStep 3: Make a payment request\n\n\nUse the WeChat function wx.request() to make a request to your server.\n\n\n\n\n\nMake a  \/payments request.\n\n\n\nWhen the  \/payments request is received by Adyen, a POST request is automatically sent from Adyen to the WeChat Server to place the order and to get the prepay_id, which is required to execute wx.requestPayment() and to trigger the payment on WeChat.\nThe value for prepay_id is returned as part of the  \/payments response, and is contained in redirect.data.package.\n\n\n\n\n\n\n\nUse the WeChat function wx.requestPayment() to handle the redirect received in the  \/payments response.\n\nStep 4: Check the payment result\nWhen the shopper completes the payment:\n\n\nUse wx.request() (also used in step 3) to check the payment result.\n\n\n\n\n\nMake a  \/payments\/details request.\nThe value for paymentStatus is returned in res.errMsg and is one of these:\n\nrequestPayment:ok\nrequestPayment:fail cancel\nrequestPayment:fail (detail message)\n\n\n\n\nReceive the  \/payments\/details response.\n\n\n\n\n\nStep 5: Show the payment result\nUse the resultCode that you received in the  \/payments\/details response to present the payment result to your shopper.\n \nThe resultCode values you can receive for WeChat Pay are:\n \n\n\n\nresultCode\nDescription\nAction to take\n\n\n\n\nAuthorised\nThe payment was successful.\nInform the shopper that the payment has been successful.  You will receive the funds in 2-3 days.\n\n\nError\nThere was an error when the payment was being processed.\nInform the shopper that there was an error processing their payment. The response contains a refusalReason, indicating the cause of the error.\n\n\nPending or  Received\nThe payment order was successfully received.\nInform the shopper that you have received their order, and are waiting for the payment to clear.  You will receive the final result of the payment in an AUTHORISATION webhook. If successful, you will receive the funds in 2 days.\n\n\nRefused\nThe payment was refused by the shopper's bank.\nAsk the shopper to try the payment again using a different payment method.\n\n\n\nTest and go live\nWeChat Pay does not have a test platform. If you have a personal WeChat account, test the following scenarios:\n\nCancel the transaction when you are asked to verify the payment (recommended).\nMake a live WeChat Pay payment with a low value.\n\nCheck the status of a WeChat Pay payment in your Customer Area &gt; Transactions &gt; Payments.\nSee also\n\n\n                    About Mini Programs\n                \n                    API only integration guide\n                \n                    Webhooks\n                \n                    API Explorer\n                \n","type":"page","locale":"pt","boost":16,"hierarchy":{"lvl0":"Home","lvl1":"Payment methods","lvl2":"WeChat Pay","lvl3":"WeChat Pay Mini Program","lvl4":"Mini Program for API-only"},"hierarchy_url":{"lvl0":"https:\/\/docs.adyen.com\/pt","lvl1":"https:\/\/docs.adyen.com\/pt\/payment-methods","lvl2":"https:\/\/docs.adyen.com\/pt\/payment-methods\/wechat-pay","lvl3":"https:\/\/docs.adyen.com\/pt\/payment-methods\/wechat-pay\/wechat-pay-mini-program","lvl4":"\/pt\/payment-methods\/wechat-pay\/wechat-pay-mini-program\/api-only"},"levels":5,"category":"Payment method","category_color":"green","tags":["Program","API-only"]}}
