Skip to content

Commit ba6aac2

Browse files
author
Success Go
authored
Merge pull request #168 from maxsky/master
Add certificate mode support and test code adjusted.
2 parents c1a9cbb + 8d6f98e commit ba6aac2

28 files changed

+641
-324
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
processing library for PHP. This package implements Alipay support for Omnipay.
1414

1515
> Cross-border Alipay payment please use [`lokielse/omnipay-global-alipay`](https://github.com/lokielse/omnipay-global-alipay)
16-
16+
1717
> Legacy Version please use [`"lokielse/omnipay-alipay": "dev-legacy"`](https://github.com/lokielse/omnipay-alipay/tree/legacy)
1818
1919
## Installation
@@ -44,13 +44,19 @@ The following gateways are provided by this package:
4444
* @var AopAppGateway $gateway
4545
*/
4646
$gateway = Omnipay::create('Alipay_AopPage');
47-
$gateway->setSignType('RSA2'); // RSA/RSA2/MD5
47+
$gateway->setSignType('RSA2'); // RSA/RSA2/MD5. Use certificate mode must set RSA2
4848
$gateway->setAppId('the_app_id');
4949
$gateway->setPrivateKey('the_app_private_key');
50-
$gateway->setAlipayPublicKey('the_alipay_public_key');
50+
$gateway->setAlipayPublicKey('the_alipay_public_key'); // Need not set this when used certificate mode
5151
$gateway->setReturnUrl('https://www.example.com/return');
5252
$gateway->setNotifyUrl('https://www.example.com/notify');
5353

54+
// Must set cert path if you used certificate mode
55+
//$gateway->setAlipayRootCert('the_alipay_root_cert'); // alipayRootCert.crt
56+
//$gateway->setAlipayPublicCert('the_alipay_public_cert'); // alipayCertPublicKey_RSA2.crt
57+
//$gateway->setAppCert('the_app_public_cert'); // appCertPublicKey.crt
58+
//$gateway->setCheckAlipayPublicCert(true);
59+
5460
/**
5561
* @var AopTradePagePayResponse $response
5662
*/

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
]
3030
},
3131
"require": {
32+
"ext-bcmath": "*",
3233
"ext-json": "*",
3334
"ext-openssl": "*",
3435
"omnipay/common": "^3.0",

src/AbstractAopGateway.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,86 @@ public function setPrivateKey($value)
158158
}
159159

160160

161+
/**
162+
* @return mixed
163+
*/
164+
public function getAlipayRootCert()
165+
{
166+
return $this->getParameter('alipay_root_cert');
167+
}
168+
169+
170+
/**
171+
* @param $value
172+
*
173+
* @return $this
174+
*/
175+
public function setAlipayRootCert($value)
176+
{
177+
return $this->setParameter('alipay_root_cert', $value);
178+
}
179+
180+
181+
/**
182+
* @return mixed
183+
*/
184+
public function getAlipayPublicCert()
185+
{
186+
return $this->getParameter('alipay_public_cert');
187+
}
188+
189+
190+
/**
191+
* @param $value
192+
*
193+
* @return $this
194+
*/
195+
public function setAlipayPublicCert($value)
196+
{
197+
return $this->setParameter('alipay_public_cert', $value);
198+
}
199+
200+
201+
/**
202+
* @return mixed
203+
*/
204+
public function getAppCert()
205+
{
206+
return $this->getParameter('app_cert');
207+
}
208+
209+
210+
/**
211+
* @param $value
212+
*
213+
* @return $this
214+
*/
215+
public function setAppCert($value)
216+
{
217+
return $this->setParameter('app_cert', $value);
218+
}
219+
220+
221+
/**
222+
* @return mixed
223+
*/
224+
public function getCheckAlipayPublicCert()
225+
{
226+
return $this->getParameter('check_alipay_public_cert');
227+
}
228+
229+
230+
/**
231+
* @param bool $value
232+
*
233+
* @return $this
234+
*/
235+
public function setCheckAlipayPublicCert($value)
236+
{
237+
return $this->setParameter('check_alipay_public_cert', $value);
238+
}
239+
240+
161241
/**
162242
* @return mixed
163243
*/

src/AbstractLegacyGateway.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Omnipay\Alipay\Requests\LegacyQueryRequest;
88
use Omnipay\Alipay\Requests\LegacyRefundRequest;
99
use Omnipay\Common\AbstractGateway;
10+
use Omnipay\Common\Message\AbstractRequest;
1011

