Giter Site home page Giter Site logo

helloteababy / woocommerce-wechatpay Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 554 KB

This is a mirror, check the latest version at https://plugins.svn.wordpress.org/woo-wechatpay/

Home Page: https://github.com/froger-me/woo-wechatpay

License: GNU General Public License v3.0

CSS 1.75% PHP 59.05% JavaScript 39.20%
woocommerce wechat wordpress

woocommerce-wechatpay's Introduction

Woo WeChatPay - WeChat Pay payment gateway for WooCommerce

General Description

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 (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.

Requirements

Important Notes

Does NOT support cross-border payments (possibly planned for v1.4).

Overview

This plugin adds the following major features to WooCommerce and WP Weixin:

  • Payment of WooCommerce orders in WeChat mobile app (H5): uses the WeChat JSAPI 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.

Settings

The settings below are added to WooCommerce and WP Weixin when the plugin is active.

Gateway settings

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.

WP Weixin Settings

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.

Hooks - actions & filters

Woo WeChatPay gives developers the possibilty to customise its behavior with a series of custom actions and filters.

Actions

Actions index:


woo_wechatpay_templated_message_sent

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

Filters index:


woo_wechatpay_qr_img_header

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'.


woo_wechatpay_qr_img_footer

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'.


woo_wechatpay_qr_phone_bg

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'.


woo_wechatpay_qr_placeholder

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'.


woo_wechatpay_templated_message

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.


woo_wechatpay_templated_message_intro_text

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.


woo_wechatpay_templated_message_cta_text

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.


woo_wechatpay_templated_message_remark_text

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.


woo_wechatpay_templated_message_url

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.


woo_wechatpay_templated_message_product_info_text

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.


woo_wechatpay_templated_message_title_color

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'.


woo_wechatpay_templated_message_intro_color

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'.


woo_wechatpay_templated_message_order_num_color

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'.


woo_wechatpay_templated_message_product_info_color

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'.


woo_wechatpay_templated_message_order_total_color

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'.


woo_wechatpay_templated_message_remark_color

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'.


woowechatpay_filter_wechat_gateways

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.


Templates

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

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

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

woocommerce-wechatpay's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.