...
|
...
|
@@ -161,11 +161,62 @@ class IndexController extends HomeBaseController |
|
|
}
|
|
|
}
|
|
|
|
|
|
// public function alipay()
|
|
|
// {
|
|
|
// require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php';
|
|
|
//
|
|
|
// $alipay_config = [
|
|
|
// 'gatewayUrl' => 'https://openapi.alipay.com/gateway.do',
|
|
|
// 'app_id' => '2018101661696470',
|
|
|
// 'merchant_private_key' => config('private_key'),
|
|
|
// 'alipay_public_key' => config('alipay_public_key'),
|
|
|
// 'charset' => 'UTF-8',
|
|
|
// 'sign_type' => 'RSA'
|
|
|
// ];
|
|
|
//
|
|
|
// $builder = [
|
|
|
// 'WIDsubject' => '购买',
|
|
|
// 'WIDout_trade_no' => '20181017256210',
|
|
|
// 'WIDtotal_amount' => 99,
|
|
|
// 'WIDbody' => '商品'
|
|
|
// ];
|
|
|
// $alipay = new \AlipayTradeService($alipay_config);
|
|
|
// $return = $alipay->wapPay($builder, '', '');
|
|
|
// print_r($return);
|
|
|
// }
|
|
|
|
|
|
public function alipay()
|
|
|
{
|
|
|
require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php';
|
|
|
header("Content-type: text/html; charset=utf-8");
|
|
|
|
|
|
|
|
|
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'service/AlipayTradeService.php';
|
|
|
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'buildermodel/AlipayTradeWapPayContentBuilder.php';
|
|
|
require dirname(__FILE__) . DIRECTORY_SEPARATOR . './../config.php';
|
|
|
if (!empty($_POST['WIDout_trade_no']) && trim($_POST['WIDout_trade_no']) != "") {
|
|
|
//商户订单号,商户网站订单系统中唯一订单号,必填
|
|
|
$out_trade_no = '2018101721025641';
|
|
|
|
|
|
//订单名称,必填
|
|
|
$subject = '购买';
|
|
|
|
|
|
//付款金额,必填
|
|
|
$total_amount = 0.01;
|
|
|
|
|
|
//商品描述,可空
|
|
|
$body = '商品';
|
|
|
|
|
|
$alipay_config = [
|
|
|
//超时时间
|
|
|
$timeout_express = "1m";
|
|
|
|
|
|
$payRequestBuilder = new AlipayTradeWapPayContentBuilder();
|
|
|
$payRequestBuilder->setBody($body);
|
|
|
$payRequestBuilder->setSubject($subject);
|
|
|
$payRequestBuilder->setOutTradeNo($out_trade_no);
|
|
|
$payRequestBuilder->setTotalAmount($total_amount);
|
|
|
$payRequestBuilder->setTimeExpress($timeout_express);
|
|
|
|
|
|
$config = [
|
|
|
'gatewayUrl' => 'https://openapi.alipay.com/gateway.do',
|
|
|
'app_id' => '2018101661696470',
|
|
|
'merchant_private_key' => config('private_key'),
|
...
|
...
|
@@ -174,15 +225,11 @@ class IndexController extends HomeBaseController |
|
|
'sign_type' => 'RSA'
|
|
|
];
|
|
|
|
|
|
$builder = [
|
|
|
'WIDsubject' => '购买',
|
|
|
'WIDout_trade_no' => '20181017256210',
|
|
|
'WIDtotal_amount' => 99,
|
|
|
'WIDbody' => '商品'
|
|
|
];
|
|
|
$alipay = new \AlipayTradeService($alipay_config);
|
|
|
$return = $alipay->wapPay($builder, '', '');
|
|
|
print_r($return);
|
|
|
$payResponse = new AlipayTradeService($config);
|
|
|
$result = $payResponse->wapPay($payRequestBuilder, $config['return_url'], $config['notify_url']);
|
|
|
|
|
|
print_r($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|