增加聚合支付托管下单
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Leady\YeePay\Commands;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Yeepay\Yop\Sdk\Service\Account\AccountClientBuilder;
|
||||
use Yeepay\Yop\Sdk\Service\Account\Model\AccountinfosQueryRequest;
|
||||
use Yeepay\Yop\Sdk\Service\Account\Model\AutoWithdrawRuleQueryRequest;
|
||||
@@ -44,7 +45,7 @@ class Account extends InitConfig
|
||||
{
|
||||
$request = new TransferB2bQueryRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setRequestNo($requestNo);
|
||||
->setRequestNo($requestNo);
|
||||
$response = $this->client->transferB2bQuery($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['returnCode'] == 'UA00000') {
|
||||
@@ -58,13 +59,13 @@ class Account extends InitConfig
|
||||
{
|
||||
$request = new TransferB2bOrderRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setRequestNo($data['requestNo'])
|
||||
->setFromMerchantNo(config('yeepay.merchantNo'))
|
||||
->setToMerchantNo($data['merchantNo'])
|
||||
->setOrderAmount($data['amount'])
|
||||
->setFeeChargeSide($data['chargeSide'])
|
||||
->setUsage($data['usage'])
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
->setRequestNo($data['requestNo'])
|
||||
->setFromMerchantNo(config('yeepay.merchantNo'))
|
||||
->setToMerchantNo($data['merchantNo'])
|
||||
->setOrderAmount($data['amount'])
|
||||
->setFeeChargeSide($data['chargeSide'])
|
||||
->setUsage($data['usage'])
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
$response = $this->client->transferB2bOrder($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['returnCode'] == 'UA00000') {
|
||||
@@ -91,9 +92,9 @@ class Account extends InitConfig
|
||||
{
|
||||
$request = new WithdrawCardBindRequest();
|
||||
$request->setMerchantNo($data['merchantNo'])
|
||||
->setBankCardType($data['bankCardType'])
|
||||
->setAccountNo($data['accountNo'])
|
||||
->setBankCode($data['bankCode']);
|
||||
->setBankCardType($data['bankCardType'])
|
||||
->setAccountNo($data['accountNo'])
|
||||
->setBankCode($data['bankCode']);
|
||||
$response = $this->client->withdrawCardBind($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['returnCode'] == 'UA00000') {
|
||||
@@ -107,8 +108,8 @@ class Account extends InitConfig
|
||||
{
|
||||
$request = new WithdrawCardModifyRequest();
|
||||
$request->setMerchantNo($data['merchantNo'])
|
||||
->setBankCardOperateType('CANCELLED')
|
||||
->setBindId($data['bindId']);
|
||||
->setBankCardOperateType('CANCELLED')
|
||||
->setBindId($data['bindId']);
|
||||
|
||||
$response = $this->client->withdrawCardModify($request);
|
||||
$result = $response->getResult();
|
||||
@@ -132,22 +133,33 @@ class Account extends InitConfig
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 付款-下单
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2024/4/1 10:38
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \Yeepay\Yop\Sdk\Exception\YopClientException
|
||||
*/
|
||||
public function PayOrder(array $data)
|
||||
{
|
||||
$request = new PayOrderRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setRequestNo($data['requestNo'])
|
||||
->setOrderAmount($data['amount'])
|
||||
->setFeeChargeSide('PAYEE')
|
||||
->setReceiveType('REAL_TIME')
|
||||
->setReceiverBankCode($data['receiverBankCode'])
|
||||
->setReceiverAccountNo($data['receiverAccountNo'])
|
||||
->setReceiverAccountName($data['receiverAccountName'])
|
||||
->setBankAccountType($data['bankAccountType'] ?? 'DEBIT_CARD')
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setRequestNo($data['requestNo'])
|
||||
->setOrderAmount($data['amount'])
|
||||
->setFeeChargeSide('PAYEE')
|
||||
->setReceiveType('REAL_TIME')
|
||||
->setFeeChargeSide('PAYEE')
|
||||
->setReceiverBankCode($data['receiverBankCode'] ?? '')
|
||||
->setReceiverAccountNo($data['receiverAccountNo'])
|
||||
->setReceiverAccountName($data['receiverAccountName'])
|
||||
->setBankAccountType($data['bankAccountType'] ?? 'DEBIT_CARD')
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
$response = $this->client->payOrder($request);
|
||||
$result = $response->getResult();
|
||||
Log::channel('yeepay')->info('PayOrder', $result);
|
||||
if ($result['returnCode'] == 'UA00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
@@ -159,12 +171,12 @@ class Account extends InitConfig
|
||||
{
|
||||
$request = new WithdrawOrderRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo($data['merchantNo'])
|
||||
->setRequestNo($data['requestNo'])
|
||||
->setBankCardId($data['bankCardId'])
|
||||
->setReceiveType('TWO_HOUR')
|
||||
->setOrderAmount($data['amount'])
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
->setMerchantNo($data['merchantNo'])
|
||||
->setRequestNo($data['requestNo'])
|
||||
->setBankCardId($data['bankCardId'])
|
||||
->setReceiveType('TWO_HOUR')
|
||||
->setOrderAmount($data['amount'])
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
$response = $this->client->withdrawOrder($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['returnCode'] == 'UA00000') {
|
||||
@@ -176,18 +188,18 @@ class Account extends InitConfig
|
||||
|
||||
public function AutoWithdrawRule(string $merchantNo)
|
||||
{
|
||||
try{
|
||||
$request=new AutoWithdrawRuleQueryRequest();
|
||||
try {
|
||||
$request = new AutoWithdrawRuleQueryRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo($merchantNo);
|
||||
$response=$this->client->autoWithdrawRuleQuery($request);
|
||||
$result=$response->getResult();
|
||||
$response = $this->client->autoWithdrawRuleQuery($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['returnCode'] == 'UA00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['returnMsg']);
|
||||
}
|
||||
}catch (Exception $e){
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,84 +5,123 @@ namespace Leady\YeePay\Commands;
|
||||
use Exception;
|
||||
use Yeepay\Yop\Sdk\Service\Aggpay\AggpayClientBuilder;
|
||||
use Yeepay\Yop\Sdk\Service\Aggpay\Model\PrePayRequest;
|
||||
use Yeepay\Yop\Sdk\Service\Aggpay\Model\TutelagePrePayRequest;
|
||||
use Yeepay\Yop\Sdk\Service\Aggpay\Model\WechatConfigAdd0Request;
|
||||
use Yeepay\Yop\Sdk\Service\Aggpay\Model\WechatConfigQuery0Request;
|
||||
|
||||
class Aggpay extends InitConfig
|
||||
{
|
||||
|
||||
protected $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->client = AggpayClientBuilder::builder($this->getSdkConfig())->build();
|
||||
}
|
||||
|
||||
public function PrePay(array $data)
|
||||
{
|
||||
try {
|
||||
$request = new PrePayRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setOrderId($data['orderId'] ?? '')
|
||||
->setOrderAmount($data['orderAmount'] ?? '')
|
||||
->setExpiredTime(now()->addMinutes(30)->toDateTimeString())
|
||||
->setNotifyUrl($data['notifyUrl'] ?? '')
|
||||
->setRedirectUrl($data['redirectUrl'] ?? '')
|
||||
->setMemo($data['memo'] ?? '')
|
||||
->setGoodsName($data['goodsName'] ?? '')
|
||||
->setPayWay($data['payWay'] ?? 'USER_SCAN')
|
||||
->setChannel($data['channel'] ?? '')
|
||||
->setUserIp($data['userIp'])
|
||||
->setFundProcessType($data['fundProcessType'] ?? 'REAL_TIME')
|
||||
->setAppId($data['appId'] ?? '')
|
||||
->setUserId($data['userId'] ?? '')
|
||||
->setScene('ONLINE');
|
||||
$response = $this->client->prePay($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['code'] == '00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['returnMsg']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function WechatConfig(array $data)
|
||||
{
|
||||
$url = $this->getJson($data['url'] ?? '');
|
||||
$appId = $this->getJson($data['appId'] ?? '');
|
||||
|
||||
$request = new WechatConfigAdd0Request();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setTradeAuthDirList($url)
|
||||
->setAppIdList($appId);
|
||||
$response = $this->client->wechatConfigAdd_0($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['code'] == '00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['returnMsg']);
|
||||
}
|
||||
}
|
||||
|
||||
public function WechatConfigQuery()
|
||||
{
|
||||
$request = new WechatConfigQuery0Request();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'));
|
||||
$response = $this->client->wechatConfigQuery_0($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['code'] == '00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['returnMsg']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->client = AggpayClientBuilder::builder($this->getSdkConfig())->build();
|
||||
}
|
||||
|
||||
public function PrePay(array $data)
|
||||
{
|
||||
try {
|
||||
$request = new PrePayRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setOrderId($data['orderId'] ?? '')
|
||||
->setOrderAmount($data['orderAmount'] ?? '')
|
||||
->setExpiredTime(now()->addMinutes(30)->toDateTimeString())
|
||||
->setNotifyUrl($data['notifyUrl'] ?? '')
|
||||
->setRedirectUrl($data['redirectUrl'] ?? '')
|
||||
->setMemo($data['memo'] ?? '')
|
||||
->setGoodsName($data['goodsName'] ?? '')
|
||||
->setPayWay($data['payWay'] ?? 'USER_SCAN')
|
||||
->setChannel($data['channel'] ?? '')
|
||||
->setUserIp($data['userIp'])
|
||||
->setFundProcessType($data['fundProcessType'] ?? 'REAL_TIME')
|
||||
->setAppId($data['appId'] ?? '')
|
||||
->setUserId($data['userId'] ?? '')
|
||||
->setScene('OFFLINE');
|
||||
|
||||
$response = $this->client->prePay($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['code'] == '00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['returnMsg']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 聚合支付托管下单
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2024/4/1 15:19
|
||||
*/
|
||||
public function tutelagePrePay(array $data)
|
||||
{
|
||||
$request = new TutelagePrePayRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setOrderId($data['orderId'] ?? '')
|
||||
->setOrderAmount($data['orderAmount'] ?? '')
|
||||
->setExpiredTime(now()->addMinutes(30)->toDateTimeString())
|
||||
->setNotifyUrl($data['notifyUrl'] ?? '')
|
||||
->setRedirectUrl($data['redirectUrl'] ?? '')
|
||||
->setMemo($data['memo'] ?? '')
|
||||
->setGoodsName($data['goodsName'] ?? '')
|
||||
->setPayWay($data['payWay'] ?? 'USER_SCAN')
|
||||
->setChannel($data['channel'] ?? '')
|
||||
->setUserIp($data['userIp'])
|
||||
->setToken($data['token'] ?? '')
|
||||
->setFundProcessType($data['fundProcessType'] ?? 'REAL_TIME')
|
||||
->setScene('OFFLINE');
|
||||
|
||||
try {
|
||||
$response = $this->client->tutelagePrePay($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['code'] == '00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['returnMsg']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function WechatConfig(array $data)
|
||||
{
|
||||
$url = $this->getJson($data['url'] ?? '');
|
||||
$appId = $this->getJson($data['appId'] ?? '');
|
||||
$request = new WechatConfigAdd0Request();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setTradeAuthDirList($url)
|
||||
->setAppIdList($appId);
|
||||
$response = $this->client->wechatConfigAdd_0($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['code'] == '00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['returnMsg']);
|
||||
}
|
||||
}
|
||||
|
||||
public function WechatConfigQuery(array $data)
|
||||
{
|
||||
$request = new WechatConfigQuery0Request();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setAppIdType($data['appIdType'] ?? '');
|
||||
$response = $this->client->wechatConfigQuery_0($request);
|
||||
$result = $response->getResult();
|
||||
if ($result['code'] == '00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['returnMsg']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,44 +3,144 @@
|
||||
namespace Leady\YeePay\Commands;
|
||||
|
||||
use Exception;
|
||||
use Yeepay\Yop\Sdk\Service\Trade\Model\OrderQueryRequest;
|
||||
use Yeepay\Yop\Sdk\Service\Trade\Model\OrderRequest;
|
||||
use Yeepay\Yop\Sdk\Service\Trade\Model\RefundQueryRequest;
|
||||
use Yeepay\Yop\Sdk\Service\Trade\Model\RefundRequest;
|
||||
use Yeepay\Yop\Sdk\Service\Trade\TradeClientBuilder;
|
||||
|
||||
class Trade extends InitConfig
|
||||
{
|
||||
|
||||
protected $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->client = TradeClientBuilder::builder($this->getSdkConfig())->build();
|
||||
}
|
||||
|
||||
public function order(array $data)
|
||||
{
|
||||
try {
|
||||
$request = new OrderRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setOrderId($data['order_id'])
|
||||
->setOrderAmount($data['amount'])
|
||||
->setGoodsName($data['goods_name'])
|
||||
->setFundProcessType($data['fundProcessType'] ?? 'REAL_TIME')
|
||||
->setExpiredTime($data['expiredTime'] ?? now()->addMinutes(30))
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
$respnonse = $this->client->order($request);
|
||||
|
||||
$result = $respnonse->getResult();
|
||||
if ($result['code'] == 'OPR00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['message']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->client = TradeClientBuilder::builder($this->getSdkConfig())->build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 统一下单
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2024/4/1 10:00
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function order(array $data)
|
||||
{
|
||||
try {
|
||||
$request = new OrderRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setOrderId($data['order_id'])
|
||||
->setOrderAmount($data['amount'])
|
||||
->setGoodsName($data['goods_name'])
|
||||
->setFundProcessType($data['fundProcessType'] ?? 'REAL_TIME')
|
||||
->setExpiredTime($data['expiredTime'] ?? now()->addMinutes(30))
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
$respnonse = $this->client->order($request);
|
||||
|
||||
$result = $respnonse->getResult();
|
||||
if ($result['code'] == 'OPR00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['message']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 查询订单
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2024/4/1 9:57
|
||||
* @param $orderId
|
||||
* @return array
|
||||
*/
|
||||
public function query($orderId)
|
||||
{
|
||||
try {
|
||||
$request = new OrderQueryRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setOrderId($orderId);
|
||||
|
||||
$respnonse = $this->client->orderQuery($request);
|
||||
|
||||
$result = $respnonse->getResult();
|
||||
if ($result['code'] == 'OPR00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['message']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 退款
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2024/4/1 10:01
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function refund(array $data)
|
||||
{
|
||||
try {
|
||||
$request = new RefundRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setOrderId($data['order_id'])
|
||||
->setRefundRequestId($data['refundRequestId'])
|
||||
->setRefundAmount($data['refundAmount'])
|
||||
->setDescription($data['description'] ?? '')
|
||||
->setNotifyUrl($data['notifyUrl']);
|
||||
|
||||
$respnonse = $this->client->refund($request);
|
||||
|
||||
$result = $respnonse->getResult();
|
||||
if ($result['code'] == 'OPR00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['message']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 查询退款状态
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2024/4/1 10:13
|
||||
*/
|
||||
public function refundQuery(array $data)
|
||||
{
|
||||
try {
|
||||
$request = new RefundQueryRequest();
|
||||
$request->setParentMerchantNo(config('yeepay.merchantNo'))
|
||||
->setMerchantNo(config('yeepay.merchantNo'))
|
||||
->setOrderId($data['order_id'])
|
||||
->setRefundRequestId($data['refundRequestId']);
|
||||
|
||||
$respnonse = $this->client->refundQuery($request);
|
||||
|
||||
$result = $respnonse->getResult();
|
||||
if ($result['code'] == 'OPR00000') {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error($result['message']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user