2017 © Pedro Peláez
 

library omnipay-wechat

WeChat driver for the Omnipay PHP payment processing library

image

labs7in0/omnipay-wechat

WeChat driver for the Omnipay PHP payment processing library

  • Tuesday, May 10, 2016
  • by kinosang
  • Repository
  • 7 Watchers
  • 24 Stars
  • 16,215 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

Omnipay-WeChat

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

Build Status Build Status Coverage Status Packagist Status Packagist Downloads, (*2)

Deprecated We suggest you to use @lokielse's implementation of WeChatPay for Omnipay at lokielse/omnipay-wechatpay., (*3)

There's a pre-built Payment Gateway based on Omnipay at labs7in0/E-cash., (*4)

Installation

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

{
    "require": {
        "labs7in0/omnipay-wechat": "dev-master"
    }
}

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

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

Basic Usage

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

  • WeChat Express (WeChat NATIVE)

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

Example

Make a payment

The WeChat NATIVE payment gateway return a URI which can be opened within WeChat In-App broswer, you can generate a QR code with the URI., (*9)

$omnipay = Omnipay::create('WeChat_Express');

$omnipay->setAppId('app_id'); // App ID of your WeChat MP account
$omnipay->setAppKey('app_key'); // App Key of your WeChat MP account
$omnipay->setMchId('partner_id'); // Partner ID of your WeChat merchandiser (WeChat Pay) account

$params = array(
    'out_trade_no' => time() . rand(100, 999), // billing id in your system
    'notify_url' => $notify_url, // URL for asynchronous notify
    'body' => $billing_desc, // A simple description
    'total_fee' => 0.01, // Amount with less than 2 decimals places
    'fee_type' => 'CNY', // Currency name from ISO4217, Optional, default as CNY
);

$response = $omnipay->purchase($params)->send();

$qrCode = new Endroid\QrCode\QrCode(); // Use Endroid\QrCode to generate the QR code
$qrCode
    ->setText($response->getRedirectUrl())
    ->setSize(120)
    ->setPadding(0)
    ->render();

Verify a payment (especially for asynchronous notify)

completePurchase for Omnipay-WeChat does not require the same arguments as when you made the initial purchase call. The only required parameter is out_trade_no (the billing id in your system) or transaction_id (the trade number from WeChat)., (*10)

$omnipay = Omnipay::create('WeChat_Express');

$omnipay->setAppId('app_id'); // App ID of your WeChat MP account
$omnipay->setAppKey('app_key'); // App Key of your WeChat MP account
$omnipay->setMchId('partner_id'); // Partner ID of your WeChat merchandiser (WeChat Pay) account

$params = array(
    'out_trade_no' => $billing_id, // billing id in your system
    //or you can use 'transaction_id', the trade number from WeChat
);

$response = $omnipay->completePurchase($params)->send();

if ($response->isSuccessful() && $response->isTradeStatusOk()) {
    $responseData = $response->getData();

    // Do something here
}

Donate us, (*11)

License

The MIT License (MIT), (*12)

More info see LICENSE, (*13)

The Versions

10/05 2016

dev-master

9999999-dev https://github.com/labs7in0/omnipay-wechat

WeChat driver for the Omnipay PHP payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by 7IN0SAN9

payment pay gateway merchant purchase omnipay wechat

10/05 2016

v1.1.1

1.1.1.0 https://github.com/labs7in0/omnipay-wechat

WeChat driver for the Omnipay PHP payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by 7IN0SAN9

payment pay gateway merchant purchase omnipay wechat

07/10 2015

v1.1.0

1.1.0.0 https://github.com/labs7in0/omnipay-wechat

WeChat driver for the Omnipay PHP payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by 7IN0SAN9

payment pay gateway merchant purchase omnipay wechat

15/08 2015

v1.0.0

1.0.0.0 https://github.com/labs7in0/omnipay-wechat

WeChat driver for the Omnipay PHP payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by 7IN0SAN9

payment pay gateway merchant purchase omnipay wechat

12/08 2015

v1.0.0-beta

1.0.0.0-beta https://github.com/labs7in0/omnipay-wechat

WeChat driver for the Omnipay PHP payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by 7IN0SAN9

payment pay gateway merchant purchase omnipay wechat