Skip to content

Commit

Permalink
Merge pull request #1 from lvliujie/master
Browse files Browse the repository at this point in the history
 支付宝关闭接口支持
  • Loading branch information
wenqinruan authored Mar 22, 2018
2 parents 0bd24ae + e81493b commit 7f90672
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 7 deletions.
59 changes: 55 additions & 4 deletions src/AbstractAopGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@

use Omnipay\Alipay\Requests\AopCompletePurchaseRequest;
use Omnipay\Alipay\Requests\AopTradeCancelRequest;
use Omnipay\Alipay\Requests\AopTradeOrderSettleRequest;
use Omnipay\Alipay\Requests\AopTradeQueryRequest;
use Omnipay\Alipay\Requests\AopTradeRefundQueryRequest;
use Omnipay\Alipay\Requests\AopTradeRefundRequest;
use Omnipay\Alipay\Requests\DataServiceBillDownloadUrlQueryRequest;
use Omnipay\Common\AbstractGateway;
use Omnipay\Alipay\Requests\AopTradeCloseRequest;
use Omnipay\Common\Exception\InvalidRequestException;

abstract class AbstractAopGateway extends \Omnipay\Common\AbstractGateway
{
protected $endpoints = array('production' => 'https://openapi.alipay.com/gateway.do', 'sandbox' => 'https://openapi.alipaydev.com/gateway.do');

public function getDefaultParameters()
{
return array('format' => 'JSON', 'charset' => 'UTF-8', 'signType' => 'RSA', 'version' => '1.0', 'timestamp' => date('Y-m-d H:i:s'), 'alipaySdk' => 'lokielse/omnipay-alipay');
}

/**
* @return mixed
*/
public function getAppId()
{
return $this->getParameter('app_id');
}

/**
* @param $value
*
Expand All @@ -34,13 +36,15 @@ public function setAppId($value)
{
return $this->setParameter('app_id', $value);
}

/**
* @return mixed
*/
public function getFormat()
{
return $this->getParameter('format');
}

/**
* @param $value
*
Expand All @@ -50,13 +54,15 @@ public function setFormat($value)
{
return $this->setParameter('format', $value);
}

/**
* @return mixed
*/
public function getCharset()
{
return $this->getParameter('charset');
}

/**
* @param $value
*
Expand All @@ -66,13 +72,15 @@ public function setCharset($value)
{
return $this->setParameter('charset', $value);
}

/**
* @return mixed
*/
public function getSignType()
{
return $this->getParameter('sign_type');
}

/**
* @param $value
*
Expand All @@ -82,13 +90,15 @@ public function setSignType($value)
{
return $this->setParameter('sign_type', $value);
}

/**
* @return mixed
*/
public function getVersion()
{
return $this->getParameter('version');
}

/**
* @param $value
*
Expand All @@ -98,13 +108,15 @@ public function setVersion($value)
{
return $this->setParameter('version', $value);
}

/**
* @return mixed
*/
public function getPrivateKey()
{
return $this->getParameter('private_key');
}

/**
* @param $value
*
Expand All @@ -114,13 +126,15 @@ public function setPrivateKey($value)
{
return $this->setParameter('private_key', $value);
}

/**
* @return mixed
*/
public function getEncryptKey()
{
return $this->getParameter('encrypt_key');
}

/**
* @param $value
*
Expand All @@ -130,13 +144,15 @@ public function setEncryptKey($value)
{
return $this->setParameter('encrypt_key', $value);
}

/**
* @return mixed
*/
public function getNotifyUrl()
{
return $this->getParameter('notify_url');
}

/**
* @param $value
*
Expand All @@ -146,13 +162,15 @@ public function setNotifyUrl($value)
{
return $this->setParameter('notify_url', $value);
}

/**
* @return mixed
*/
public function getTimestamp()
{
return $this->getParameter('timestamp');
}

/**
* @param $value
*
Expand All @@ -162,13 +180,15 @@ public function setTimestamp($value)
{
return $this->setParameter('timestamp', $value);
}

/**
* @return mixed
*/
public function getAppAuthToken()
{
return $this->getParameter('app_auth_token');
}

/**
* @param $value
*
Expand All @@ -178,13 +198,15 @@ public function setAppAuthToken($value)
{
return $this->setParameter('app_auth_token', $value);
}

/**
* @return mixed
*/
public function getAlipayPublicKey()
{
return $this->getParameter('alipay_public_key');
}

/**
* @param $value
*
Expand All @@ -194,20 +216,23 @@ public function setAlipayPublicKey($value)
{
return $this->setParameter('alipay_public_key', $value);
}

/**
* @return mixed
*/
public function getEndpoint()
{
return $this->getParameter('endpoint');
}

/**
* @return mixed
*/
public function getAlipaySdk()
{
return $this->getParameter('alipay_sdk');
}

/**
* @param $value
*
Expand All @@ -217,14 +242,17 @@ public function setAlipaySdk($value)
{
return $this->setParameter('alipay_sdk', $value);
}

public function production()
{
return $this->setEnvironment('production');
}

/**
* @param $value
*
* @return $this
*
* @throws InvalidRequestException
*/
public function setEnvironment($value)
Expand All @@ -234,8 +262,10 @@ public function setEnvironment($value)
throw new \Omnipay\Common\Exception\InvalidRequestException('The environment is invalid');
}
$this->setEndpoint($this->endpoints[$env]);

