LegacyQuickPayGatewayTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Omnipay\UnionPay\Tests;
  3. use Omnipay\Omnipay;
  4. use Omnipay\Tests\GatewayTestCase;
  5. use Omnipay\UnionPay\LegacyMobileGateway;
  6. use Omnipay\UnionPay\Message\LegacyQuickPayPurchaseResponse;
  7. class LegacyQuickPayGatewayTest extends GatewayTestCase
  8. {
  9. /**
  10. * @var LegacyMobileGateway $gateway
  11. */
  12. protected $gateway;
  13. protected $options;
  14. public function setUp()
  15. {
  16. parent::setUp();
  17. $this->gateway = Omnipay::create('UnionPay_LegacyQuickPay');
  18. $this->gateway->setMerId(UNIONPAY_MER_ID);
  19. $this->gateway->setSecretKey('xxxxxxx');
  20. $this->gateway->setReturnUrl('http://example.com/return');
  21. $this->gateway->setNotifyUrl('http://example.com/notify');
  22. $this->gateway->setEnvironment('production');
  23. }
  24. public function testPurchase()
  25. {
  26. $order = array(
  27. 'orderNumber' => date('YmdHis'), //Your order ID
  28. 'orderTime' => date('YmdHis'), //Should be format 'YmdHis'
  29. 'title' => 'My order title', //Order Title
  30. 'orderAmount' => '100', //Order Total Fee
  31. );
  32. /**
  33. * @var LegacyQuickPayPurchaseResponse $response
  34. */
  35. $response = $this->gateway->purchase($order)->send();
  36. $this->assertTrue($response->isSuccessful());
  37. $this->assertTrue($response->isRedirect());
  38. }
  39. public function testCompletePurchase()
  40. {
  41. $options = array(
  42. 'request_params' => array(
  43. 'certId' => UNIONPAY_CERT_ID,
  44. 'signature' => 'xxxxxxx'
  45. ),
  46. );
  47. /**
  48. * @var LegacyQuickPayPurchaseResponse $response
  49. */
  50. $response = $this->gateway->completePurchase($options)->send();
  51. $this->assertFalse($response->isSuccessful());
  52. }
  53. }