12345678910111213141516171819202122232425262728293031323334 |
- <?php namespace App\Servers\WechatMini;
- use EasyWeChat\Factory;
- use Ixudra\Curl\Facades\Curl;
- /**
- * 微信小程序
- *
- */
- class MiniPay
- {
- protected $payment;
- public function __construct(Factory $factory)
- {
- $this->payment = $factory->payment(config('wechat.mini_pay',[]));
- }
- /**
- * 微信小程序支付下单
- *
- */
- public function unifiedOrder($request)
- {
- $result = $this->payment->order->unify($request);
- if ($result['return_code'] === 'SUCCESS' && !isset($result['err_code'])) {
- $prepayId = $result['prepay_id'];
- $json = $this->payment->jssdk->sdkConfig($prepayId);
- return response()->json($json);
- } else {
- return response()->json(['error' => '创建订单失败'], 500);
- }
- }
- }
|