|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\AuthorizeNet; |
| 4 | + |
| 5 | +use Omnipay\Tests\GatewayTestCase; |
| 6 | +//use Omnipay\AuthorizeNet\SIMGatewayTest; |
| 7 | + |
| 8 | +class DPMGatewayTest extends GatewayTestCase //SIMGatewayTest |
| 9 | +{ |
| 10 | + public function setUp() |
| 11 | + { |
| 12 | + parent::setUp(); |
| 13 | + |
| 14 | + $this->gateway = new DPMGateway($this->getHttpClient(), $this->getHttpRequest()); |
| 15 | + $this->gateway->setApiLoginId('example'); |
| 16 | + $this->gateway->setTransactionKey('keykey'); |
| 17 | + $this->gateway->setHashSecret('elpmaxe'); |
| 18 | + |
| 19 | + $this->options = array( |
| 20 | + 'amount' => '10.00', |
| 21 | + 'transactionId' => '99', |
| 22 | + 'returnUrl' => 'https://www.example.com/return', |
| 23 | + ); |
| 24 | + } |
| 25 | + |
| 26 | + public function testAuthorize() |
| 27 | + { |
| 28 | + $response = $this->gateway->authorize($this->options)->send(); |
| 29 | + |
| 30 | + $this->assertFalse($response->isSuccessful()); |
| 31 | + $this->assertTrue($response->isRedirect()); |
| 32 | + $this->assertNotEmpty($response->getRedirectUrl()); |
| 33 | + |
| 34 | + $redirectData = $response->getRedirectData(); |
| 35 | + $this->assertSame('https://www.example.com/return', $redirectData['x_relay_url']); |
| 36 | + } |
| 37 | + |
| 38 | + public function testCompleteAuthorize() |
| 39 | + { |
| 40 | + $this->getHttpRequest()->request->replace( |
| 41 | + array( |
| 42 | + 'x_response_code' => '1', |
| 43 | + 'x_trans_id' => '12345', |
| 44 | + 'x_amount' => '10.00', |
| 45 | + 'x_MD5_Hash' => md5('elpmaxe' . 'example' . '12345' . '10.00'), |
| 46 | + ) |
| 47 | + ); |
| 48 | + |
| 49 | + $response = $this->gateway->completeAuthorize($this->options)->send(); |
| 50 | + |
| 51 | + $this->assertTrue($response->isSuccessful()); |
| 52 | + $this->assertSame('12345', $response->getTransactionReference()); |
| 53 | + $this->assertNull($response->getMessage()); |
| 54 | + } |
| 55 | + |
| 56 | + public function testPurchase() |
| 57 | + { |
| 58 | + $response = $this->gateway->purchase($this->options)->send(); |
| 59 | + |
| 60 | + $this->assertFalse($response->isSuccessful()); |
| 61 | + $this->assertTrue($response->isRedirect()); |
| 62 | + $this->assertNotEmpty($response->getRedirectUrl()); |
| 63 | + |
| 64 | + $redirectData = $response->getRedirectData(); |
| 65 | + $this->assertSame('https://www.example.com/return', $redirectData['x_relay_url']); |
| 66 | + } |
| 67 | + |
| 68 | + public function testCompletePurchase() |
| 69 | + { |
| 70 | + $this->getHttpRequest()->request->replace( |
| 71 | + array( |
| 72 | + 'x_response_code' => '1', |
| 73 | + 'x_trans_id' => '12345', |
| 74 | + 'x_amount' => '10.00', |
| 75 | + 'x_MD5_Hash' => md5('elpmaxe' . 'example' . '12345' . '10.00'), |
| 76 | + ) |
| 77 | + ); |
| 78 | + |
| 79 | + $response = $this->gateway->completePurchase($this->options)->send(); |
| 80 | + |
| 81 | + $this->assertTrue($response->isSuccessful()); |
| 82 | + $this->assertSame('12345', $response->getTransactionReference()); |
| 83 | + $this->assertNull($response->getMessage()); |
| 84 | + } |
| 85 | +} |
0 commit comments