Browse Source

增加转账接口

master
wuliangbo 5 years ago
parent
commit
32dbb868e4
  1. 39
      src/Payment/Close/Client.php
  2. 40
      src/Payment/Fund/Client.php

39
src/Payment/Close/Client.php

@ -4,13 +4,13 @@ namespace EasyAlipay\Payment\Close;
use EasyAlipay\Kernel\AppClient; use EasyAlipay\Kernel\AppClient;
use EasyAlipay\Kernel\AppRequest; use EasyAlipay\Kernel\AppRequest;
use EasyAlipay\Payment\Model\AlipayFundTransUniTransferContentBuilder;
use EasyAlipay\Payment\Model\AlipayTradeCloseContentBuilder; use EasyAlipay\Payment\Model\AlipayTradeCloseContentBuilder;
class Client extends AppClient class Client extends AppClient
{ {
/** /**
* @param array $payload * 关闭订单
* @param string $out_trade_no
* @return \EasyAlipay\Kernel\Support\Collection * @return \EasyAlipay\Kernel\Support\Collection
* @throws \EasyAlipay\Kernel\Exceptions\BadRequestException * @throws \EasyAlipay\Kernel\Exceptions\BadRequestException
* @throws \EasyAlipay\Kernel\Exceptions\InvalidArgumentException * @throws \EasyAlipay\Kernel\Exceptions\InvalidArgumentException
@ -18,37 +18,14 @@ class Client extends AppClient
* @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
* @throws \GuzzleHttp\Exception\GuzzleException * @throws \GuzzleHttp\Exception\GuzzleException
*/ */
public function transfer(array $payload) public function close(string $out_trade_no)
{ {
//构造查询业务请求参数对象 //构造查询业务请求参数对象
$contentBuilder = new AlipayFundTransUniTransferContentBuilder(); $closeContentBuilder = new AlipayTradeCloseContentBuilder();
$contentBuilder->setOutBizNo($payload['out_biz_no']); $closeContentBuilder->setOutTradeNo($out_trade_no);
$contentBuilder->setTransAmount($payload['trans_amount']);
$contentBuilder->setIdentity($payload['identity']);
if (isset($payload['identity_type'])) {
$contentBuilder->setIdentity($payload['identity_type']);
}
if (isset($payload['name'])) {
$contentBuilder->setIdentityName($payload['name']);
}
if (isset($payload['remark'])) {
$contentBuilder->setRemark($payload['remark']);
}
if (isset($payload['biz_scene'])) {
$contentBuilder->setBizScene($payload['biz_scene']);
}
if (isset($payload['order_title'])) {
$contentBuilder->setOrderTitle($payload['order_title']);
}
if (isset($payload['original_order_id'])) {
$contentBuilder->setOriginalOrderId($payload['original_order_id']);
}
if (isset($payload['business_params'])) {
$contentBuilder->setBusinessParams($payload['business_params']);
}
$request = new AppRequest (); $request = new AppRequest ();
$request->setBizContent($contentBuilder->getBizContent()); $request->setBizContent($closeContentBuilder->getBizContent());
$request->setApiMethodName("alipay.fund.trans.uni.transfer"); $request->setApiMethodName("alipay.trade.close");
return ($this->execute($request)); return($this->execute($request)) ;
} }
} }

40
src/Payment/Fund/Client.php

@ -4,13 +4,12 @@ namespace EasyAlipay\Payment\Fund;
use EasyAlipay\Kernel\AppClient; use EasyAlipay\Kernel\AppClient;
use EasyAlipay\Kernel\AppRequest; use EasyAlipay\Kernel\AppRequest;
use EasyAlipay\Payment\Model\AlipayTradeCloseContentBuilder; use EasyAlipay\Payment\Model\AlipayFundTransUniTransferContentBuilder;
class Client extends AppClient class Client extends AppClient
{ {
/** /**
* 关闭订单 * @param array $payload
* @param string $out_trade_no
* @return \EasyAlipay\Kernel\Support\Collection * @return \EasyAlipay\Kernel\Support\Collection
* @throws \EasyAlipay\Kernel\Exceptions\BadRequestException * @throws \EasyAlipay\Kernel\Exceptions\BadRequestException
* @throws \EasyAlipay\Kernel\Exceptions\InvalidArgumentException * @throws \EasyAlipay\Kernel\Exceptions\InvalidArgumentException
@ -18,14 +17,37 @@ class Client extends AppClient
* @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
* @throws \GuzzleHttp\Exception\GuzzleException * @throws \GuzzleHttp\Exception\GuzzleException
*/ */
public function close(string $out_trade_no) public function transfer(array $payload)
{ {
//构造查询业务请求参数对象 //构造查询业务请求参数对象
$closeContentBuilder = new AlipayTradeCloseContentBuilder(); $contentBuilder = new AlipayFundTransUniTransferContentBuilder();
$closeContentBuilder->setOutTradeNo($out_trade_no); $contentBuilder->setOutBizNo($payload['out_biz_no']);
$contentBuilder->setTransAmount($payload['trans_amount']);
$contentBuilder->setIdentity($payload['identity']);
if (isset($payload['identity_type'])) {
$contentBuilder->setIdentity($payload['identity_type']);
}
if (isset($payload['name'])) {
$contentBuilder->setIdentityName($payload['name']);
}
if (isset($payload['remark'])) {
$contentBuilder->setRemark($payload['remark']);
}
if (isset($payload['biz_scene'])) {
$contentBuilder->setBizScene($payload['biz_scene']);
}
if (isset($payload['order_title'])) {
$contentBuilder->setOrderTitle($payload['order_title']);
}
if (isset($payload['original_order_id'])) {
$contentBuilder->setOriginalOrderId($payload['original_order_id']);
}
if (isset($payload['business_params'])) {
$contentBuilder->setBusinessParams($payload['business_params']);
}
$request = new AppRequest (); $request = new AppRequest ();
$request->setBizContent($closeContentBuilder->getBizContent()); $request->setBizContent($contentBuilder->getBizContent());
$request->setApiMethodName("alipay.trade.close"); $request->setApiMethodName("alipay.fund.trans.uni.transfer");
return($this->execute($request)) ; return ($this->execute($request));
} }
} }

Loading…
Cancel
Save