LegacyAppGatewayTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Omnipay\Alipay\Tests;
  3. use Omnipay\Alipay\Common\Signer;
  4. use Omnipay\Alipay\LegacyAppGateway;
  5. use Omnipay\Alipay\Responses\LegacyAppPurchaseResponse;
  6. use Omnipay\Alipay\Responses\LegacyCompletePurchaseResponse;
  7. class LegacyAppGatewayTest extends AbstractGatewayTestCase
  8. {
  9. /**
  10. * @var LegacyAppGateway $gateway
  11. */
  12. protected $gateway;
  13. protected $options;
  14. public function setUp()
  15. {
  16. parent::setUp();
  17. $this->gateway = new LegacyAppGateway($this->getHttpClient(), $this->getHttpRequest());
  18. }
  19. public function testCreateOrder()
  20. {
  21. $partner = '123456789';
  22. $privateKey = ALIPAY_ASSET_DIR . '/dist/common/rsa_private_key.pem';
  23. //$partner = ALIPAY_PARTNER;
  24. //$privateKey = ALIPAY_ASSET_DIR . '/dist/common/rsa_private_key.pem';
  25. $this->assertFileExists($privateKey);
  26. $this->gateway = new LegacyAppGateway($this->getHttpClient(), $this->getHttpRequest());
  27. $this->gateway->setPartner($partner);
  28. $this->gateway->setSellerId($partner);
  29. $this->gateway->setPrivateKey($privateKey);
  30. $this->gateway->setNotifyUrl('https://www.example.com/notify');
  31. $this->options = [
  32. 'out_trade_no' => '2014010122390001',
  33. //'out_trade_no' => date('YmdHis').mt_rand(1000,9999),
  34. 'subject' => 'test',
  35. 'total_fee' => '0.01',
  36. ];
  37. /**
  38. * @var LegacyAppPurchaseResponse $response
  39. */
  40. $response = $this->gateway->purchase($this->options)->send();
  41. $this->assertEquals('e16fdd8098c197201986cd9c3a8fb276', md5($response->getOrderString()));
  42. }
  43. }