You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
payment/app/Helper/Efps/Api.php

260 lines
9.4 KiB
PHTML

2 years ago
<?php
namespace App\Helper\Efps;
use App\Helper\Efps\Request\UnifiedPaymentRequest;
2 years ago
use App\Helper\StringHelper;
2 years ago
2 years ago
class Api extends AbstractApi
2 years ago
{
1 year ago
public static function apply()
{
$paper = [
"certificateName" => "李四",
"contactPhone" => "13531231222",
"email" => "test1@test.cn",
"lawyerCertNo" => "430481198104234557",
"lawyerCertType" => "0",
"merchantType" => "3",
"openBank" => "中国银行",
"openingLicenseAccountPhoto" => "https://www.epaylinks.cn/www/wimages/epl_logo.png",
"settleAccount" => "李四",
"settleAccountNo" => "6214830201234567",
"settleAccountType" => "2",
"settleTarget" => "2"
];
$business = [
[
"businessCode" => "WITHDRAW_TO_SETTMENT_DEBIT",
"creditcardsEnabled" => 0,
"refundEnabled" => 1,
"refundFeePer" => 0,
"refundFeeRate" => 0,
"settleCycle" => "D+0",
"stage" => [
[
"amountFrom" => 0,
"feePer" => 50
]
]
]
];
$params = [
'acqSpId' => self::getConfig('customerCode'),
'merchantName' => "测试商户20211202",
'acceptOrder' => 0,
'openAccount' => 1,
'paper' => json_encode($paper, JSON_UNESCAPED_UNICODE),
'business' => $business
];
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
2 years ago
public static function register($params)
2 years ago
{
2 years ago
$merId = $params['merId'] ?? '';
$backUrl = $params['backUrl'] ?? '';
$certificateName = $params['certificateName'] ?? '';
$lawyerCertType = $params['lawyerCertType'] ?? 0;
$lawyerCertNo = $params['lawyerCertNo'] ?? '';
$lawyerCertPhotoFront = $params['lawyerCertPhotoFront'] ?? '';
$lawyerCertPhotoBack = $params['lawyerCertPhotoBack'] ?? '';
$certificateTo = $params['certificateTo'] ?? '';
$contactPhone = $params['contactPhone'] ?? '';
$accountType = $params['accountType'] ?? 3;
$canDownType = $params['canDownType'] ?? '01';
$uri = '/api/cust/SP/Personal/apply';
$params = [
'version' => '3.0',
'acqSpId' => self::getConfig('customerCode'),
'merId' => $merId,
'backUrl' => $backUrl,
'certificateName' => $certificateName,
'lawyerCertType' => $lawyerCertType,
'lawyerCertNo' => $lawyerCertNo,
'lawyerCertPhotoFront' => $lawyerCertPhotoFront,
'lawyerCertPhotoBack' => $lawyerCertPhotoBack,
'certificateTo' => $certificateTo,
'contactPhone' => $contactPhone,
'accountType' => $accountType,
'canDownType' => $canDownType,
];
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
public static function bindCard($params)
{
1 year ago
$memberId = $params['memberId'] ?? '';
2 years ago
$mchtOrderNo = $params['mchtOrderNo'] ?? StringHelper::generateOrderNo();
$userName = $params['userName'] ?? '';
$phoneNum = $params['phoneNum'] ?? '';
$bankCardNo = $params['bankCardNo'] ?? '';
$bankCardType = $params['bankCardType'] ?? '';
$certificatesNo = $params['certificatesNo'] ?? '';
$expired = $params['expired'] ?? '';
$cvn = $params['cvn'] ?? '';
$uri = '/api/txs/protocol/bindCard';
$params = [
1 year ago
'version' => '2.0',
2 years ago
'customerCode' => self::getConfig('customerCode'),
'mchtOrderNo' => $mchtOrderNo,
'memberId' => $memberId,
1 year ago
'isSendIssuer' => true,
2 years ago
'userName' => Signer::publicEncrypt($userName),
'phoneNum' => Signer::publicEncrypt($phoneNum),
'bankCardNo' => Signer::publicEncrypt($bankCardNo),
'bankCardType' => $bankCardType,
'certificatesType' => '01',
'certificatesNo' => Signer::publicEncrypt($certificatesNo),
'nonceStr' => StringHelper::getRandomString(32),
];
if ($bankCardType == 'credit') {
$params['expired'] = Signer::publicEncrypt($expired);
$params['cvn'] = Signer::publicEncrypt($cvn);
}
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
public static function bindCardConfirm($params)
{
$smsNo = $params['smsNo'] ?? '';
$smsCode = $params['smsCode'] ?? '';
$memberId = $params['memberId'] ?? '';
$uri = '/api/txs/protocol/bindCardConfirm';
$params = [
1 year ago
'version' => '2.0',
2 years ago
'customerCode' => self::getConfig('customerCode'),
'smsNo' => $smsNo,
'memberId' => $memberId,
'smsCode' => $smsCode,
'nonceStr' => StringHelper::getRandomString(32),
];
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
public static function unBindCard($params)
{
$protocol = $params['protocol'] ?? '';
$memberId = $params['memberId'] ?? '';
$uri = '/api/txs/protocol/unBindCard';
$params = [
1 year ago
'version' => '2.0',
2 years ago
'customerCode' => self::getConfig('customerCode'),
'protocol' => $protocol,
'memberId' => $memberId,
'nonceStr' => StringHelper::getRandomString(32),
];
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
public static function protocolPayPre($params)
{
$outTradeNo = $params['outTradeNo'] ?? StringHelper::generateOrderNo();
$protocol = $params['protocol'] ?? '';
$smsNo = $params['smsNo'] ?? '';
$smsCode = $params['smsCode'] ?? '';
$payAmount = $params['payAmount'] ?? 0;
$orderInfo = [];
$orderInfo['Id'] = $outTradeNo;
$orderInfo['businessType'] = '130001';
1 year ago
$orderInfo['goodsList'] = [['name' => 'pay', 'number' => '1', 'amount' => $payAmount]];
2 years ago
$uri = '/api/txs/protocol/protocolPayPre';
$params = [
'version' => '3.0',
'customerCode' => self::getConfig('customerCode'),
'outTradeNo' => $outTradeNo,
'orderInfo' => $orderInfo,
'payAmount' => $payAmount,
'payCurrency' => 'CNY',
'isInstalments' => 0,
1 year ago
'notifyUrl' => 'http://146.70.113.165:9501/notify/payment',
2 years ago
'transactionStartTime' => date('YmdHis'),
'nonceStr' => StringHelper::getRandomString(32),
];
1 year ago
if ($protocol) {
$params['protocol'] = $protocol;
} else {
$params['smsCode'] = $smsCode;
$params['smsNo'] = $smsNo;
}
2 years ago
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
public static function protocolPayConfirm($params)
{
$smsCode = $params['smsCode'] ?? '';
$protocol = $params['protocol'] ?? '';
$token = $params['token'] ?? '';
$uri = '/api/txs/protocol/protocolPayConfirm';
$params = [
'version' => '3.0',
'customerCode' => self::getConfig('customerCode'),
'token' => $token,
'protocol' => $protocol,
'smsCode' => $smsCode,
'nonceStr' => StringHelper::getRandomString(32),
];
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
2 years ago
}
1 year ago
public static function refund($params)
{
$uri = '/api/txs/pay/Refund/V2';
$outRefundNo = $params['outRefundNo'] ?? '';
$outTradeNo = $params['outTradeNo'] ?? '';
$refundAmount = $params['refundAmount'] ?? 0;
$amount = $params['amount'] ?? 0;
$remark = $params['remark'] ?? '';
$params = [
'customerCode' => self::getConfig('customerCode'),
'outRefundNo' => $outRefundNo,
'outTradeNo' => $outTradeNo,
'refundAmount' => $refundAmount,
'amount' => $amount,
'remark' => $remark,
1 year ago
'notifyUrl' => 'http://146.70.113.165:9501/notify/refund',
1 year ago
'nonceStr' => StringHelper::getRandomString(32),
];
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
public static function refundQuery($params)
{
$uri = '/api/txs/custPay/refundQuery';
$outRefundNo = $params['outRefundNo'] ?? '';
$params = [
'customerCode' => self::getConfig('customerCode'),
'outRefundNo' => $outRefundNo,
'nonceStr' => StringHelper::getRandomString(32),
];
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
1 year ago
public static function paymentQuery($params)
{
$uri = '/api/txs/pay/PaymentQuery';
$outTradeNo = $params['outTradeNo'] ?? '';
$params = [
'customerCode' => self::getConfig('customerCode'),
'outTradeNo' => $outTradeNo,
'nonceStr' => StringHelper::getRandomString(32),
];
$sign = Signer::sign(json_encode($params));
return self::request($uri, $params, $sign);
}
2 years ago
}