2017 © Pedro Peláez
 

library yii2-easy-wechat

WeChat SDK for yii2, based on overtrue/easywechat

image

maxwen/yii2-easy-wechat

WeChat SDK for yii2, based on overtrue/easywechat

  • Friday, August 11, 2017
  • by max.wen
  • Repository
  • 12 Watchers
  • 176 Stars
  • 5,562 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 63 Forks
  • 6 Open issues
  • 10 Versions
  • 11 % Grown

The README.md

yii2-easy-wechat

WeChat SDK for yii2 , based on overtrue/wechat.
This extension helps you access overtrue/wechat application in a simple & familiar way: Yii::$app->wechat., (*1)

Latest Stable Version Total Downloads License, (*2)

Installation

composer require maxwen/yii2-easy-wechat

Configuration

Add the SDK as a yii2 application component in the config/main.php:, (*3)


'components' => [ // ... 'wechat' => [ 'class' => 'maxwen\easywechat\Wechat', // 'userOptions' => [] # user identity class params // 'sessionParam' => '' # wechat user info will be stored in session under this key // 'returnUrlParam' => '' # returnUrl param stored in session ], // ... ]

Usage


// here are two representative examples that will help you: // 微信网页授权: if(Yii::$app->wechat->isWechat && !Yii::$app->wechat->isAuthorized()) { return Yii::$app->wechat->authorizeRequired()->send(); } // 微信支付(JsApi): $orderData = [ 'openid' => '.. ' // ... etc. ]; $order = new WechatOrder($orderData); $payment = Yii::$app->wechat->payment; $prepayRequest = $payment->prepare($order); if($prepayRequest->return_code = 'SUCCESS' && $prepayRequest->result_code == 'SUCCESS') { $prepayId = $prepayRequest->prepay_id; }else{ throw new yii\base\ErrorException('微信支付异常, 请稍后再试'); } $jsApiConfig = $payment->configForPayment($prepayId); return $this->render('wxpay', [ 'jsApiConfig' => $jsApiConfig, 'orderData' => $orderData ]);

How to load Wechat configures?

the overtrue/wechat application always constructs with a $options parameter. I made the options as a yii2 param in the params.php:, (*4)

recomended way:, (*5)

// in this way you need to create a wechat.php in the same directory of params.php
// put contents in the wechat.php like:
// return [ 
//      // wechat options here 
// ];
'WECHAT' => require(__DIR__.'/wechat.php'),

OR, (*6)

'WECHAT' => [ // wechat options here ]

Wechat options configure help docs., (*7)

More documentation

see EasyWeChat Docs., (*8)

Thanks to overtrue/wechat , realy a easy way to play with wechat SDK 😁., (*9)

More repos for Yii2:

yii2-ckeditor-widget
yii2-adminlte-gii
yii2-curl, (*10)

The Versions

11/08 2017

dev-master

9999999-dev

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

11/08 2017

1.0.3

1.0.3.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

06/04 2017

2.x-dev

2.9999999.9999999.9999999-dev

WeChat Module for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

31/03 2017

1.0.2

1.0.2.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

27/03 2017

1.0.1

1.0.1.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

13/11 2016

1.0

1.0.0.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

25/10 2016

0.9.3

0.9.3.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

25/10 2016

0.9.2

0.9.2.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

25/10 2016

0.9.1

0.9.1.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen

25/10 2016

0.9

0.9.0.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by Avatar max.wen