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/Baofu/Baofu.php

428 lines
17 KiB
PHTML

1 year ago
<?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 //'支付宝主扫'
];
1 year ago
public function apply($loginNo, $email, $token) {
1 year ago
$data = [];
$data['loginNo'] = $loginNo;
$data['email'] = $email;
1 year ago
$data['notifyUrl'] = NotifyList::getNotifyUrl('apply', $token);
return $this->pc('apply', $data);
1 year ago
}
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;
1 year ago
$data['dataContent'] = NotifyList::getNotifyUrl('card-bind', $token);
return $this->h5('card-bind', $data, $token);
1 year ago
}
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;
1 year ago
return $this->api('unbind-card', $data);
1 year ago
}
public function getBalance($loginNo)
{
$data = [];
$data['loginNo'] = $loginNo;
$data['accountType'] = 'BALANCE';
1 year ago
return $this->api('get-balance-new', $data);
1 year ago
}
1 year ago
public function withdraw($params, $token)
1 year ago
{
$data = [];
$data['amount'] = $params['amount'];
$data['loginNo'] = $params['loginNo'];
$data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath());
$data['outOrderNo'] = $params['outOrderNo'];
1 year ago
$data['notifyUrl'] = NotifyList::getNotifyUrl($params['notifyUrl'], $token);
return $this->withReturnUrl($this->api('withdraw', $data, $token), $token);
1 year ago
}
1 year ago
public function assurePaymentSplit($params, $token)
1 year ago
{
$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'];
1 year ago
return $this->withReturnUrl($this->api('assure-payment-split', $data), $token);
1 year ago
}
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']);
1 year ago
$data['pwdPayExpTime'] = $params['pwdPayExpTime'];
$data['notifyUrl'] = NotifyList::getNotifyUrl('payment', $token);
return $this->withReturnUrl($this->api('payment-split', $data), $token);
1 year ago
}
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);
1 year ago
return $this->api('cloud-b2c-assure-recharge', $data);
1 year ago
}
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'];
}
}
}
1 year ago
public function recharge($params, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $params['loginNo'];
$data['amount'] = $params['amount'];
$data['outOrderNo'] = $params['outOrderNo'];
$data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath());
1 year ago
$data['notifyUrl'] = NotifyList::getNotifyUrl('recharge', $token);
return $this->withReturnUrl($this->api('recharge', $data), $token);
1 year ago
}
1 year ago
public function merchantTransferRecharge($params, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $params['loginNo'];
$data['amount'] = $params['amount'];
$data['outOrderNo'] = $params['outOrderNo'];
$data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath());
1 year ago
$data['notifyUrl'] = NotifyList::getNotifyUrl('recharge', $token);
return $this->api('merchant-transfer-recharge', $data);
1 year ago
}
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'];
1 year ago
return $this->api('confirm-assure-pay', $data);
1 year ago
}
public function findBindBankCards($params)
{
$data = [];
$data['loginNo'] = $params['loginNo'];
$data['contractNo'] = $params['contractNo'];
$data['tradeType'] = 'BASE_LIST';
1 year ago
return $this->api('find-bind-bank-cards', $data);
1 year ago
}
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;
1 year ago
$result = $this->api('query-customer-info', $data);
1 year ago
return json_decode($result, true);
}
1 year ago
public function pwdModify($loginNo, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
1 year ago
return $this->h5('pwd-modify', $data, $token);
1 year ago
}
1 year ago
public function enterprisePwdModify($loginNo, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
1 year ago
return $this->h5('enterprise-pwd-modify', $data, $token);
1 year ago
}
1 year ago
public function pwdForget($loginNo, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
1 year ago
return $this->h5('pwd-forget', $data, $token);
1 year ago
}
1 year ago
public function pwReset($loginNo, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
1 year ago
return $this->h5('pw-reset', $data, $token);
1 year ago
}
1 year ago
public function refund($params, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $params['loginNo'];
$data['refundTradeId'] = $params['refundTradeId'];
$data['orgTradeId'] = $params['orgTradeId'];
$data['refundMoney'] = $params['refundMoney'];
$data['refundReason'] = $params['refundReason'];
1 year ago
if ($params['refundSplitInfoList']) {
$data['refundSplitInfoList'] = json_encode($params['refundSplitInfoList']);
} else {
$data['oldSubOutOrderNo'] = $params['oldSubOutOrderNo'];
}
1 year ago
$data['notifyUrl'] = NotifyList::getNotifyUrl('refund', $token);
return $this->api('refund-request', $data);
1 year ago
}
public function modifyLoginNo($origLoginNo, $loginNo)
{
$data = [];
$data['loginNo'] = $loginNo;
$data['origLoginNo'] = $origLoginNo;
1 year ago
return $this->api('modify-login-no', $data);
1 year ago
}
1 year ago
public function enterpriseUnbindCard($loginNo, $agreementNo, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
$data['agreementNo'] = $agreementNo;
1 year ago
$data['notifyUrl'] = NotifyList::getNotifyUrl('enterprise-unbind-card', $token);
return $this->api('enterprise-unbind-card', $data);
1 year ago
}
1 year ago
public function sendBindCardEmail($loginNo)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
1 year ago
return $this->api('send-bind-card-email',$data);
1 year ago
}
1 year ago
public function applyBindCard($loginNo, $info, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
1 year ago
$data['cardNo'] = BFRSA::encryptByCERFile($info['cardNo'], config('baofu.cerFilePath'));
1 year ago
$data['cardName'] = $info['cardName'];
$data['bankName'] = $info['bankName'];
$data['branchName'] = $info['branchName'];
$data['provinceName'] = $info['provinceName'];
$data['cityName'] = $info['cityName'];
1 year ago
$data['notifyUrl'] = NotifyList::getNotifyUrl('apply-bind-card', $token);
return $this->api('apply-bind-card' ,$data);
1 year ago
}
1 year ago
public function openAccount($loginNo, $info)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
1 year ago
$data['customerName'] = BFRSA::encryptByCERFile($info['customerName'], config('baofu.cerFilePath'));
$data['certificateNo'] = BFRSA::encryptByCERFile($info['certificateNo'], config('baofu.cerFilePath'));
1 year ago
$data['base64imageFront'] = $info['imageFront'];
$data['base64imageBack'] = $info['imageBack'];
1 year ago
return $this->api('open-account', $data);
1 year ago
}
1 year ago
public function bindCard($loginNo, $info, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
1 year ago
$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);
1 year ago
}
1 year ago
public function fixedBinding($loginNo, $info, $token)
1 year ago
{
$data = [];
$data['loginNo'] = $loginNo;
$data['requestNo'] = $info['requestNo'];
$data['verifyCode'] = $info['verifyCode'];
1 year ago
$result = $this->api('bind-card-check', $data);
return $this->withReturnUrl($result['url'], $token);
}
1 year ago
public function profitShareRefundApply($params){
$data = [];
1 year ago
$data['loginNo'] = $params['loginNo'] ?: '';// 匿名支付不需要传
1 year ago
$data['refundTradeId'] = $params['refundTradeId'];
$data['refundTradeType'] = 'REFUND_APPLY';
$data['orgTradeId'] = $params['orgTradeId'];
$data['refundAmount'] = $params['refundAmount']; // 单位:分
$data['refundReason'] = $params['refundReason'];
$data['refundSplitInfoList'] = $params['refundSplitInfoList'];
1 year ago
return $this->api('profit-share-refund-apply', $data);
}
1 year ago
public function profitShareRefundConfirm($params){
$data = [];
1 year ago
$data['loginNo'] = $params['loginNo'] ?: '';// 匿名支付不需要传
1 year ago
$data['refundTradeId'] = $params['refundTradeId']; // 与退款申请中的退款请求订单号一致
$data['refundTradeType'] = 'REFUND_CONFIRM';
$data['orgTradeId'] = $params['orgTradeId']; // 原始支付商户订单号
$data['refundAmount'] = $params['refundAmount']; // 单位:分
$data['notifyUrl'] = $params['notifyUrl'];
1 year ago
return $this->api('profit-share-refund-confirm', $data);
}
1 year ago
public function profitShareRefundCancel($params){
$data = [];
1 year ago
$data['loginNo'] = $params['loginNo'] ?: '';// 匿名支付不需要传
1 year ago
$data['refundTradeId'] = $params['refundTradeId']; // 与退款申请中的退款请求订单号一致
$data['refundTradeType'] = 'REFUND_CANCEL';
1 year ago
return $this->api('profit-share-refund-cancel', $data);
1 year ago
}
public function merchantReportCreate($params){
$data = [];
$data['uniqueId'] = $params['uniqueId'];
$data['loginNo'] = $params['loginNo'];
$data['reportType'] = $params['reportType'];
$data['bizContent'] = json_encode([
1 year ago
'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']
1 year ago
]);
1 year ago
return $this->api('merchant-report-create', $data);
1 year ago
}
public function authBind($params){
$data = [];
$data['simId'] = $params['simId'];
$data['authType'] = $params['authType'];
$data['authContent'] = $params['authContent'];
1 year ago
return $this->api('auth-bind', $data);
1 year ago
}
}