Download the PHP package itc/weixin-payment without Composer
On this page you can find all versions of the php package itc/weixin-payment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package weixin-payment
weixin-payment
WeChat payment client library for PHP 5.5+
Features
- Simple, intuitive programming interface
- Composer-friendly; just install the package and go!
- PSR-7 compatible
- PSR-3 compatible
- Integrates with Laravel 5
- Fully tested
What it does (and doesn't)
The client exposes a simple programming interface to WeChat's payment-related web service calls. It transparently handles boilerplate stuff like request signing and XML serialization so you can focus on things that matter.
This package does not perform authentication; it will not help you get a user's OpenID. Fortunately, there are plenty of other packages that already do this. overtrue/wechat is a pretty good one.
Usage
Create a Client instance
Start a payment
The $jsbridge_params
object can then be JSON-serialized and supplied directly
to the WeixinJSBridge
global in the Javascript space. Here's an example:
Messages
This library represents XML payloads transported between the client and the WeChat web service as messages. A Message is an object that:
- can be serialized to XML
- supports hash-based signing and authentication
- provides key/value access to its attributes
How to create a Message instance
How to add message attributes
How to convert a message to XML
How to sign a message
How to authenticate a signed message
Generally, whenever you execute a Command
(see below), you will want to
authenticate the result:
Commands
The various web service calls to the payment API are commands. A
Command is an
object that has an execute
method which returns a Message
.
-
pay/unifiedorder
spec -
pay/orderquery
spec -
pay/closeorder
spec (NOT IMPLEMENTED) -
secapi/refund
spec (NOT IMPLEMENTED) -
pay/refundquery
spec (NOT IMPLEMENTED) -
pay/downloadbill
spec (NOT IMPLEMENTED) -
payitil/report
spec (NOT IMPLEMENTED) -
tools/shorturl
spec (NOT IMPLEMENTED) -
mmpaymkttransfers/sendredpack
spec mmpaymkttransfers/gethbinfo
spec
Installation
Composer
composer require itc/weixin-payment:1.3.0
Laravel
The package ships with a Laravel 5 service provider that
registers the Client on the application service container. Install the service
provider by adding the following line to the providers
array in config/app.php
:
ITC\Weixin\Payment\ServiceProvider::class
Then publish the package configuration via:
php artisan vendor:publish
Now you can access the client instance via dependency injection or through the service container:
Contributing
Feel free to fork this project and create a pull request!
How to implement a Command
-
Implement a concrete
ITC\Weixin\Payment\Contracts\Command
. Feel free to extendITC\Weixin\Payment\Command\Command
. - Register the command inside
Client::instance()
:
How to run tests
./phpunit
License
MIT