Skip to content

Commit 71ed19f

Browse files
author
Success Go
authored
Merge pull request #169 from maxsky/master
Fixed public certificate no effect problem and test file content error.
2 parents ba6aac2 + 4c528fc commit 71ed19f

File tree

5 files changed

+13
-29
lines changed

5 files changed

+13
-29
lines changed

src/AbstractAopGateway.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ public function getAlipayPublicCert()
194194
*/
195195
public function setAlipayPublicCert($value)
196196
{
197+
$this->setParameter('alipay_public_key', getPublicKey($value));
198+
197199
return $this->setParameter('alipay_public_cert', $value);
198200
}
199201

@@ -354,7 +356,12 @@ public function getAlipayPublicKey()
354356
*/
355357
public function setAlipayPublicKey($value)
356358
{
357-
return $this->setParameter('alipay_public_key', $value);
359+
// prevent public key overlay when certificate exist
360+
if (!$this->getAlipayPublicCert()) {
361+
return $this->setParameter('alipay_public_key', $value);
362+
}
363+
364+
return $this;
358365
}
359366

360367

@@ -407,7 +414,7 @@ public function setEnvironment($value)
407414
{
408415
$env = strtolower($value);
409416

410-
if (! isset($this->endpoints[$env])) {
417+
if (!isset($this->endpoints[$env])) {
411418
throw new InvalidRequestException('The environment is invalid');
412419
}
413420

src/Requests/AbstractAopRequest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ abstract class AbstractAopRequest extends AbstractRequest
2222

2323
protected $alipayRootCert;
2424

25-
protected $alipayPublicCert;
26-
2725
protected $appCert;
2826

2927
protected $checkAlipayPublicCert = true;
@@ -89,7 +87,6 @@ public function getCertSN()
8987
if (is_file($alipayRootCert) && is_file($appCert)) {
9088
$this->setParameter('alipay_root_cert_sn', getRootCertSN($alipayRootCert));
9189
$this->setParameter('app_cert_sn', getCertSN($appCert));
92-
$this->setAlipayPublicKey(getPublicKey($this->getAlipayPublicCert()));
9390
}
9491
}
9592
}
@@ -203,28 +200,6 @@ public function setAlipayRootCert($value)
203200
}
204201

205202

206-
/**
207-
* @return mixed
208-
*/
209-
public function getAlipayPublicCert()
210-
{
211-
return $this->alipayPublicCert;
212-
}
213-
214-
215-
/**
216-
* @param $value
217-
*
218-
* @return $this
219-
*/
220-
public function setAlipayPublicCert($value)
221-
{
222-
$this->alipayPublicCert = $value;
223-
224-
return $this;
225-
}
226-
227-
228203
/**
229204
* @return mixed
230205
*/

tests/AbstractGatewayTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ abstract class AbstractGatewayTestCase extends GatewayTestCase
1616

1717
protected $appPrivateKey = ALIPAY_APP_PRIVATE_KEY;
1818

19+
protected $alipayPublicKey = ALIPAY_PUBLIC_KEY;
20+
1921
protected $appEncryptKey = ALIPAY_APP_ENCRYPT_KEY;
2022

2123

tests/AopAppGatewayTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function setUp()
2626
$this->gateway = new AopAppGateway($this->getHttpClient(), $this->getHttpRequest());
2727
$this->gateway->setAppId($this->appId);
2828
$this->gateway->setPrivateKey(ALIPAY_AOP_PRIVATE_KEY);
29-
//$this->gateway->setAlipayPublicKey(file_get_contents($this->appPrivateKey));
29+
//$this->gateway->setAlipayPublicKey(file_get_contents($this->alipayPublicKey));
3030
//$this->gateway->setEncryptKey($this->appEncryptKey);
3131
//$this->gateway->setNotifyUrl('http://www.guoshuzc.com/api/pay/alipay_recharge_notify');
3232
//$this->gateway->setAlipaySdk('alipay_sdk');

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
define('ALIPAY_PARTNER', '2088011436420182');
1919
define('ALIPAY_KEY', '18x8lAi0a1520st1hvxcnt7m4w1whkbs');
2020
define('ALIPAY_SELLER_ID', '2088011436420182');
21-
define('ALIPAY_PUBLIC_KEY', ALIPAY_ASSET_DIR . '/alipay_public_key.pem');
21+
define('ALIPAY_PUBLIC_KEY', ALIPAY_ASSET_DIR . '/dist/aop/alipay_public_key.pem');
2222
define('ALIPAY_LEGACY_PRIVATE_KEY', ALIPAY_ASSET_DIR . '/dist/legacy/rsa_private_key.pem');
2323
define('ALIPAY_LEGACY_PUBLIC_KEY', ALIPAY_ASSET_DIR . '/dist/legacy/alipay_public_key.pem');
2424
define('ALIPAY_AOP_PUBLIC_KEY', ALIPAY_ASSET_DIR . '/dist/aop/alipay_public_key.pem');

0 commit comments

Comments
 (0)