1112
abstract class AbstractLegacyGateway extends AbstractGateway
1213
{
@@ -304,7 +305,7 @@ public function setAlipaySdk($value)
304305
/**
305306
* @param array $parameters
306307
*
307-
* @return \Omnipay\Alipay\Requests\LegacyCompletePurchaseRequest
308+
* @return LegacyCompletePurchaseRequest|AbstractRequest
308309
*/
309310
public function completePurchase(array $parameters = [])
310311
{
@@ -315,7 +316,7 @@ public function completePurchase(array $parameters = [])
315316
/**
316317
* @param array $parameters
317318
*
318-
* @return \Omnipay\Alipay\Requests\LegacyRefundRequest
319+
* @return LegacyRefundRequest|AbstractRequest
319320
*/
320321
public function refund(array $parameters = [])
321322
{
@@ -326,7 +327,7 @@ public function refund(array $parameters = [])
326327
/**
327328
* @param array $parameters
328329
*
329-
* @return \Omnipay\Alipay\Requests\LegacyRefundRequest
330+
* @return LegacyRefundRequest|AbstractRequest
330331
*/
331332
public function completeRefund(array $parameters = [])
332333
{
@@ -337,7 +338,7 @@ public function completeRefund(array $parameters = [])
337338
/**
338339
* @param array $parameters
339340
*
340-
* @return \Omnipay\Alipay\Requests\LegacyQueryRequest
341+
* @return LegacyQueryRequest|AbstractRequest
341342
*/
342343
public function query(array $parameters = [])
343344
{

src/AopAppGateway.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
namespace Omnipay\Alipay;
44

55
use Omnipay\Alipay\Requests\AopTradeAppPayRequest;
6+
use Omnipay\Common\Message\AbstractRequest;
7+
use Omnipay\Common\Message\RequestInterface;
68

79
/**
810
* Class AopAppGateway
11+
*
912
* @package Omnipay\Alipay
10-
* @link https://doc.open.alipay.com/docs/doc.htm?treeId=204&articleId=105051&docType=1
13+
* @link https://docs.open.alipay.com/204/105051
14+
* @method RequestInterface authorize(array $options = [])
15+
* @method RequestInterface completeAuthorize(array $options = [])
16+
* @method RequestInterface capture(array $options = [])
17+
* @method RequestInterface void(array $options = [])
18+
* @method RequestInterface createCard(array $options = [])
19+
* @method RequestInterface updateCard(array $options = [])
20+
* @method RequestInterface deleteCard(array $options = [])
1121
*/
1222
class AopAppGateway extends AbstractAopGateway
1323
{
@@ -26,7 +36,7 @@ public function getName()
2636
/**
2737
* @param array $parameters
2838
*
29-
* @return \Omnipay\Alipay\Requests\AopTradeAppPayRequest
39+
* @return AopTradeAppPayRequest|AbstractRequest
3040
*/
3141
public function purchase(array $parameters = [])
3242
{

src/AopF2FGateway.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44

55
use Omnipay\Alipay\Requests\AopTradePayRequest;
66
use Omnipay\Alipay\Requests\AopTradePreCreateRequest;
7+
use Omnipay\Common\Message\AbstractRequest;
8+
use Omnipay\Common\Message\RequestInterface;
79

810
/**
911
* Class AopF2FGateway
12+
*
1013
* @package Omnipay\Alipay
11-
* @link https://doc.open.alipay.com/docs/doc.htm?treeId=194&articleId=105072&docType=1
14+
* @link https://docs.open.alipay.com/194/105072
15+
* @method RequestInterface authorize(array $options = [])
16+
* @method RequestInterface completeAuthorize(array $options = [])
17+
* @method RequestInterface void(array $options = [])
18+
* @method RequestInterface createCard(array $options = [])
19+
* @method RequestInterface updateCard(array $options = [])
20+
* @method RequestInterface deleteCard(array $options = [])
1221
*/
1322
class AopF2FGateway extends AbstractAopGateway
1423
{
@@ -27,7 +36,7 @@ public function getName()
2736
/**
2837
* @param array $parameters
2938
*
30-
* @return \Omnipay\Alipay\Requests\AopTradePayRequest
39+
* @return AopTradePayRequest|AbstractRequest
3140
*/
3241
public function capture(array $parameters = [])
3342
{
@@ -38,7 +47,7 @@ public function capture(array $parameters = [])
3847
/**
3948
* @param array $parameters
4049
*
41-
* @return \Omnipay\Alipay\Requests\AopTradePreCreateRequest
50+
* @return AopTradePreCreateRequest|AbstractRequest
4251
*/
4352
public function purchase(array $parameters = [])
4453
{

src/AopJsGateway.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33
namespace Omnipay\Alipay;
44

55
use Omnipay\Alipay\Requests\AopTradeCreateRequest;
6+
use Omnipay\Common\Message\AbstractRequest;
7+
use Omnipay\Common\Message\RequestInterface;
68

79
/**
810
* Class AopJsGateway
11+
*
912
* @package Omnipay\Alipay
1013
* @link https://docs.open.alipay.com/api_1/alipay.trade.create
1114
* @link https://myjsapi.alipay.com/jsapi/native/trade-pay.html
15+
* @method RequestInterface authorize(array $options = array())
16+
* @method RequestInterface completeAuthorize(array $options = array())
17+
* @method RequestInterface capture(array $options = array())
18+
* @method RequestInterface void(array $options = array())
19+
* @method RequestInterface createCard(array $options = array())
20+
* @method RequestInterface updateCard(array $options = array())
21+
* @method RequestInterface deleteCard(array $options = [])
1222
*/
1323
class AopJsGateway extends AbstractAopGateway
1424
{
@@ -27,7 +37,7 @@ public function getName()
2737
/**
2838
* @param array $parameters
2939
*
30-
* @return \Omnipay\Common\Message\AbstractRequest
40+
* @return AbstractRequest
3141
*/
3242
public function purchase(array $parameters = [])
3343
{

src/AopPageGateway.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
namespace Omnipay\Alipay;
44

55
use Omnipay\Alipay\Requests\AopTradePagePayRequest;
6+
use Omnipay\Common\Message\AbstractRequest;
7+
use Omnipay\Common\Message\RequestInterface;
68

79
/**
810
* Class AopPageGateway
11+
*
912
* @package Omnipay\Alipay
10-
* @link https://doc.open.alipay.com/doc2/detail.htm?treeId=270&articleId=105901&docType=1
13+
* @link https://docs.open.alipay.com/api_1/alipay.trade.page.pay
14+
* @method RequestInterface authorize(array $options = array())
15+
* @method RequestInterface completeAuthorize(array $options = array())
16+
* @method RequestInterface capture(array $options = array())
17+
* @method RequestInterface void(array $options = array())
18+
* @method RequestInterface createCard(array $options = array())
19+
* @method RequestInterface updateCard(array $options = array())
20+
* @method RequestInterface deleteCard(array $options = [])
1121
*/
1222
class AopPageGateway extends AbstractAopGateway
1323
{
@@ -46,7 +56,7 @@ public function setReturnUrl($value)
4656
/**
4757
* @param array $parameters
4858
*
49-
* @return \Omnipay\Common\Message\AbstractRequest
59+
* @return AbstractRequest
5060
*/
5161
public function purchase(array $parameters = [])
5262
{

src/AopWapGateway.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
namespace Omnipay\Alipay;
44

55
use Omnipay\Alipay\Requests\AopTradeWapPayRequest;
6+
use Omnipay\Common\Message\AbstractRequest;
7+
use Omnipay\Common\Message\RequestInterface;
68

79
/**
810
* Class AopWapGateway
11+
*
912
* @package Omnipay\Alipay
10-
* @link https://doc.open.alipay.com/docs/doc.htm?treeId=203&articleId=105288&docType=1
13+
* @link https://docs.open.alipay.com/203/105288
14+
* @method RequestInterface authorize(array $options = [])
15+
* @method RequestInterface completeAuthorize(array $options = [])
16+
* @method RequestInterface capture(array $options = [])
17+
* @method RequestInterface void(array $options = [])
18+
* @method RequestInterface createCard(array $options = [])
19+
* @method RequestInterface updateCard(array $options = [])
20+
* @method RequestInterface deleteCard(array $options = [])
1121
*/
1222
class AopWapGateway extends AbstractAopGateway
1323
{
@@ -46,7 +56,7 @@ public function setReturnUrl($value)
4656
/**
4757
* @param array $parameters
4858
*
49-
* @return \Omnipay\Common\Message\AbstractRequest
59+
* @return AbstractRequest
5060
*/
5161
public function purchase(array $parameters = [])
5262
{

0 commit comments

Comments
 (0)