|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Helper\Baofu;
|
|
|
|
|
|
|
|
use App\Helper\StringHelper;
|
|
|
|
|
|
|
|
class Baofu
|
|
|
|
{
|
|
|
|
use Common;
|
|
|
|
|
|
|
|
const OK = 'OK';
|
|
|
|
const FAIL = 'FAIL';
|
|
|
|
const PEYMENT_PAID_TYPE = [
|
|
|
|
'WECHAT_JSGZH' => 2,//'微信公众号支付',
|
|
|
|
// 'WECHAT_JSXCX' => '微信小程序支付',
|
|
|
|
// 'ALIPAY_ALSHH' => '支付宝生活号支付',
|
|
|
|
// 'ALIPAY_ALXCX' => '支付宝小程序支付',
|
|
|
|
'ALIPAY_NATIVE' => 1 //'支付宝主扫'
|
|
|
|
];
|
|
|
|
|
|
|
|
public function apply($loginNo, $email, $token) {
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['email'] = $email;
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl('apply', $token);
|
|
|
|
return $this->pc('apply', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function register($loginNo, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['dataContent'] = NotifyList::getNotifyUrl('register', $token);
|
|
|
|
return $this->h5('register', $data, $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function cardBind($loginNo, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['dataContent'] = NotifyList::getNotifyUrl('card-bind', $token);
|
|
|
|
return $this->h5('card-bind', $data, $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function cardUnbind($loginNo, $agreementNo, $requestNo = '')
|
|
|
|
{
|
|
|
|
if (empty($requestNo)) {
|
|
|
|
$requestNo = StringHelper::generateOrderNo(StringHelper::ORDER_NO_TYPE_UNBIND_CARD);
|
|
|
|
}
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['requestNo'] = $requestNo;
|
|
|
|
$data['agreementNo'] = $agreementNo;
|
|
|
|
return $this->api('unbind-card', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBalance($loginNo)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['accountType'] = 'BALANCE';
|
|
|
|
return $this->api('get-balance-new', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function withdraw($params, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['amount'] = $params['amount'];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath());
|
|
|
|
$data['outOrderNo'] = $params['outOrderNo'];
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl($params['notifyUrl'], $token);
|
|
|
|
return $this->withReturnUrl($this->api('withdraw', $data, $token), $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assurePaymentSplit($params, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['amount'] = $params['amount'];
|
|
|
|
$data['outOrderNo'] = $params['outOrderNo'];
|
|
|
|
$data['paidType'] = $params['paidType'] ?: 'CARD';
|
|
|
|
$data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath());
|
|
|
|
$data['splitInfoList'] = json_encode($params['splitInfoList']);
|
|
|
|
$data['expireDate'] = date('YmdHis', time() + 15*60);
|
|
|
|
$data['validDate'] = date('Ymd');
|
|
|
|
$data['notifyUrl'] = $params['notifyUrl'];
|
|
|
|
return $this->withReturnUrl($this->api('assure-payment-split', $data), $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function paymentSplit($params, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['amount'] = $params['amount'];
|
|
|
|
$data['outOrderNo'] = $params['outOrderNo'];
|
|
|
|
$data['paidType'] = $params['paidType'] ?: 'CARD';
|
|
|
|
$data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath());
|
|
|
|
$data['splitInfoList'] = json_encode($params['splitInfoList']);
|
|
|
|
$data['pwdPayExpTime'] = $params['pwdPayExpTime'];
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl('payment', $token);
|
|
|
|
return $this->withReturnUrl($this->api('payment-split', $data), $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function unifyPay($params){
|
|
|
|
$dataContent = [
|
|
|
|
'goodsName' => $params['goodsName'],
|
|
|
|
'amount' => $params['amount'],
|
|
|
|
'outOrderNo' => $params['outOrderNo'],
|
|
|
|
'expireDate' => date('YmdHis', time() + 15*60),
|
|
|
|
'notifyUrl' => $params['notifyUrl'],
|
|
|
|
'splitInfoList' => $params['splitInfoList'],
|
|
|
|
'paidType' => $params['paidType'],
|
|
|
|
'validDate' => date('Ymd'),
|
|
|
|
];
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['orderType'] = 'SPLIT_PAY';
|
|
|
|
$data['dataContent'] = json_encode($dataContent);
|
|
|
|
// 1.微信支付(公众号、小程序)需填公众号授权获取微信用户openid
|
|
|
|
// 2.支付宝支付(生活号、小程序)需填生活号授权获取支付宝用户userid
|
|
|
|
// 3.支付宝主扫可不填写
|
|
|
|
$data['channelId'] = $params['channelId'] ?: '';
|
|
|
|
$data['forbidCredit'] = $params['forbidCredit'] ? 1 : 0;
|
|
|
|
$data['simId'] = $params['simId'] ?: $this->getSimID($params['paidType']);
|
|
|
|
$data['isRaw'] = 0;
|
|
|
|
$data['appId'] = $params['appId'] ?: '';
|
|
|
|
$data['anonymityPayRemark'] = $params['anonymityPayRemark'];
|
|
|
|
|
|
|
|
$res = base64_decode($this->api('unifyPay', $data)['data']);
|
|
|
|
if(self::PEYMENT_PAID_TYPE[$params['paidType']]){
|
|
|
|
$res = json_decode($res, true);
|
|
|
|
if($res['body']){
|
|
|
|
return $res['body'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function cloudB2cAssureRecharge($params){
|
|
|
|
$dataContent = [
|
|
|
|
'goodsName' => $params['goodsName'],
|
|
|
|
'amount' => $params['amount'],
|
|
|
|
'outOrderNo' => $params['outOrderNo'],
|
|
|
|
'notifyUrl' => $params['notifyUrl'],
|
|
|
|
'splitInfoList' => $params['splitInfoList'],
|
|
|
|
'expireDate' => date('YmdHis', time() + 15*60),
|
|
|
|
'validDate' => date('Ymd'),
|
|
|
|
];
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['payId'] = $params['payId'];
|
|
|
|
$data['dataContent'] = json_encode($dataContent);
|
|
|
|
return $this->api('cloud-b2c-assure-recharge', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function payment($params, $type = 'ASSURE_PAYMENT')
|
|
|
|
{
|
|
|
|
$dataContent = [
|
|
|
|
'goodsName' => $params['goodsName'],
|
|
|
|
'amount' => $params['amount'],
|
|
|
|
'outOrderNo' => $params['outOrderNo'],
|
|
|
|
'expireDate' => date('YmdHis', time() + 15*60),
|
|
|
|
'notifyUrl' => $params['notifyUrl'],
|
|
|
|
'splitInfoList' => $params['splitInfoList'],
|
|
|
|
'paidType' => $params['paidType'],
|
|
|
|
'validDate' => date('Ymd'),
|
|
|
|
];
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['simId'] = $this->getSimID($params['paidType']);
|
|
|
|
// 1.微信支付(公众号、小程序)需填公众号授权获取微信用户openid
|
|
|
|
// 2.支付宝支付(生活号、小程序)需填生活号授权获取支付宝用户userid
|
|
|
|
// 其余时间不传
|
|
|
|
$data['chanalId'] = $params['chanalId'] ?: '';
|
|
|
|
$data['dataContent'] = json_encode($dataContent);
|
|
|
|
// 1.微信支付(公众号、小程序)需填公众号授权获取微信的appid
|
|
|
|
// 2.支付宝支付(生活号、小程序)需填生活号授权获取支付宝的appid
|
|
|
|
// 支付宝主扫 不需要
|
|
|
|
$data['appId'] = $params['appId'] ?: '';
|
|
|
|
$data['isRaw'] = 0;
|
|
|
|
$data['callType'] = $type;
|
|
|
|
|
|
|
|
$res = base64_decode($this->api('payment', $data));
|
|
|
|
if(self::PEYMENT_PAID_TYPE[$params['paidType']]){
|
|
|
|
$res = json_decode($res, true);
|
|
|
|
if($res['body']){
|
|
|
|
return $res['body'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function recharge($params, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['amount'] = $params['amount'];
|
|
|
|
$data['outOrderNo'] = $params['outOrderNo'];
|
|
|
|
$data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath());
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl('recharge', $token);
|
|
|
|
return $this->withReturnUrl($this->api('recharge', $data), $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function merchantTransferRecharge($params, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['amount'] = $params['amount'];
|
|
|
|
$data['outOrderNo'] = $params['outOrderNo'];
|
|
|
|
$data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath());
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl('recharge', $token);
|
|
|
|
return $this->api('merchant-transfer-recharge', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function confirmAssurePay($params)
|
|
|
|
{
|
|
|
|
$dataContent = [
|
|
|
|
'amount' => $params['amount'],
|
|
|
|
'outOrderNo' => $params['outOrderNo'],
|
|
|
|
'assureConfirmSplitInfoList' => $params['assureConfirmSplitInfoList'],
|
|
|
|
'oldOutOrderNo' => $params['oldOutOrderNo'],
|
|
|
|
];
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['dataContent'] = json_encode($dataContent);
|
|
|
|
$data['notifyUrl'] = $params['notifyUrl'];
|
|
|
|
return $this->api('confirm-assure-pay', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function findBindBankCards($params)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['contractNo'] = $params['contractNo'];
|
|
|
|
$data['tradeType'] = 'BASE_LIST';
|
|
|
|
return $this->api('find-bind-bank-cards', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function queryCustomerInfo($loginNo, $customerType = 'PERSON')
|
|
|
|
{
|
|
|
|
$requestNo = StringHelper::generateOrderNo(StringHelper::ORDER_NO_TYPE_QUERY_CUSTOMER_INFO);
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['customerType'] = $customerType;
|
|
|
|
$data['requestNo'] = $requestNo;
|
|
|
|
$result = $this->api('query-customer-info', $data);
|
|
|
|
return json_decode($result, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pwdModify($loginNo, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
return $this->h5('pwd-modify', $data, $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function enterprisePwdModify($loginNo, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
return $this->h5('enterprise-pwd-modify', $data, $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pwdForget($loginNo, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
return $this->h5('pwd-forget', $data, $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pwReset($loginNo, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
return $this->h5('pw-reset', $data, $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function refund($params, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['refundTradeId'] = $params['refundTradeId'];
|
|
|
|
$data['orgTradeId'] = $params['orgTradeId'];
|
|
|
|
$data['refundMoney'] = $params['refundMoney'];
|
|
|
|
$data['refundReason'] = $params['refundReason'];
|
|
|
|
if ($params['refundSplitInfoList']) {
|
|
|
|
$data['refundSplitInfoList'] = json_encode($params['refundSplitInfoList']);
|
|
|
|
} else {
|
|
|
|
$data['oldSubOutOrderNo'] = $params['oldSubOutOrderNo'];
|
|
|
|
}
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl('refund', $token);
|
|
|
|
return $this->api('refund-request', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function modifyLoginNo($origLoginNo, $loginNo)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['origLoginNo'] = $origLoginNo;
|
|
|
|
return $this->api('modify-login-no', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function enterpriseUnbindCard($loginNo, $agreementNo, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['agreementNo'] = $agreementNo;
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl('enterprise-unbind-card', $token);
|
|
|
|
return $this->api('enterprise-unbind-card', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sendBindCardEmail($loginNo)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
return $this->api('send-bind-card-email',$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function applyBindCard($loginNo, $info, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['cardNo'] = BFRSA::encryptByCERFile($info['cardNo'], config('baofu.cerFilePath'));
|
|
|
|
$data['cardName'] = $info['cardName'];
|
|
|
|
$data['bankName'] = $info['bankName'];
|
|
|
|
$data['branchName'] = $info['branchName'];
|
|
|
|
$data['provinceName'] = $info['provinceName'];
|
|
|
|
$data['cityName'] = $info['cityName'];
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl('apply-bind-card', $token);
|
|
|
|
return $this->api('apply-bind-card' ,$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function openAccount($loginNo, $info)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['customerName'] = BFRSA::encryptByCERFile($info['customerName'], config('baofu.cerFilePath'));
|
|
|
|
$data['certificateNo'] = BFRSA::encryptByCERFile($info['certificateNo'], config('baofu.cerFilePath'));
|
|
|
|
$data['base64imageFront'] = $info['imageFront'];
|
|
|
|
$data['base64imageBack'] = $info['imageBack'];
|
|
|
|
return $this->api('open-account', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bindCard($loginNo, $info, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['cardNo'] = BFRSA::encryptByCERFile($info['cardNo'], config('baofu.cerFilePath'));
|
|
|
|
$data['bankMobile'] = BFRSA::encryptByCERFile($info['bankMobile'], config('baofu.cerFilePath'));
|
|
|
|
$data['notifyUrl'] = NotifyList::getNotifyUrl('card-bind', $token);
|
|
|
|
return $this->api('bind-card',$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function fixedBinding($loginNo, $info, $token)
|
|
|
|
{
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $loginNo;
|
|
|
|
$data['requestNo'] = $info['requestNo'];
|
|
|
|
$data['verifyCode'] = $info['verifyCode'];
|
|
|
|
$result = $this->api('bind-card-check', $data);
|
|
|
|
return $this->withReturnUrl($result['url'], $token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function profitShareRefundApply($params){
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'] ?: '';// 匿名支付不需要传
|
|
|
|
$data['refundTradeId'] = $params['refundTradeId'];
|
|
|
|
$data['refundTradeType'] = 'REFUND_APPLY';
|
|
|
|
$data['orgTradeId'] = $params['orgTradeId'];
|
|
|
|
$data['refundAmount'] = $params['refundAmount']; // 单位:分
|
|
|
|
$data['refundReason'] = $params['refundReason'];
|
|
|
|
$data['refundSplitInfoList'] = $params['refundSplitInfoList'];
|
|
|
|
return $this->api('profit-share-refund-apply', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function profitShareRefundConfirm($params){
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'] ?: '';// 匿名支付不需要传
|
|
|
|
$data['refundTradeId'] = $params['refundTradeId']; // 与退款申请中的退款请求订单号一致
|
|
|
|
$data['refundTradeType'] = 'REFUND_CONFIRM';
|
|
|
|
$data['orgTradeId'] = $params['orgTradeId']; // 原始支付商户订单号
|
|
|
|
$data['refundAmount'] = $params['refundAmount']; // 单位:分
|
|
|
|
$data['notifyUrl'] = $params['notifyUrl'];
|
|
|
|
return $this->api('profit-share-refund-confirm', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function profitShareRefundCancel($params){
|
|
|
|
$data = [];
|
|
|
|
$data['loginNo'] = $params['loginNo'] ?: '';// 匿名支付不需要传
|
|
|
|
$data['refundTradeId'] = $params['refundTradeId']; // 与退款申请中的退款请求订单号一致
|
|
|
|
$data['refundTradeType'] = 'REFUND_CANCEL';
|
|
|
|
return $this->api('profit-share-refund-cancel', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function merchantReportCreate($params){
|
|
|
|
$data = [];
|
|
|
|
$data['uniqueId'] = $params['uniqueId'];
|
|
|
|
$data['loginNo'] = $params['loginNo'];
|
|
|
|
$data['reportType'] = $params['reportType'];
|
|
|
|
$data['bizContent'] = json_encode([
|
|
|
|
'servicePhone' => $params['servicePhone'],
|
|
|
|
'businessLicense' => $params['businessLicense'],
|
|
|
|
'businessLicenseType' => $params['businessLicenseType'],
|
|
|
|
'merchantName' => $params['merchantName'],
|
|
|
|
'merchantShortName' => $params['merchantShortName'],
|
|
|
|
'channelId' => $this->getChannelId(),
|
|
|
|
'channelName' => $this->getChannelName(),
|
|
|
|
'business' => $params['business'],
|
|
|
|
'contactWechatIdType' => $params['contactWechatIdType'],
|
|
|
|
'contactWechatId' => $params['contactWechatId'],
|
|
|
|
'serviceCodes' => $params['serviceCodes'],
|
|
|
|
'addressInfo' => $params['addressInfo'],
|
|
|
|
'bankCardInfo' => $params['bankCardInfo']
|
|
|
|
]);
|
|
|
|
return $this->api('merchant-report-create', $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function authBind($params){
|
|
|
|
$data = [];
|
|
|
|
$data['simId'] = $params['simId'];
|
|
|
|
$data['authType'] = $params['authType'];
|
|
|
|
$data['authContent'] = $params['authContent'];
|
|
|
|
return $this->api('auth-bind', $data);
|
|
|
|
}
|
|
|
|
}
|