File tree Expand file tree Collapse file tree 5 files changed +13
-29
lines changed Expand file tree Collapse file tree 5 files changed +13
-29
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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     */ 
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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'); 
Original file line number Diff line number Diff line change 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 ' );
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments