php链接一网通支付,github/helei112g-payment: Payment是php版本的支付聚合第三方sdk,集成了微信支付、支付宝支付、招商一网通支付。提供统一的调用接口,方便快速接入...

/*

* The file is part of the payment lib.

*

* (c) Leo

*

* This source file is subject to the MIT license that is bundled

* with this source code in the file LICENSE.

*/

namespace Payment\Gateways\Alipay;

use Payment\Contracts\IGatewayRequest;

use Payment\Exceptions\GatewayException;

use Payment\Helpers\ArrayUtil;

/**

* @package Payment\Gateways\Alipay

* @author : Leo

* @email : dayugog@gmail.com

* @date : 2019/3/30 3:12 PM

* @version : 1.0.0

* @desc : 手机网站支付接口2.0

**/

class WapCharge extends AliBaseObject implements IGatewayRequest

{

const METHOD = 'alipay.trade.wap.pay';

/**

* @param array $requestParams

* @return mixed

*/

protected function getBizContent(array $requestParams)

{

$timeoutExp = '';

$timeExpire = intval($requestParams['time_expire']);

if (!empty($timeExpire)) {

$expire = floor(($timeExpire - time()) / 60);

($expire > 0) && $timeoutExp = $expire . 'm';// 超时时间 统一使用分钟计算

}

$bizContent = [

'body' => $requestParams['body'] ?? '',

'subject' => $requestParams['subject'] ?? '',

'out_trade_no' => $requestParams['trade_no'] ?? '',

'timeout_express' => $timeoutExp,

'time_expire' => $timeExpire ? date('Y-m-d H:i', $timeExpire) : '',

'total_amount' => $requestParams['amount'] ?? '',

'auth_token' => $requestParams['auth_token'] ?? '',

'goods_type' => $requestParams['goods_type'] ?? '',

'passback_params' => $requestParams['return_params'] ?? '',

'quit_url' => $requestParams['quit_url'] ?? '',

'product_code' => 'QUICK_WAP_WAY',

'promo_params' => $requestParams['promo_params'] ?? '',

'extend_params' => $requestParams['extend_params'] ?? '',

// 使用禁用列表

//'enable_pay_channels' => '',

'disable_pay_channels' => implode(self::$config->get('limit_pay', ''), ','),

'store_id' => $requestParams['store_id'] ?? '',

'specified_channel' => $requestParams['specified_channel'] ?? '',

'business_params' => $requestParams['business_params'] ?? '',

'ext_user_info' => $requestParams['ext_user_info'] ?? '',

];

$bizContent = ArrayUtil::paraFilter($bizContent);

return $bizContent;

}

/**

* 获取第三方返回结果

* @param array $requestParams

* @return mixed

* @throws GatewayException

*/

public function request(array $requestParams)

{

try {

$params = $this->buildParams(self::METHOD, $requestParams);

return sprintf('%s?%s', $this->gatewayUrl, http_build_query($params));

} catch (GatewayException $e) {

throw $e;

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值