setSort() public method

public setSort ( boolean $sort ) : Signer
$sort boolean
return Signer
 protected function verifySignature()
 {
     $signer = new Signer($this->params->all());
     $signer->setSort($this->sort);
     $content = $signer->getContentToSign();
     $sign = $this->params->get('sign');
     $signType = strtoupper($this->params->get('sign_type'));
     if ($signType == 'MD5') {
         if (!$this->getKey()) {
             throw new InvalidRequestException('The `key` is required for `MD5` sign_type');
         }
         $match = (new Signer())->verifyWithMD5($content, $sign, $this->getKey());
     } elseif ($signType == 'RSA') {
         if (!$this->getAlipayPublicKey()) {
             throw new InvalidRequestException('The `alipay_public_key` is required for `RSA` sign_type');
         }
         $match = (new Signer())->verifyWithRSA($content, $sign, $this->getAlipayPublicKey());
     } else {
         throw new InvalidRequestException('The `sign_type` is invalid');
     }
     if (!$match) {
         throw new InvalidRequestException('The signature is not match');
     }
 }
 public function testCompletePurchaseNotifyWithInlineKey()
 {
     $testPrivateKey = ALIPAY_ASSET_DIR . '/dist/common/rsa_private_key.pem';
     $testPublicKey = ALIPAY_ASSET_DIR . '/dist/common/rsa_public_key_inline.pem';
     $this->gateway = new AopAppGateway($this->getHttpClient(), $this->getHttpRequest());
     $this->gateway->setAppId($this->appId);
     $this->gateway->setPrivateKey($this->appPrivateKey);
     $this->gateway->setNotifyUrl('https://www.example.com/notify');
     $str = '{"total_amount":"0.01","buyer_id":"20882025611234567","trade_no":"201609232100100306021234567","refund_fee":"0.00","notify_time":"2016-09-23 19:12:33","subject":"test","sign_type":"RSA","notify_type":"trade_status_sync","out_trade_no":"2016092313071234567","gmt_close":"2016-09-23 19:08:10","trade_status":"TRADE_FINISHED","gmt_payment":"2016-09-23 19:08:10","sign":"vCAj0n6vUVggDzZUqV4P2IucMeguUMaLBl5Uld7PeLHCo74/d3AcWCNCsGDxtW9Jm7+suyo6Y0jRY7OUi0PKZJre84m2q9Oo30AdgbMFRT91uZFYp9miJGWlQWwHhJDo3cU5iAYf5bnPPYgH8073kTFtmDPmrP9pvEUm3lsroUw=","gmt_create":"2016-09-23 19:08:09","app_id":"20151128001234567","seller_id":"20880114661234567","notify_id":"da3e56af64bcb163f167240dc0f781agge"}';
     $str = stripslashes($str);
     $data = json_decode($str, true);
     $signer = new Signer($data);
     $signer->setSort(true);
     $signer->setEncodePolicy(Signer::ENCODE_POLICY_QUERY);
     $data['sign'] = $signer->signWithRSA($testPrivateKey);
     $data['sign_type'] = 'RSA';
     $this->gateway->setAlipayPublicKey($testPublicKey);
     /**
      * @var AopCompletePurchaseResponse $response
      */
     $response = $this->gateway->completePurchase(['params' => $data])->send();
     $this->assertEquals('{"total_amount":"0.01","buyer_id":"20882025611234567","trade_no":"201609232100100306021234567","refund_fee":"0.00","notify_time":"2016-09-23 19:12:33","subject":"test","sign_type":"RSA","notify_type":"trade_status_sync","out_trade_no":"2016092313071234567","gmt_close":"2016-09-23 19:08:10","trade_status":"TRADE_FINISHED","gmt_payment":"2016-09-23 19:08:10","sign":"Xa2NyOsxOBjW\\/q\\/RUFZhii2epa4B3ka+2aGsG8knqkiCD8llXrTDm11QtGkSRVw\\/hbfcgFPiTkuaKnaaDu\\/UfypsVSHToy28PiH5xkBSSd6zHNZCP\\/jvjzOa6GPf4tIpfYNVvjaRMRcbn+TRlOFtHOnMMubjsg7K52P+LCugZIA=","gmt_create":"2016-09-23 19:08:09","app_id":"20151128001234567","seller_id":"20880114661234567","notify_id":"da3e56af64bcb163f167240dc0f781agge"}', json_encode($response->data()));
     $this->assertEquals('2016092313071234567', $response->data('out_trade_no'));
     $this->assertTrue($response->isSuccessful());
     $this->assertTrue($response->isPaid());
     $this->assertEquals('201609232100100306021234567', $response->getData()['trade_no']);
 }
 protected function verifySignature()
 {
     $signer = new Signer($this->params->all());
     $signer->setSort($this->sort);
     $signer->setEncodePolicy($this->encodePolicy);
     $content = $signer->getContentToSign();
     $sign = $this->params->get('sign');
     $match = (new Signer())->verifyWithRSA($content, $sign, $this->getAlipayPublicKey());
     if (!$match) {
         throw new InvalidRequestException('The signature is not match');
     }
 }
 public function testCompletePurchase()
 {
     $testPrivateKey = ALIPAY_ASSET_DIR . '/dist/common/rsa_private_key.pem';
     $testPublicKey = ALIPAY_ASSET_DIR . '/dist/common/rsa_public_key.pem';
     $this->gateway = new AopF2FGateway($this->getHttpClient(), $this->getHttpRequest());
     $this->gateway->setAppId($this->appId);
     $this->gateway->setPrivateKey($this->appPrivateKey);
     $this->gateway->setNotifyUrl('https://www.example.com/notify');
     $str = 'gmt_payment=2015-06-11 22:33:59&notify_id=42af7baacd1d3746cf7b56752b91edcj34&seller_email=testyufabu07@alipay.com&notify_type=trade_status_sync&sign=kPbQIjX+xQc8F0/A6/AocELIjhhZnGbcBN6G4MM/HmfWL4ZiHM6fWl5NQhzXJusaklZ1LFuMo+lHQUELAYeugH8LYFvxnNajOvZhuxNFbN2LhF0l/KL8ANtj8oyPM4NN7Qft2kWJTDJUpQOzCzNnV9hDxh5AaT9FPqRS6ZKxnzM=&trade_no=2015061121001004400068549373&out_trade_no=21repl2ac2eOutTradeNo322&gmt_create=2015-06-11 22:33:46&seller_id=2088211521646673&notify_time=2015-06-11 22:34:03&subject=FACE_TO_FACE_PAYMENT_PRECREATE中文&trade_status=TRADE_SUCCESS&sign_type=RSA';
     parse_str($str, $data);
     $signer = new Signer($data);
     $signer->setSort(true);
     $signer->setEncodePolicy(Signer::ENCODE_POLICY_QUERY);
     $data['sign'] = $signer->signWithRSA($testPrivateKey);
     $data['sign_type'] = 'RSA';
     $this->gateway->setAlipayPublicKey($testPublicKey);
     /**
      * @var AopCompletePurchaseResponse $response
      */
     $response = $this->gateway->completePurchase(['params' => $data])->send();
     $this->assertEquals('{"gmt_payment":"2015-06-11 22:33:59","notify_id":"42af7baacd1d3746cf7b56752b91edcj34","seller_email":"*****@*****.**","notify_type":"trade_status_sync","sign":"T4JCUXoO5sK\\/7UjupKEfsSQnjDnw\\/1aSJnC6s53SYJyqdjFl+1Lt8dWdNuuXl5yX39leQsYzmk2CDwZx6F\\/YIQWCo1LHZME3DYMqH\\/F5wT5uiSUk2KYsYbLluW9pi7YHtBXRWKB6jtnn73DWWbC2sN3tDky9KySPizL5jQ1Cd0I=","trade_no":"2015061121001004400068549373","out_trade_no":"21repl2ac2eOutTradeNo322","gmt_create":"2015-06-11 22:33:46","seller_id":"2088211521646673","notify_time":"2015-06-11 22:34:03","subject":"FACE_TO_FACE_PAYMENT_PRECREATE\\u4e2d\\u6587","trade_status":"TRADE_SUCCESS","sign_type":"RSA"}', json_encode($response->data()));
     $this->assertEquals('21repl2ac2eOutTradeNo322', $response->data('out_trade_no'));
     $this->assertTrue($response->isSuccessful());
     $this->assertTrue($response->isPaid());
     $this->assertEquals('2015061121001004400068549373', $response->getData()['trade_no']);
 }