EeasyWechat 微信app支付
生活随笔
收集整理的這篇文章主要介紹了
EeasyWechat 微信app支付
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
EeasyWechat 微信app支付
用的是easywechat3.x版本 + phpuse EasyWeChat\Foundation\Application; use EasyWeChat\Payment\Order; public function appPay(){if ($this->request->isPost()) {$post = $this->request->post();$result = ['body' => '商品名稱','out_trade_no' => ‘訂單編號’,'total_fee' => 10 * 100, // 金額'spbill_create_ip' => '', // 可選,如不傳該參數,SDK 將會自動獲取相應 IP 地址'notify_url' => '/notify', // 支付結果通知網址,如果不設置則會使用配置里的默認地址'trade_type' => 'APP', // 請對應換成你的支付方式對應的值類型];$appOrder = new Order($result);$appPayment = self::appPayment(); // 微信app配置信息 new Application(self::options);$rest = $appPayment->payment->prepare($appOrder);if ($rest->return_code != 'SUCCESS' || $rest->result_code != 'SUCCESS') {$this->error('獲取支付訂單失敗');} if ($rest->return_code == 'SUCCESS' && $rest->result_code == 'SUCCESS') {$prepayId = $rest['prepay_id'];$json = $appPayment->payment->configForAppPayment($prepayId);$this->success('支付成功',$json);} else {$this->error('調起支付失敗,稍后再試~');}}$this->error('請求錯誤');}總結
以上是生活随笔為你收集整理的EeasyWechat 微信app支付的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CH 5102Mobile Servic
- 下一篇: 关于z-index的一些问题