2017 © Pedro Peláez
 

library omnipay-wxpay

Wechat gateway for Omnipay payment processing library

image

zfuming/omnipay-wxpay

Wechat gateway for Omnipay payment processing library

  • Friday, September 8, 2017
  • by zfuming
  • Repository
  • 1 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Omnipay: WxPay

WxPay driver for the Omnipay PHP payment processing library, (*1)

Build Status Latest Stable Version Total Downloads, (*2)

The WxPay gateway can be accessed from outside of China, (*3)

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements UnionPay support for Omnipay., (*4)

Installation

Omnipay is installed via Composer. To install, simply add it to your composer.json file:, (*5)

"zfuming/omnipay-wxpay": "^1.0",

And run composer to update your dependencies:, (*6)

$ composer update -vvv

Basic Usage

The following gateways are provided by this package:, (*7)

  • WxPay (Wechat Common Gateway) 微信支付通用网关
  • WxPay_App (Wechat App Gateway) 微信APP支付网关
  • WxPay_Native (Wechat Native Gateway) 微信原生扫码支付支付网关
  • WxPay_Js (Wechat Js API/MP Gateway) 微信网页、公众号、小程序支付网关
  • WxPay_Pos (Wechat Micro/POS Gateway) 微信刷卡支付网关

Usage

Create Order doc

//gateways: WxPay_App, WxPay_Native, WxPay_Js, WxPay_Pos
$gateway    = Omnipay::create('WxPay_App');
$gateway->setAppId($config['app_id']);
$gateway->setMchId($config['mch_id']);
$gateway->setSubMchId($config['sub_mch_id']);
$gateway->setApiKey($config['api_key']);

$order = [
    'body'              => 'The test order',
    'out_trade_no'      => date('YmdHis').mt_rand(1000, 9999),
    'total_fee'         => 1, //=0.01
    'spbill_create_ip'  => 'ip_address',
    'fee_type'          => 'CNY'
];

/**
 * @var Omnipay\WxPay\Message\CreateOrderRequest $request
 * @var Omnipay\WxPay\Message\CreateOrderResponse $response
 */
$request  = $gateway->purchase($order);
$response = $request->send();

//available methods
$response->isSuccessful();
$response->getData(); //For debug
$response->getAppOrderData(); //For WxPay_App
$response->getJsOrderData(); //For WxPay_Js
$response->getCodeUrl(); //For Native Trade Type

Notify doc

$gateway    = Omnipay::create('WxPay');
$gateway->setAppId($config['app_id']);
$gateway->setMchId($config['mch_id']);
$gateway->setSubMchId($config['sub_mch_id']);
$gateway->setApiKey($config['api_key']);

$response = $gateway->completePurchase([
    'request_params' => file_get_contents('php://input')
])->send();

if ($response->isPaid()) {
    //pay success
    var_dump($response->getData());
}else{
    //pay fail
}

Query Order doc

$response = $gateway->query([
    'transaction_id' => '1217752501201407033233368018', //The wechat trade no
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());

Close Order doc

$response = $gateway->close([
    'out_trade_no' => '201602011315231245', //The merchant trade no
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());

Refund doc

$gateway->setCertPath($certPath);
$gateway->setKeyPath($keyPath);

$response = $gateway->refund([
    'transaction_id' => '1217752501201407033233368018', //The wechat trade no
    'out_refund_no' => $outRefundNo,
    'total_fee' => 1, //=0.01
    'refund_fee' => 1, //=0.01
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());

QueryRefund doc

$response = $gateway->queryRefund([
    'refund_id' => '1217752501201407033233368018', //Your site trade no, not union tn.
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());

Shorten URL (for WxPay_Native) doc

$response = $gateway->shortenUrl([
    'long_url' => $longUrl
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());
var_dump($response->getShortUrl());

Query OpenId (for WxPay_Pos) doc

$response = $gateway->shortenUrl([
    'auth_code' => $authCode
])->send();

var_dump($response->isSuccessful());
var_dump($response->getData());
var_dump($response->getOpenId());

For general usage instructions, please see the main Omnipay repository., (*8)

The Versions

08/09 2017

dev-master

9999999-dev https://github.com/zfuming/omnipay-wxpay

Wechat gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar zfuming

php payment pay gateway purchase omnipay app sdk wechat 微信支付

08/09 2017

1.0

1.0.0.0 https://github.com/zfuming/omnipay-wxpay

Wechat gateway for Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar zfuming

php payment pay gateway purchase omnipay app sdk wechat 微信支付