Browse Source

支付变更

undefined
v-Brocloni 4 years ago
parent
commit
ec6480757a
4 changed files with 63 additions and 47 deletions
  1. +1
    -0
      addons/epay/controller/Index.php
  2. +1
    -1
      addons/epay/info.ini
  3. +1
    -1
      addons/epay/library/Yansongda/Pay/Gateways/Alipay/Alipay.php
  4. +60
    -45
      addons/unishop/controller/Pay.php

+ 1
- 0
addons/epay/controller/Index.php View File

@@ -82,6 +82,7 @@ class Index extends Controller
$out_trade_no = $data['out_trade_no'];

//你可以在此编写订单逻辑

} catch (Exception $e) {
}
echo $pay->success();


+ 1
- 1
addons/epay/info.ini View File

@@ -5,4 +5,4 @@ author = Karson
website = https://www.fastadmin.net
version = 1.0.5
state = 1
url = /addons/epay.html
url = /addons/epay

+ 1
- 1
addons/epay/library/Yansongda/Pay/Gateways/Alipay/Alipay.php View File

@@ -15,7 +15,7 @@ abstract class Alipay implements GatewayInterface
/**
* @var string
*/
protected $gateway = 'https://openapi.alipay.com/gateway.do?charset=UTF-8';
protected $gateway = 'https://openapi.alipaydev.com/gateway.do?charset=UTF-8';

/**
* alipay global config params.


+ 60
- 45
addons/unishop/controller/Pay.php View File

@@ -9,6 +9,7 @@

namespace addons\unishop\controller;

use addons\epay\library\Service;
use addons\unishop\extend\Ali;
use addons\unishop\extend\Hashids;
use addons\unishop\extend\Wechat;
@@ -237,51 +238,65 @@ class Pay extends Base
*/
public function alipay()
{
$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());
}
$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());
// }

}



Loading…
Cancel
Save