ajiahub / yii2-wechat-pay

wechat pay sdk for yii2
MIT License
0 stars 2 forks source link

confusing usage of static class #1

Open xklake opened 7 years ago

xklake commented 7 years ago

hi, i am a bit confused the way you use yii2-wechat-pay/WxPayConfig.php, properties of this classes are used as WxPayConfig::property which is for static, this does not work for me.

also in param.php wxPay, 'components' => [ 'wxPay' => [ 'class' => 'chinahub\wechat\WxPayConfig', 'app_id' => '8888888888888', 'mch_id' => '9999999999999999', 'app_key' => '11111111111111111', 'app_secret' => '777777777777777777', ], ],

but in class WxPayDataBase, if using public function behaviors() { return [WxPayConfig::className()]; }

will not pass the config values into these objects,

what i am trying to do is like this public function behaviors() { return [ 'wxconfig' => [ 'class' => WxPayConfig::className(), 'app_id' => Yii::$app->params['wechat_appid'], 'mch_id' => Yii::$app->params['wechat_mchid'], 'app_key' => Yii::$app->params['wechat_key'], 'app_secret' => Yii::$app->params['wechat_secret'], .... ] ]; } but i am not sure if you defined it as component, it should be used somewhere, but how do you use it? i am new to php or yii2, dare to raise these question, please kindly to help me to understand. thank you in advance.

xklake commented 7 years ago

in WxPayApi $result = WxPayResults::Init($response); this should be WxPayResults::IInits(), also in WxPayConfig class, some const are missed in the file

xklake commented 7 years ago

the code has not been tested very well, please be cautious if you really use in production