Woo WeChatPay is a companion plugin for WP Weixin that adds a WeChat Pay payment gateway to WooCommerce-powered websites. Customers can pay both in the WeChat browser (JSAPI), mobile browsers (H5), or from their computer via a QR code. Upon purchase and if activated in settings, customers may receive a notification in the WeChat Official Account with a templated message if they are a follower.
- A China Mainland WeChat Official Account - Service account.
- A China Mainland WeChat Pay account.
- WP Weixin installed, activated, enabled and properly configured.
Does NOT support cross-border payments (possibly planned for v1.4).
This plugin adds the following major features to WooCommerce and WP Weixin:
- Payment of WooCommerce orders in WeChat mobile app: uses the WeChat JSAPI for a seamless experience.
- Payment of WooCommerce orders in mobile browsers: calls the WeChat H5 API for a seamless experience.
- Payment of WooCommerce orders with WeChat via QR Code: for customers using WeChat Pay in classic browsers.
- Support for "pay again": allows customers to continue the payment process of Pending orders.
- Refund of WooCommerce orders: possibility to refund orders manually in a few clicks, and support for automatic refund in case the transaction failed.
- Templated message notification in WeChat: send a WeChat templated message to the customer upon purchase (if following the Official Account - completely customisable via filters).
- Multi-currency support: using an exchange rate against Chinese Yuan configured in the settings.
Compatible with WooCommerce Multilingual, WPML, Ultimate Member, WordPress Multisite, and many caching plugins.
The settings below are added to WooCommerce and WP Weixin when the plugin is active.
The following settings can be accessed in WooCommerce > Settings > Payments > WeChat Pay:
Name | Type | Description |
---|---|---|
Enable/Disable | checkbox | Used to enable/disable the payment gateway |
Checkout page title | text | Title displayed for the payment gateway on the checkout page |
Checkout page description | text | Description displayed for the payment gateway on the checkout page |
Exchange Rate | text | Exchange rate against Chinese Yuan (shows if the store currency is not set to Chinese Yuan) |
WeChat Order Notification Template ID | text | ID of a template added in the WeChat backend at https://mp.weixin.qq.com . |
H5 payment in mobile web browsers | checkbox | If checked, customers can place an order via their mobile browsers and select WeChat Pay on their phone: instead of a QR code, WeChat Pay will be automatically called out to complete the payment. This feature requires to be activated and approved in the backend at https://pay.weixin.qq.com/index.php/extend/pay_apply/apply_normal_h5_pay beforehand. |
The settings below are only available if Woo WeChatPay is installed and activated (this behavior may be altered using the wp_weixin_show_settings_section filter).
Name | Type | Description |
---|---|---|
Force follow (account and checkout) | checkbox | Require the user to follow the Official Account before accessing the checkout and account pages with the WeChat browser. |
Additionally, required settings are located on the WP Weixin settings page, in the WeChat Pay Settings section. See also the WeChat Pay Settings of the WP Weixin plugin documentation.
Woo WeChatPay gives developers the possibilty to customise its behavior with a series of custom actions and filters.
Actions index:
do_action( 'woo_wechatpay_templated_message_sent', bool $sent, array $parameters );
Description
Fired after attempting to send the templated message payment notification to the WeChat user.
Parameters
$sent
(bool) Wether the templated message was sent. $parameters (array) The parameters and content of the templated message.
Filters index:
- woo_wechatpay_qr_img_header
- woo_wechatpay_qr_img_footer
- woo_wechatpay_qr_phone_bg
- woo_wechatpay_qr_placeholder
- woo_wechatpay_templated_message
- woo_wechatpay_templated_message_intro_text
- woo_wechatpay_templated_message_cta_text
- woo_wechatpay_templated_message_remark_text
- woo_wechatpay_templated_message_url
- woo_wechatpay_templated_message_product_info_text
- woo_wechatpay_templated_message_title_color
- woo_wechatpay_templated_message_intro_color
- woo_wechatpay_templated_message_order_num_color
- woo_wechatpay_templated_message_product_info_color
- woo_wechatpay_templated_message_order_total_color
- woo_wechatpay_templated_message_remark_color
- woowechatpay_filter_wechat_gateways
apply_filters( 'woo_wechatpay_qr_img_header', string $qr_img_header );
Description
Filter the image used as a header when displaying the payment QR code on desktops.
Parameters
$qr_img_header
(string) Path to the image - default
WP_PLUGIN_URL . '/woo-wechatpay/images/wechatpay-logo.png'
.
apply_filters( 'woo_wechatpay_qr_img_footer', string $qr_img_footer );
Description
Filter the image used as a footer when displaying the payment QR code on desktops.
Parameters
$qr_img_footer
(string) Path to the image - default
WP_PLUGIN_URL . '/woo-wechatpay/images/browser-qr-footer.png'
.
apply_filters( 'woo_wechatpay_qr_phone_bg', string $qr_phone_bg );
Description
Filter the image used as a background when displaying the payment QR code on desktops.
Parameters
$qr_phone_bg
(string) Path to the image - default
WP_PLUGIN_URL . '/woo-wechatpay/images/phone-bg.png'
.
apply_filters( 'woo_wechatpay_qr_placeholder', string $qr_placeholder );
Description
Filter the image used as a placeholder when the payment QR code is not available on desktops.
Parameters
$qr_placeholder
(string) Path to the image - default
WP_PLUGIN_URL . '/woo-wechatpay/images/qr-placeholder.png'
.
apply_filters( 'woo_wechatpay_templated_message', array $templated_message, array $payment_result, mixed $order );
Description
Filter the templated message values - can be used to override the order notification templated message entirely, bypassing the fields restrictions imposed by default and use any template available in WeChat backend. The filter must be added at the latest in a plugin_loaded
action with a priority of 19
or less.
Parameters
$templated_message
(array) An array representation of the final JSON templated message.
$payment_result
(array) Result information returned by WeChat.
$order
(mixed) A
WC_Order
object representing the order the customer attempted to pay.
apply_filters( 'woo_wechatpay_templated_message_intro_text', string $intro_text, mixed $order );
Description
Filter the introduction displayed in the order notification templated message.
Parameters
$intro_text
(string) The intro text to display.
$order
(mixed) A
WC_Order
object or the integer ID of a WooCommerce order.
apply_filters( 'woo_wechatpay_templated_message_cta_text', string $cta, mixed $order );
Description
Filter the call to action text displayed in the order notification templated message.
Parameters
$cta
(string) The call to action text to display.
$order
(mixed) A
WC_Order
object or the integer ID of a WooCommerce order.
apply_filters( 'woo_wechatpay_templated_message_remark_text', string $remark_text, mixed $order );
Description
Filter the remarks text displayed in the order notification templated message.
Parameters
$remark_text
(string) The remark text to display.
$order
(mixed) A
WC_Order
object or the integer ID of a WooCommerce order.
apply_filters( 'woo_wechatpay_templated_message_url', string $url, mixed $order );
Description
Filter the URL the user will be redirected to when interacting with the order notification templated message.
Parameters
$url
(string) The URL the user will be redirected to.
$order
(mixed) A
WC_Order
object or the integer ID of a WooCommerce order.
apply_filters( 'woo_wechatpay_templated_message_product_info_text', string $product_info, mixed $order );
Description
Filter the product information displayed in the order notification templated message.
Parameters
$product_info
(string) The product information text to display.
$order
(mixed) A
WC_Order
object or the integer ID of a WooCommerce order.
apply_filters( 'woo_wechatpay_templated_message_title_color', string $color );
Description
Filter the color of the title in the order notification templated message.
Parameters
$color
(string) The hexadecimal code of the color - default
'#666'
.
apply_filters( 'woo_wechatpay_templated_message_intro_color', string $color );
Description
Filter the color of the introduction in the order notification templated message.
Parameters
$color
(string) The hexadecimal code of the color - default
'#173177'
.
apply_filters( 'woo_wechatpay_templated_message_order_num_color', string $color );
Description
Filter the color of the order number in the order notification templated message.
Parameters
$color
(string) The hexadecimal code of the color - default
'#173177'
.
apply_filters( 'woo_wechatpay_templated_message_product_info_color', string $color );
Description
Filter the color of the product information in the order notification templated message.
Parameters
$color
(string) The hexadecimal code of the color - default
'#173177'
.
apply_filters( 'woo_wechatpay_templated_message_order_total_color', string $color );
Description
Filter the color of the total price in the order notification templated message.
Parameters
$color
(string) The hexadecimal code of the color - default
'#173177'
.
apply_filters( 'woo_wechatpay_templated_message_remark_color', string $color );
Description
Filter the color of the remark in the order notification templated message.
Parameters
$color
(string) The hexadecimal code of the color - default
'#173177'
.
apply_filters( 'woowechatpay_filter_wechat_gateways', $available_gateways, $original_available_gateways )
Description
Filter the available gateways in the WeChat browser.
Parameters
$available_gateways
(array) The list of gateways available in the WeChat browser.
$original_available_gateways
(array) The list of gateways originally available in WooCommerce.
The following template files are selected using the locate_template()
and included with load_template()
functions provided by WordPress. This means they can be overloaded in the active WordPress theme. Developers may place their custom template files in the following directories under the theme's folder (in order of selection priority):
plugins/wp-weixin/woo-wechatpay/
wp-weixin/woo-wechatpay/
plugins/woo-wechatpay/
woo-wechatpay/
wp-weixin/
- at the root of the theme's folder
The available paths of the templates may be customised with the wp_weixin_locate_template_paths filter.
Templates index:
computer-pay-qr.php
Description
The template of the page displayed when the user is paying using a QR code on a computer.
Variables
$has_result
(bool) Wether the QR code has been generated successfully.
$qr_img_header
(string) The image used as a header when displaying the payment QR code on desktops.
$qr_placeholder
(string) The image used as a placeholder when the payment QR code is not available on desktops.
$qr_url
(string) The URL of the WeChat Pay QR code used to pay for the order.
$order_id
(int) The ID of the order to pay for.
$qr_img_footer
(string) The image used as a footer when displaying the payment QR code on desktops.
$qr_phone_bg
(string) The image used as a background when displaying the payment QR code on desktops.
$error
(string) Description of the error if somthing wrong happened.
Associated style enqueued with key:
woo-wechatpay-main-style
Associated script enqueued with key:
woo-wechatpay-heartbeat
redirected-pay.php
Description
The template of the page displayed when users are redirected before payment on mobile phones. The template acts as a placeholder before showing the native payment UI.
Associated style enqueued with key:
woo-wechatpay-main-style
Associated script enqueued with key:
woo-wechatpay-mobile-redirected