|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Helper\Efps;
|
|
|
|
|
|
|
|
use App\Helper\Efps\Request\UnifiedPaymentRequest;
|
|
|
|
use App\Helper\StringHelper;
|
|
|
|
|
|
|
|
class Api extends AbstractApi
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function register($params)
|
|
|
|
{
|
|
|
|
$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)
|
|
|
|
{
|
|
|
|
$memberId = $params['memberId'] ?? '';
|
|
|
|
$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 = [
|
|
|
|
'version' => '2.0',
|
|
|
|
'customerCode' => self::getConfig('customerCode'),
|
|
|
|
'mchtOrderNo' => $mchtOrderNo,
|
|
|
|
'memberId' => $memberId,
|
|
|
|
'isSendIssuer' => true,
|
|
|
|
'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 = [
|
|
|
|
'version' => '2.0',
|
|
|
|
'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 = [
|
|
|
|
'version' => '2.0',
|
|
|
|
'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';
|
|
|
|
$orderInfo['goodsList'] = [['name' => 'pay', 'number' => '1', 'amount' => $payAmount]];
|
|
|
|
|
|
|
|
$uri = '/api/txs/protocol/protocolPayPre';
|
|
|
|
$params = [
|
|
|
|
'version' => '3.0',
|
|
|
|
'customerCode' => self::getConfig('customerCode'),
|
|
|
|
'outTradeNo' => $outTradeNo,
|
|
|
|
'orderInfo' => $orderInfo,
|
|
|
|
'payAmount' => $payAmount,
|
|
|
|
'payCurrency' => 'CNY',
|
|
|
|
'isInstalments' => 0,
|
|
|
|
'notifyUrl' => 'http://146.70.113.165:9501/notify/payment',
|
|
|
|
'transactionStartTime' => date('YmdHis'),
|
|
|
|
'nonceStr' => StringHelper::getRandomString(32),
|
|
|
|
];
|
|
|
|
if ($protocol) {
|
|
|
|
$params['protocol'] = $protocol;
|
|
|
|
} else {
|
|
|
|
$params['smsCode'] = $smsCode;
|
|
|
|
$params['smsNo'] = $smsNo;
|
|
|
|
}
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
'notifyUrl' => 'http://146.70.113.165:9501/notify/refund',
|
|
|
|
'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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|