|
|
@@ -238,65 +238,37 @@ class Pay extends Base |
|
|
|
*/ |
|
|
|
public function alipay() |
|
|
|
{ |
|
|
|
$params = [ |
|
|
|
'amount'=>"99.9", |
|
|
|
'orderid'=>time(), |
|
|
|
'type'=>"alipay", |
|
|
|
'title'=>"订单标题", |
|
|
|
'notifyurl'=>Config::getByName('ali_notify_url')['value'], |
|
|
|
'returnurl'=>Config::getByName('ali_return_url')['value'], |
|
|
|
'method'=>"wap", |
|
|
|
'openid'=>"用户的OpenID", |
|
|
|
'auth_code'=>"验证码" |
|
|
|
]; |
|
|
|
|
|
|
|
return Service::submitOrder($params); |
|
|
|
|
|
|
|
// $orderId = $this->request->request('order_id', 0); |
|
|
|
// $orderId = Hashids::decodeHex($orderId); |
|
|
|
// |
|
|
|
// $orderModel = new \addons\unishop\model\Order(); |
|
|
|
// $order = $orderModel->where(['id' => $orderId])->find(); |
|
|
|
// |
|
|
|
// try { |
|
|
|
// if (!$order) { |
|
|
|
// $this->error(__('Order does not exist')); |
|
|
|
// } |
|
|
|
// $products = $order->products()->select(); |
|
|
|
// |
|
|
|
// $body = Config::getByName('name')['value']; |
|
|
|
// foreach ($products as $product) { |
|
|
|
// $body .= '_' . $product['title']; |
|
|
|
// } |
|
|
|
// |
|
|
|
// $platfrom = $this->request->header('platform', 'H5'); |
|
|
|
// $alipay = Ali::initAliPay(); |
|
|
|
// $order = [ |
|
|
|
// 'out_trade_no' => $order->out_trade_no, |
|
|
|
// 'total_amount' => $order->total_price, |
|
|
|
// 'subject' => $body, |
|
|
|
// 'http_method' => 'GET' // 如果想在 wap 支付时使用 GET 方式提交,请加上此参数。默认使用 POST 方式提交 |
|
|
|
// ]; |
|
|
|
// |
|
|
|
// switch ($platfrom) { |
|
|
|
// case 'H5': |
|
|
|
// // 直接返回 |
|
|
|
// $alipay->wap($order)->send(); |
|
|
|
// break; |
|
|
|
// case 'APP-PLUS': |
|
|
|
// //$pay->app($order)->send(); |
|
|
|
// $this->success('', $alipay->app($order)->getContent()); |
|
|
|
// break; |
|
|
|
// case 'MP-ALIPAY': |
|
|
|
// |
|
|
|
// break; |
|
|
|
// default: |
|
|
|
// $this->error('此平台不支持支付宝支付'); |
|
|
|
// } |
|
|
|
// |
|
|
|
// } catch (Exception $e) { |
|
|
|
// $this->error($e->getMessage()); |
|
|
|
// } |
|
|
|
$orderId = $this->request->request('order_id', 0); |
|
|
|
$orderId = Hashids::decodeHex($orderId); |
|
|
|
|
|
|
|
$orderModel = new \addons\unishop\model\Order(); |
|
|
|
$order = $orderModel->where(['id' => $orderId])->find(); |
|
|
|
|
|
|
|
try { |
|
|
|
if (!$order) { |
|
|
|
$this->error(__('Order does not exist')); |
|
|
|
} |
|
|
|
$products = $order->products()->select(); |
|
|
|
|
|
|
|
$body = Config::getByName('name')['value']; |
|
|
|
foreach ($products as $product) { |
|
|
|
$body .= '_' . $product['title']; |
|
|
|
} |
|
|
|
$params = [ |
|
|
|
'amount'=>$order->total_price, |
|
|
|
'orderid'=>$order->out_trade_no, |
|
|
|
'type'=>"alipay", |
|
|
|
'title'=>$body, |
|
|
|
'notifyurl'=>Config::getByName('ali_notify_url')['value'], |
|
|
|
'returnurl'=>Config::getByName('ali_return_url')['value'], |
|
|
|
'method'=>"wap", |
|
|
|
]; |
|
|
|
|
|
|
|
return Service::submitOrder($params); |
|
|
|
|
|
|
|
} catch (Exception $e) { |
|
|
|
$this->error($e->getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|