{"title":"WeChat Pay Component","category":"default","creationDate":1776961628,"content":"<p>This page explains how to add  to your existing Android Components integration.<\/p>\n<div class=\"sc-notice info\"><div>\n<p><strong>If you are using Android Components v5.0.0 or later:<\/strong><\/p>\n<p>This payment method requires no additional configuration.<\/p>\n<p>Follow the  <a href=\"\/pt\/online-payments\/build-your-integration\/sessions-flow?platform=Android&amp;integration=Components\">Components integration guide<\/a> and use the following module and Component names:<\/p>\n<ul>\n<li>To <a href=\"\/pt\/online-payments\/build-your-integration\/sessions-flow\/?platform=Android&amp;integration=Components#import\">import the module<\/a>: <strong>instant<\/strong><\/li>\n<li>To <a href=\"\/pt\/online-payments\/build-your-integration\/sessions-flow?platform=Android&amp;integration=Components#launch-and-show\">launch and show the Component<\/a>: <strong>InstantPaymentComponent<\/strong><\/li>\n<\/ul>\n<\/div><\/div>\n<div class=\"sc-notice info\"><div>\n<p>WeChat Pay is supported from Android Components version 3.5.0 and later. For more information, see <a href=\"\/pt\/online-payments\/release-notes\">release notes<\/a>.<\/p>\n<\/div><\/div>\n<p>Our WeChat Pay Component triggers the app switch from your app to the WeChat app on the shopper's device.<\/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 Advanced flow <a href=\"\/pt\/online-payments\/build-your-integration\/advanced-flow\/?platform=Android&amp;integration=Components\">Android Components 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  in your Customer Area<\/a>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Preparation<\/h2>\n<ol>\n<li><a href=\"\/pt\/payment-methods\/wechat-pay\/wechat-pay-in-app-payments\/enable-wechat-pay#create-developer-account\">Create a developer account<\/a> on the WeChat Open Platform.<\/li>\n<li><a href=\"\/pt\/payment-methods\/wechat-pay\/wechat-pay-in-app-payments\/enable-wechat-pay#register-mobile-app\">Register your mobile app<\/a> with WeChat.<\/li>\n<\/ol>\n<h2>Start a payment with WeChat Pay<\/h2>\n<p>To start a payment with WeChat Pay, you need to:<\/p>\n<ol>\n<li>\n<p>Specify in your  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/paymentMethods\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/paymentMethods<\/a> request:<\/p>\n<ul>\n<li> <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/paymentMethods\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">countryCode<\/a>&#58; Any supported country\/region. For example, <span translate=\"no\"><strong>CN<\/strong><\/span>.<\/li>\n<li> <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/paymentMethods#request-amount\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">amount.currency<\/a>&#58; Any supported currency. For example, <span translate=\"no\"><strong>CNY<\/strong><\/span>.<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>Deserialize the response from the  <a href=\"https:\/\/docs.adyen.com\/api-explorer\/Checkout\/latest\/post\/paymentMethods\" class=\"codeLabel  external-link no-image\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\/paymentMethods<\/a> call and get the object with <code>type<\/code>: <span translate=\"no\"><strong>wechatpaySDK<\/strong><\/span>.<\/p>\n<\/li>\n<li>\n<p>Add the WeChat Pay module:<\/p>\n<p>a. Import the WeChat Pay module to your <code>build.gradle<\/code> file.<\/p>\n<pre><code class=\"language-groovy\">implementation \"com.adyen.checkout:wechatpay:&lt;latest-version&gt;\"<\/code><\/pre>\n<p>Check the <a href=\"https:\/\/github.com\/Adyen\/adyen-android\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">latest version on GitHub<\/a>.<\/p>\n<p>b.  Check if WeChat is available on the shopper's device.<\/p>\n<pre><code class=\"language-kotlin\">   \/\/ WeChatPayProvider is not an actual provider, it only checks whether WeChat Pay is available.\n   val weChatPayProvider = WeChatPayProvider()\n   weChatPayProvider.isAvailable(application, paymentMethod, null) { isAvailable: Boolean, paymentMethod: PaymentMethod, _ -&gt;\n       if (isAvailable) {\n           \/\/ show WeChat pay as a payment option in your app\n       }\n   }<\/code><\/pre>\n<p>c. If WeChat is available and the shopper chooses to pay with WeChat Pay, 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 from your server.<\/p>\n<\/li>\n<\/ol>\n<h2>Make a payment<\/h2>\n<ol>\n<li>\n<p>From your server, 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=\"''\" :id=\"'wechat-payments-request-api'\" :code-data=\"[{&quot;language&quot;:&quot;bash&quot;,&quot;tabTitle&quot;:&quot;curl&quot;,&quot;content&quot;:&quot;curl https:\\\/\\\/checkout-test.adyen.com\\\/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;YOUR_ORDER_NUMBER\\&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;wechatpaySDK\\&quot;\\n  },\\n  \\&quot;returnUrl\\&quot;:\\&quot;https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..\\&quot;\\n}'&quot;},{&quot;language&quot;:&quot;java&quot;,&quot;tabTitle&quot;:&quot;Java&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Java API Library v27.0.0\\nimport com.adyen.Client;\\nimport com.adyen.enums.Environment;\\nimport com.adyen.model.checkout.*;\\nimport java.time.OffsetDateTime;\\nimport java.util.*;\\nimport com.adyen.model.RequestOptions;\\nimport com.adyen.service.checkout.*;\\n\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nClient client = new Client(\\&quot;ADYEN_API_KEY\\&quot;, Environment.TEST);\\n\\n\\\/\\\/ Create the request object(s)\\nAmount amount = new Amount()\\n  .currency(\\&quot;CNY\\&quot;)\\n  .value(1000L);\\n\\nPaymentDetails paymentDetails = new PaymentDetails()\\n  .type(PaymentDetails.TypeEnum.WECHATPAYSDK);\\n\\nPaymentRequest paymentRequest = new PaymentRequest()\\n  .reference(\\&quot;YOUR_ORDER_NUMBER\\&quot;)\\n  .amount(amount)\\n  .merchantAccount(\\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;)\\n  .paymentMethod(new CheckoutPaymentMethod(paymentDetails))\\n  .returnUrl(\\&quot;https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..\\&quot;);\\n\\n\\\/\\\/ Send the request\\nPaymentsApi service = new PaymentsApi(client);\\nPaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey(\\&quot;UUID\\&quot;));&quot;},{&quot;language&quot;:&quot;php&quot;,&quot;tabTitle&quot;:&quot;PHP&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen PHP API Library v19.0.0\\nuse Adyen\\\\Client;\\nuse Adyen\\\\Environment;\\nuse Adyen\\\\Model\\\\Checkout\\\\Amount;\\nuse Adyen\\\\Model\\\\Checkout\\\\CheckoutPaymentMethod;\\nuse Adyen\\\\Model\\\\Checkout\\\\PaymentRequest;\\nuse Adyen\\\\Service\\\\Checkout\\\\PaymentsApi;\\n\\n$client = new Client();\\n$client-&gt;setXApiKey(\\&quot;ADYEN_API_KEY\\&quot;);\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\n$client-&gt;setEnvironment(Environment::TEST);\\n\\n\\n\\\/\\\/ Create the request object(s)\\n$amount = new Amount();\\n$amount\\n  -&gt;setCurrency(\\&quot;CNY\\&quot;)\\n  -&gt;setValue(1000);\\n\\n$checkoutPaymentMethod = new CheckoutPaymentMethod();\\n$checkoutPaymentMethod\\n  -&gt;setType(\\&quot;wechatpaySDK\\&quot;);\\n\\n$paymentRequest = new PaymentRequest();\\n$paymentRequest\\n  -&gt;setReference(\\&quot;YOUR_ORDER_NUMBER\\&quot;)\\n  -&gt;setAmount($amount)\\n  -&gt;setMerchantAccount(\\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;)\\n  -&gt;setPaymentMethod($checkoutPaymentMethod)\\n  -&gt;setReturnUrl(\\&quot;https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..\\&quot;);\\n\\n$requestOptions['idempotencyKey'] = 'UUID';\\n\\n\\\/\\\/ Send the request\\n$service = new PaymentsApi($client);\\n$response = $service-&gt;payments($paymentRequest, $requestOptions);&quot;},{&quot;language&quot;:&quot;cs&quot;,&quot;tabTitle&quot;:&quot;C#&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen .net API Library v17.0.0\\nusing Adyen;\\nusing Environment = Adyen.Model.Environment;\\nusing Adyen.Model;\\nusing Adyen.Model.Checkout;\\nusing Adyen.Service.Checkout;\\n\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nvar config = new Config()\\n{\\n    XApiKey = \\&quot;ADYEN_API_KEY\\&quot;,\\n    Environment = Environment.Test\\n};\\nvar client = new Client(config);\\n\\n\\\/\\\/ Create the request object(s)\\nAmount amount = new Amount\\n{\\n  Currency = \\&quot;CNY\\&quot;,\\n  Value = 1000\\n};\\n\\nPaymentDetails paymentDetails = new PaymentDetails\\n{\\n  Type = PaymentDetails.TypeEnum.WechatpaySDK\\n};\\n\\nPaymentRequest paymentRequest = new PaymentRequest\\n{\\n  Reference = \\&quot;YOUR_ORDER_NUMBER\\&quot;,\\n  Amount = amount,\\n  MerchantAccount = \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  PaymentMethod = new CheckoutPaymentMethod(paymentDetails),\\n  ReturnUrl = \\&quot;https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..\\&quot;\\n};\\n\\n\\\/\\\/ Send the request\\nvar service = new PaymentsService(client);\\nvar response = service.Payments(paymentRequest, requestOptions: new RequestOptions { IdempotencyKey = \\&quot;UUID\\&quot;});&quot;},{&quot;language&quot;:&quot;js&quot;,&quot;tabTitle&quot;:&quot;NodeJS (JavaScript)&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Node API Library v18.0.0\\n\\\/\\\/ Require the parts of the module you want to use\\nconst { Client, CheckoutAPI } = require('@adyen\\\/api-library');\\n\\\/\\\/ Initialize the client object\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nconst client = new Client({apiKey: \\&quot;ADYEN_API_KEY\\&quot;, environment: \\&quot;TEST\\&quot;});\\n\\n\\\/\\\/ Create the request object(s)\\nconst paymentRequest = {\\n  merchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  reference: \\&quot;YOUR_ORDER_NUMBER\\&quot;,\\n  amount: {\\n    currency: \\&quot;CNY\\&quot;,\\n    value: 1000\\n  },\\n  paymentMethod: {\\n    type: \\&quot;wechatpaySDK\\&quot;\\n  },\\n  returnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..\\&quot;\\n}\\n\\n\\\/\\\/ Send the request\\nconst checkoutAPI = new CheckoutAPI(client);\\nconst response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: \\&quot;UUID\\&quot; });&quot;},{&quot;language&quot;:&quot;go&quot;,&quot;tabTitle&quot;:&quot;Go&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Go API Library v10.4.0\\nimport (\\n  \\&quot;context\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/common\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/adyen\\&quot;\\n  \\&quot;github.com\\\/adyen\\\/adyen-go-api-library\\\/v9\\\/src\\\/checkout\\&quot;\\n)\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nclient := adyen.NewClient(&amp;common.Config{\\n  ApiKey:      \\&quot;ADYEN_API_KEY\\&quot;,\\n  Environment: common.TestEnv,\\n})\\n\\n\\\/\\\/ Create the request object(s)\\namount := checkout.Amount{\\n  Currency: \\&quot;CNY\\&quot;,\\n  Value: 1000,\\n}\\n\\npaymentDetails := checkout.PaymentDetails{\\n  Type: common.PtrString(\\&quot;wechatpaySDK\\&quot;),\\n}\\n\\npaymentRequest := checkout.PaymentRequest{\\n  Reference: \\&quot;YOUR_ORDER_NUMBER\\&quot;,\\n  Amount: amount,\\n  MerchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  PaymentMethod: checkout.PaymentDetailsAsCheckoutPaymentMethod(&amp;paymentDetails),\\n  ReturnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..\\&quot;,\\n}\\n\\n\\\/\\\/ Send the request\\nservice := client.Checkout()\\nreq := service.PaymentsApi.PaymentsInput().IdempotencyKey(\\&quot;UUID\\&quot;).PaymentRequest(paymentRequest)\\nres, httpRes, err := service.PaymentsApi.Payments(context.Background(), req)&quot;},{&quot;language&quot;:&quot;py&quot;,&quot;tabTitle&quot;:&quot;Python&quot;,&quot;content&quot;:&quot;# Adyen Python API Library v12.5.1\\nimport Adyen\\n\\nadyen = Adyen.Adyen()\\nadyen.client.xapikey = \\&quot;ADYEN_API_KEY\\&quot;\\n# For the live environment, additionally include your liveEndpointUrlPrefix.\\nadyen.client.platform = \\&quot;test\\&quot; # The environment to use library in.\\n\\n# Create the request object(s)\\njson_request = {\\n  \\&quot;merchantAccount\\&quot;: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  \\&quot;reference\\&quot;: \\&quot;YOUR_ORDER_NUMBER\\&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;wechatpaySDK\\&quot;\\n  },\\n  \\&quot;returnUrl\\&quot;: \\&quot;https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..\\&quot;\\n}\\n\\n# Send the request\\nresult = adyen.checkout.payments_api.payments(request=json_request, idempotency_key=\\&quot;UUID\\&quot;)&quot;},{&quot;language&quot;:&quot;rb&quot;,&quot;tabTitle&quot;:&quot;Ruby&quot;,&quot;content&quot;:&quot;# Adyen Ruby API Library v9.5.1\\nrequire \\&quot;adyen-ruby-api-library\\&quot;\\n\\nadyen = Adyen::Client.new\\nadyen.api_key = 'ADYEN_API_KEY'\\n# For the live environment, additionally include your liveEndpointUrlPrefix.\\nadyen.env = :test # Set to \\&quot;live\\&quot; for live environment\\n\\n# Create the request object(s)\\nrequest_body = {\\n  :merchantAccount =&gt; 'ADYEN_MERCHANT_ACCOUNT',\\n  :reference =&gt; 'YOUR_ORDER_NUMBER',\\n  :amount =&gt; {\\n    :currency =&gt; 'CNY',\\n    :value =&gt; 1000\\n  },\\n  :paymentMethod =&gt; {\\n    :type =&gt; 'wechatpaySDK'\\n  },\\n  :returnUrl =&gt; 'https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..'\\n}\\n\\n# Send the request\\nresult = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' =&gt; 'UUID' })&quot;},{&quot;language&quot;:&quot;ts&quot;,&quot;tabTitle&quot;:&quot;NodeJS (TypeScript)&quot;,&quot;content&quot;:&quot;\\\/\\\/ Adyen Node API Library v18.0.0\\n\\\/\\\/ Require the parts of the module you want to use\\nimport { Client, CheckoutAPI, Types } from \\&quot;@adyen\\\/api-library\\&quot;;\\n\\\/\\\/ Initialize the client object\\n\\\/\\\/ For the live environment, additionally include your liveEndpointUrlPrefix.\\nconst client = new Client({apiKey: \\&quot;ADYEN_API_KEY\\&quot;, environment: \\&quot;TEST\\&quot;});\\n\\n\\\/\\\/ Create the request object(s)\\nconst amount: Types.checkout.Amount = {\\n  currency: \\&quot;CNY\\&quot;,\\n  value: 1000\\n};\\n\\nconst paymentDetails: Types.checkout.PaymentDetails = {\\n  type: Types.checkout.PaymentDetails.TypeEnum.WechatpaySDK\\n};\\n\\nconst paymentRequest: Types.checkout.PaymentRequest = {\\n  reference: \\&quot;YOUR_ORDER_NUMBER\\&quot;,\\n  amount: amount,\\n  merchantAccount: \\&quot;ADYEN_MERCHANT_ACCOUNT\\&quot;,\\n  paymentMethod: paymentDetails,\\n  returnUrl: \\&quot;https:\\\/\\\/your-company.example.com\\\/checkout?shopperOrder=12xy..\\&quot;\\n};\\n\\n\\\/\\\/ Send the request\\nconst checkoutAPI = new CheckoutAPI(client);\\nconst response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: \\&quot;UUID\\&quot; });&quot;}]\" :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<p>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 includes an <code>action<\/code> object that contains information about the app switch.<\/p>\n<\/li>\n<li>\n<p>Pass the <code>action<\/code> object to your client app.<\/p>\n<div data-component-wrapper=\"code-sample\">\n<code-sample :title=\"'\/payments response'\" :id=\"''\" :code-data='[{\"language\":\"json\",\"tabTitle\":\"\",\"content\":\"{\\n    \\\"resultCode\\\": \\\"Pending\\\",\\n    \\\"action\\\": {\\n        \\\"paymentMethodType\\\": \\\"wechatpaySDK\\\",\\n        \\\"type\\\": \\\"sdk\\\",\\n        \\\"sdkData\\\": {\\n            \\\"appid\\\": \\\"wx3aed7fe146f6a57a\\\",\\n            \\\"noncestr\\\": \\\"cPY0e83ny4hWyf5O\\\",\\n            \\\"packageValue\\\": \\\"Sign=WXPay\\\",\\n            \\\"partnerid\\\": \\\"205287714\\\",\\n            \\\"prepayid\\\": \\\"wx015678064827111da2e4f0b11005864100\\\",\\n            \\\"sign\\\": \\\"169FD3F1E193446D90C45573EBDD4020\\\",\\n            \\\"timestamp\\\": \\\"1573033086\\\"\\n        }\\n    },\\n    \\\"details\\\": [\\n        {\\n            \\\"key\\\": \\\"resultCode\\\",\\n            \\\"type\\\": \\\"text\\\"\\n        }\\n    ],\\n    ...\\n}\"}]' :enable-copy-link-to-code-block=\"true\" :code-sample-card-size=\"'fullsize'\"><\/code-sample>\n<\/div>\n<\/li>\n<\/ol>\n<h2>Handle the app switch<\/h2>\n<ol>\n<li>\n<p>To switch the shopper to the WeChat app, initialize the WeChat Pay Action Component, and pass the <code>action<\/code> object.<\/p>\n<pre><code class=\"language-kotlin\">  val weChatPayActionConfiguration = WeChatPayActionConfiguration.Builder(this, \"YOUR_CLIENT_KEY\")\n      \/\/ When you are ready to accept live payments, change the value to one of our live environments.\n      .setEnvironment(Environment.TEST)\n      .build()\n\n  val weChatPayActionComponent = WeChatPayActionComponent.PROVIDER.get(this, application, weChatPayActionConfiguration)\n  weChatPayActionComponent.handleAction(this@YourActivity, action)<\/code><\/pre>\n<p>After the shopper has completed the payment, the WeChat app redirects them back to your app, and provides an <code>Intent<\/code> object containing the result of the payment.<\/p>\n<\/li>\n<li>\n<p>Get the result of the WeChat Pay SDK from the <code>Activity<\/code>. Pass the <code>intent<\/code> back to the WeChat Pay Action Component. Depending on your activity's <a href=\"https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#lmode\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">launchMode<\/a>, you can get this intent in either <code>onCreate<\/code> or <code>onNewIntent<\/code>.<\/p>\n<pre><code class=\"language-kotlin\">private fun handleIntent(intent: Intent) {\n    if (WeChatPayUtils.isResultIntent(intent)) {\n        weChatPayActionComponent.handleIntent(intent)\n    }\n}<\/code><\/pre>\n<p>The Component notifies the <code>observer<\/code> with the <code>actionComponentData<\/code>.<\/p>\n<\/li>\n<li>\n<p>Pass the <code>actionComponentData<\/code> to your server.<\/p>\n<pre><code class=\"language-kotlin\">wechatPayActionComponent.observe(this) { actionComponentData -&gt;\n  \/\/ Send a \/payments\/details\/ call containing the `actionComponentData`\n  sendPaymentDetails(actionComponentData)\n}<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2>Check the payment result<\/h2>\n<p>When the shopper returns to your app, the Component provides the <code>actionComponentData<\/code>.<\/p>\n<ol>\n<li>Pass the <code>actionComponentData<\/code> to your server.<\/li>\n<li>From your server, <a href=\"\/pt\/online-payments\/build-your-integration\/advanced-flow\/?platform=Android&amp;integration=Components#send-additional-payment-details\">make a <code>\/payments\/details<\/code> request<\/a> containing the <code>actionComponentData<\/code>.<\/li>\n<\/ol>\n<h2>Present 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 id=\"test-and-go-live\">Test and go live<\/h2>\n<p>WeChat Pay currently has no test platform. If you have a personal WeChat account you can test your integration by either:<\/p>\n<ul>\n<li>Canceling the transaction when you are asked to verify the payment (<strong>recommended<\/strong>).<\/li>\n<li>Making live WeChat Pay payments with a low value.\n<\/li>\n<\/ul>\n<p>You can check the status of a WeChat Pay payment in your\u00a0<a href=\"https:\/\/ca-live.adyen.com\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Customer Area<\/a>\u00a0&gt;\u00a0<strong>Transactions<\/strong>\u00a0&gt;\u00a0<strong>Payments<\/strong>.<\/p>\n<p><\/p>\n<p>Before you can accept live WeChat Pay payments, you need to submit a request for WeChat Pay in your <a href=\"https:\/\/ca-live.adyen.com\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">live Customer Area<\/a>.<\/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:\/\/open.weixin.qq.com\/\"\n                        target=\"_blank\"\n                         class=\"external\">\n                    WeChat Open Platform\n                <\/a><\/li><li><a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.tencent.mm\"\n                        target=\"_blank\"\n                         class=\"external\">\n                    WeChat for Android\n                <\/a><\/li><li><a href=\"\/online-payments\/build-your-integration\/sessions-flow?platform=Android&amp;integration=Components\"\n                        target=\"_self\"\n                        >\n                    Android Components 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-in-app-payments\/android-component","articleFields":{"description":"Add WeChat Pay to an existing Components integration.","id":"47481283","type":"page","_expandable":{"operations":""},"status":"current","last_edit_on":"04-07-2019 10:57","parameters":{"payment_method_type":"wechatpaySDK","return_url":"adyencheckout:\/\/your.package.name","currency":"CNY","country_code":"CN","shopper_locale":"en-GB","integration":"Components","platform":"Android","module_import":"instant","android_component":"InstantPaymentComponent"},"cache_enable":false},"algolia":{"url":"https:\/\/docs.adyen.com\/pt\/payment-methods\/wechat-pay\/wechat-pay-in-app-payments\/android-component","title":"WeChat Pay Component","content":"This page explains how to add  to your existing Android Components integration.\n\nIf you are using Android Components v5.0.0 or later:\nThis payment method requires no additional configuration.\nFollow the  Components integration guide and use the following module and Component names:\n\nTo import the module: instant\nTo launch and show the Component: InstantPaymentComponent\n\n\n\nWeChat Pay is supported from Android Components version 3.5.0 and later. For more information, see release notes.\n\nOur WeChat Pay Component triggers the app switch from your app to the WeChat app on the shopper's device.\nRequirements\n\n\n\nRequirement\nDescription\n\n\n\n\nIntegration type\nMake sure that you have built an Advanced flow Android Components integration. \n\n\nSetup steps\nBefore you begin, add  in your Customer Area.\n\n\n\nPreparation\n\nCreate a developer account on the WeChat Open Platform.\nRegister your mobile app with WeChat.\n\nStart a payment with WeChat Pay\nTo start a payment with WeChat Pay, you need to:\n\n\nSpecify in your  \/paymentMethods request:\n\n countryCode&#58; Any supported country\/region. For example, CN.\n amount.currency&#58; Any supported currency. For example, CNY.\n\n\n\nDeserialize the response from the  \/paymentMethods call and get the object with type: wechatpaySDK.\n\n\nAdd the WeChat Pay module:\na. Import the WeChat Pay module to your build.gradle file.\nimplementation \"com.adyen.checkout:wechatpay:&lt;latest-version&gt;\"\nCheck the latest version on GitHub.\nb.  Check if WeChat is available on the shopper's device.\n   \/\/ WeChatPayProvider is not an actual provider, it only checks whether WeChat Pay is available.\n   val weChatPayProvider = WeChatPayProvider()\n   weChatPayProvider.isAvailable(application, paymentMethod, null) { isAvailable: Boolean, paymentMethod: PaymentMethod, _ -&gt;\n       if (isAvailable) {\n           \/\/ show WeChat pay as a payment option in your app\n       }\n   }\nc. If WeChat is available and the shopper chooses to pay with WeChat Pay, make a  \/payments request from your server.\n\n\nMake a payment\n\n\nFrom your server, make a  \/payments request:\n\n\n\nThe  \/payments response includes an action object that contains information about the app switch.\n\n\nPass the action object to your client app.\n\n\n\n\n\nHandle the app switch\n\n\nTo switch the shopper to the WeChat app, initialize the WeChat Pay Action Component, and pass the action object.\n  val weChatPayActionConfiguration = WeChatPayActionConfiguration.Builder(this, \"YOUR_CLIENT_KEY\")\n      \/\/ When you are ready to accept live payments, change the value to one of our live environments.\n      .setEnvironment(Environment.TEST)\n      .build()\n\n  val weChatPayActionComponent = WeChatPayActionComponent.PROVIDER.get(this, application, weChatPayActionConfiguration)\n  weChatPayActionComponent.handleAction(this@YourActivity, action)\nAfter the shopper has completed the payment, the WeChat app redirects them back to your app, and provides an Intent object containing the result of the payment.\n\n\nGet the result of the WeChat Pay SDK from the Activity. Pass the intent back to the WeChat Pay Action Component. Depending on your activity's launchMode, you can get this intent in either onCreate or onNewIntent.\nprivate fun handleIntent(intent: Intent) {\n    if (WeChatPayUtils.isResultIntent(intent)) {\n        weChatPayActionComponent.handleIntent(intent)\n    }\n}\nThe Component notifies the observer with the actionComponentData.\n\n\nPass the actionComponentData to your server.\nwechatPayActionComponent.observe(this) { actionComponentData -&gt;\n  \/\/ Send a \/payments\/details\/ call containing the `actionComponentData`\n  sendPaymentDetails(actionComponentData)\n}\n\n\nCheck the payment result\nWhen the shopper returns to your app, the Component provides the actionComponentData.\n\nPass the actionComponentData to your server.\nFrom your server, make a \/payments\/details request containing the actionComponentData.\n\nPresent 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 currently has no test platform. If you have a personal WeChat account you can test your integration by either:\n\nCanceling the transaction when you are asked to verify the payment (recommended).\nMaking live WeChat Pay payments with a low value.\n\n\nYou can check the status of a WeChat Pay payment in your\u00a0Customer Area\u00a0&gt;\u00a0Transactions\u00a0&gt;\u00a0Payments.\n\nBefore you can accept live WeChat Pay payments, you need to submit a request for WeChat Pay in your live Customer Area.\nSee also\n\n\n                    WeChat Open Platform\n                \n                    WeChat for Android\n                \n                    Android Components 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 in-app payments","lvl4":"WeChat Pay Component"},"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-in-app-payments","lvl4":"\/pt\/payment-methods\/wechat-pay\/wechat-pay-in-app-payments\/android-component"},"levels":5,"category":"Payment method","category_color":"green","tags":["WeChat","Component"]}}
