Git Product home page Git Product logo

wcc-wepay's Introduction

wcc-wepay

woocommerce wepay plugin, woocommerce微信支付插件

重要的事情说三遍:

本项目代码仅供参考学习!

本项目代码仅供参考学习!

本项目代码仅供参考学习!

使用前请先注意

  • 如果PHP版本是5.x版本,请注意lib/WxPay.Api.php文件中public static function notify($config, $callback, &$msg)...方法

因为PHP 7.x没有$GLOBALS['HTTP_RAW_POST_DATA']用法,7.x中用file_get_contents('php://input')替换5.x中$GLOBALS['HTTP_RAW_POST_DATA'],请知悉,代码如下:

        /**
 	 * 
 	 * 支付结果通用通知
 	 * @param function $callback
 	 * 直接回调函数使用方法: notify(you_function);
 	 * 回调类成员函数方法:notify(array($this, you_function));
 	 * $callback  原型为:function function_name($data){}
 	 */
	public static function notify($config, $callback, &$msg)
	{
                // PHP 5.x可以开启该注释
                /* 
		if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
                    file_put_contents(WCC_WEPAY_PLUGIN_PATH.'WC_Gateway_Wepay_Response.txt', 'FALSE,未收到数据'.date("Y-m-d H:i:s",time()).PHP_EOL, FILE_APPEND);
			# 如果没有数据,直接返回失败
			return false;
		}
                */

		//如果返回成功则验证签名
		try {
			//获取通知的数据
			//$xml = $GLOBALS['HTTP_RAW_POST_DATA']; // PHP 5.x版本用这个
                        $xml = file_get_contents('php://input'); // PHP 7.x版本用这个
			$result = WxPayNotifyResults::Init($config, $xml);
		} catch (WxPayException $e){
			$msg = $e->errorMessage();
			return false;
		}
		
		return call_user_func($callback, $result);
	}

插件已支持功能介绍(2019.04.21更新)

  • 支持最基本的PC扫码支付(基于PHP 7.x)

  • 支付完成自动跳转(微信demo演示并未提供该参数:return_url,需自己实现该功能...支付宝是自带了自动跳转return_url的参数)

  • 增加插件的清理工作:uninstall.php

  • 浏览器兼容性测试,支持Chrome,Firefox,IE 11

插件已支持功能介绍(2018.12.18更新)

  • 支持最基本的PC扫码支付

  • 支付完成自动跳转(微信demo演示并未提供该参数:return_url,需自己实现该功能...支付宝是自带了自动跳转return_url的参数)

运行环境(2018.12.16更新)

PHP 7.x

成功安装WooCommerce的WordPress系统

WordPress:WordPress 4.9.9

WooCommerce:3.5.0

微信支付SDK:php_sdk_v3.0.9

演示使用

wcc-wepay-show

如何使用

  • 设置固定链接格式(由于微信异步回调对回调链接有要求,不可以设置带参数的)

wordpress_link_setting

  • 安全证书放置于cert目录下即可,插件会去该路径找安全证书

cert_path

  • 上传插件,开启插件

enable_wcc_wepay_plugin

  • WooCommerce付款设置启用微信支付

wcc_enable_wepay_setting

  • WooCommerce微信支付设置支付参数

wcc_wepay_setting_args

configure_wepay_mch_end

上述设置成功,即可使用微信支付了.

wcc-wepay's People

Contributors

345161974 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

wcc-wepay's Issues

wcc-wepay MD附件图片

  • 演示

wcc-wepay-show

  • 设置固定链接格式(由于微信异步回调对回调链接有要求,不可以设置带参数的)

wordpress_link_setting

  • 安全证书至于cert目录下即可,插件会去该路径找安全证书

cert_path

  • 上传插件,开启插件

enable_wcc_wepay_plugin

  • WooCommerce付款设置启用微信支付

wcc_enable_wepay_setting

  • WooCommerce微信支付设置支付参数

wcc_wepay_setting_args

configure_wepay_mch_end

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.