return $this;
}

/**
* @param $value
*
Expand All @@ -245,20 +275,24 @@ public function setEndpoint($value)
{
return $this->setParameter('endpoint', $value);
}

public function sandbox()
{
return $this->setEnvironment('sandbox');
}

/**
* @param array $parameters
*
* @return AopCompletePurchaseRequest
*
* @throws InvalidRequestException
*/
public function completePurchase(array $parameters = array())
{
return $this->createRequest('Omnipay\\Alipay\\Requests\\AopCompletePurchaseRequest', $parameters);
}

/**
* Query Order Status
*
Expand All @@ -270,6 +304,7 @@ public function query(array $parameters = array())
{
return $this->createRequest('Omnipay\\Alipay\\Requests\\AopTradeQueryRequest', $parameters);
}

/**
* Refund
*
Expand All @@ -281,6 +316,7 @@ public function refund(array $parameters = array())
{
return $this->createRequest('Omnipay\\Alipay\\Requests\\AopTradeRefundRequest', $parameters);
}

/**
* Query Refund Status
*
Expand All @@ -292,6 +328,7 @@ public function refundQuery(array $parameters = array())
{
return $this->createRequest('Omnipay\\Alipay\\Requests\\AopTradeRefundQueryRequest', $parameters);
}

/**
* Cancel Order
*
Expand All @@ -303,6 +340,19 @@ public function cancel(array $parameters = array())
{
return $this->createRequest('Omnipay\\Alipay\\Requests\\AopTradeCancelRequest', $parameters);
}

/**
* Close Order
*
* @param array $parameters
*
* @return AopTradeCloseRequest
*/
public function close(array $parameters = array())
{
return $this->createRequest('Omnipay\\Alipay\\Requests\\AopTradeCloseRequest', $parameters);
}

/**
* Settle
*
Expand All @@ -314,6 +364,7 @@ public function settle(array $parameters = array())
{
return $this->createRequest('Omnipay\\Alipay\\Requests\\AopTradeOrderSettleRequest', $parameters);
}

/**
* @param array $parameters
*
Expand All @@ -323,4 +374,4 @@ public function queryBillDownloadUrl(array $parameters = array())
{
return $this->createRequest('Omnipay\\Alipay\\Requests\\DataServiceBillDownloadUrlQueryRequest', $parameters);
}
}
}
Loading

0 comments on commit 7f90672

Please sign in to comment.