Omnipay\Alipay\Tests\AopAppGatewayTest::testCompletePurchaseReturn PHP Метод

testCompletePurchaseReturn() публичный Метод

    public function testCompletePurchaseReturn()
    {
        $testPrivateKey = ALIPAY_ASSET_DIR . '/dist/common/rsa_private_key.pem';
        $testPublicKey = ALIPAY_ASSET_DIR . '/dist/common/rsa_public_key.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');
        $data = ['memo' => '', 'result' => '{\\"alipay_trade_app_pay_response\\":{\\"code\\":\\"10000\\",\\"msg\\":\\"Success\\",\\"app_id\\":\\"20151128008123456\\",\\"auth_app_id\\":\\"20151128008123456\\",\\"charset\\":\\"UTF-8\\",\\"timestamp\\":\\"2016-09-23 18:32:16\\",\\"total_amount\\":\\"0.01\\",\\"trade_no\\":\\"2016092321001003060123456789\\",\\"seller_id\\":\\"2088011466123456789\\",\\"out_trade_no\\":\\"201609231231447556\\"},\\"sign\\":\\"Q5n3zKIBzhBobd6Z6mP69ZvaBlVxkWOiti2ZCRBRhfEH8/sCWE89Iev94K++QH8W9Zakn9dXTq2tR0O5UWLS1XXgiSd+vUTMQNksxjddI39MQnbJ1hxEtwP5GcWzxeY9YRjXXJdzgdf/xmRS7uRQWv52cGYStlCNN/dianZmuDk=\\",\\"sign_type\\":\\"RSA\\"}', 'resultStatus' => '9000'];
        $result = json_decode(stripslashes($data['result']), true);
        $signer = new Signer($result['alipay_trade_app_pay_response']);
        $signer->setSort(false);
        $signer->setEncodePolicy(Signer::ENCODE_POLICY_JSON);
        $result['sign'] = $signer->signWithRSA($testPrivateKey);
        $result['sign_type'] = 'RSA';
        $result = addslashes(json_encode($result));
        $data['result'] = $result;
        $this->gateway->setAlipayPublicKey($testPublicKey);
        /**
         * @var AopCompletePurchaseResponse $response
         */
        $response = $this->gateway->completePurchase(['params' => $data])->send();
        $this->assertEquals('{"code":"10000","msg":"Success","app_id":"20151128008123456","auth_app_id":"20151128008123456","charset":"UTF-8","timestamp":"2016-09-23 18:32:16","total_amount":"0.01","trade_no":"2016092321001003060123456789","seller_id":"2088011466123456789","out_trade_no":"201609231231447556","sign":"jdl2MwvZLETOGMCrBvFuIHBlg+DUdd3fsuOqZWr78i1MRLoWOYWGoZNionb9hlW\\/UwsRJU8D5Su1LgVADpQH9K\\/yTjSH6eMQ4uZ+92QLsmeJxWWW2q85Ah36SULKMrJQDoap\\/zWAl\\/RV56BH8QpzBIPzby9idkt9VCIbIcSTaA0=","sign_type":"RSA"}', json_encode($response->data()));
        $this->assertEquals('201609231231447556', $response->data('out_trade_no'));
        $this->assertTrue($response->isSuccessful());
        $this->assertTrue($response->isPaid());
        $this->assertEquals('2016092321001003060123456789', $response->getData()['trade_no']);
    }