|
@@ -4,6 +4,7 @@ namespace app\api\controller\pay;
|
|
|
|
|
|
use app\model\Order;
|
|
|
use support\Request;
|
|
|
+use Yansongda\Pay\Exceptions\BusinessException;
|
|
|
use Yansongda\Pay\Pay;
|
|
|
|
|
|
class WxpayController
|
|
@@ -12,7 +13,7 @@ class WxpayController
|
|
|
public function index(Request $request)
|
|
|
{
|
|
|
$params = $request->all();
|
|
|
- if (!isset($params['order_id'])){
|
|
|
+ if (!isset($params['order_id'])) {
|
|
|
return json_fail('参数异常');
|
|
|
}
|
|
|
$orderId = $params['order_id'];
|
|
@@ -26,9 +27,17 @@ class WxpayController
|
|
|
'total_fee' => $order->order_amount_pay * 100,
|
|
|
];
|
|
|
|
|
|
- $alipay = Pay::wechat($this->getConfig())->app($payData)->getContent();
|
|
|
+ try {
|
|
|
+ $alipay = Pay::wechat($this->getConfig())->app($payData)->getContent();
|
|
|
+
|
|
|
+ return json_success('', json_decode($alipay, true));
|
|
|
+ } catch (BusinessException $e) {
|
|
|
+ return json_fail($e->getMessage());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return json_fail('下单失败');
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- return json_success('',json_decode($alipay,true));
|
|
|
}
|
|
|
|
|
|
public function notify()
|