File manager - Edit - /home/opticamezl/www/newok/tests.tar
Back
Message/RefundRequestTest.php 0000604 00000002370 15173246234 0012302 0 ustar 00 <?php namespace Omnipay\SagePay\Message; use Omnipay\Tests\TestCase; class RefundRequestTest extends TestCase { public function setUp() { parent::setUp(); $this->request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'amount' => '12.00', 'transactionReference' => '{"SecurityKey":"JEUPDN1N7E","TxAuthNo":"4255","VPSTxId":"{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}","VendorTxCode":"438791"}', 'testMode' => true, ) ); } public function testGetData() { $data = $this->request->getData(); $this->assertSame('REFUND', $data['TxType']); $this->assertSame('12.00', $data['Amount']); $this->assertSame('438791', $data['RelatedVendorTxCode']); $this->assertSame('{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}', $data['RelatedVPSTxId']); $this->assertSame('JEUPDN1N7E', $data['RelatedSecurityKey']); $this->assertSame('4255', $data['RelatedTxAuthNo']); } public function testGetEndpoint() { $url = $this->request->getEndpoint(); $this->assertSame('https://test.sagepay.com/gateway/service/refund.vsp', $url); } } Message/CaptureResponseTest.php 0000604 00000002065 15173246234 0012631 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class CaptureResponseTest extends TestCase { public function testCaptureSuccess() { $httpResponse = $this->getMockHttpResponse('CaptureSuccess.txt'); $response = new CaptureResponse($this->getMockRequest(), $httpResponse->json()); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ch_lfUYEBK14zotCTykezJkfg', $response->getTransactionReference()); $this->assertTrue($response->getCaptured()); } public function testCaptureFailure() { $httpResponse = $this->getMockHttpResponse('CaptureFailure.txt'); $response = new CaptureResponse($this->getMockRequest(), $httpResponse->json()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('The authorisation has expired and can not be captured.', $response->getMessage()); $this->assertNull($response->getCaptured()); } } Message/CreateCardRequestTest.php 0000604 00000002636 15173246234 0013061 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class CreateCardRequestTest extends TestCase { public function setUp() { $this->request = new CreateCardRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'card' => $this->getValidCard(), ) ); } public function testDataWithCard() { $card = $this->getValidCard(); $this->request->setCard($card); $data = $this->request->getData(); $this->assertSame($card['number'], $data['number']); } public function testSendSuccess() { $this->setMockHttpResponse('CardSuccess.txt'); $response = $this->request->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('card_8LmnNMTYWG4zQZ4YnYQhBg', $response->getCardReference()); $this->assertTrue($response->getMessage()); } public function testSendError() { $this->setMockHttpResponse('CardFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCardReference()); $this->assertSame('One or more parameters were missing or invalid', $response->getMessage()); } } Message/CreateCustomerRequestTest.php 0000604 00000003300 15173246234 0013776 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class CreateCustomerRequestTest extends TestCase { public function setUp() { $this->request = new CreateCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'email' => 'roland@pin.net.au', 'card' => $this->getValidCard(), ) ); } public function testDataWithCardReference() { $this->request->setToken('card_abc'); $data = $this->request->getData(); $this->assertSame('card_abc', $data['card_token']); } public function testDataWithCard() { $card = $this->getValidCard(); $this->request->setCard($card); $data = $this->request->getData(); $this->assertSame($card['number'], $data['card']['number']); } public function testSendSuccess() { $this->setMockHttpResponse('CustomerSuccess.txt'); $response = $this->request->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('cus_Mb-8S1ZgEbLUUUJ97dfhfQ', $response->getCustomerReference()); $this->assertTrue($response->getMessage()); } public function testSendError() { $this->setMockHttpResponse('CustomerFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCustomerReference()); $this->assertSame('One or more parameters were missing or invalid', $response->getMessage()); } } Message/CaptureRequestTest.php 0000604 00000002340 15173246234 0012457 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class CaptureRequestTest extends TestCase { public function setUp() { $this->request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->setTransactionReference('ch_bZ3RhJnIUZ8HhfvH8CCvfA') ->setAmount('400.00'); } public function testSendSuccess() { $this->setMockHttpResponse('CaptureSuccess.txt'); $response = $this->request->send(); $data = $response->getData(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ch_lfUYEBK14zotCTykezJkfg', $response->getTransactionReference()); $this->assertTrue($data['response']['captured']); } public function testSendError() { $this->setMockHttpResponse('CaptureFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('The authorisation has expired and can not be captured.', $response->getMessage()); } } Message/ResponseTest.php 0000604 00000007034 15173246234 0011306 0 ustar 00 <?php namespace Omnipay\SagePay\Message; use Omnipay\Tests\TestCase; class ResponseTest extends TestCase { public function setUp() { $this->getMockRequest()->shouldReceive('getTransactionId')->andReturn('123456'); } public function testDirectPurchaseSuccess() { $httpResponse = $this->getMockHttpResponse('DirectPurchaseSuccess.txt'); $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"SecurityKey":"OUWLNYQTVT","TxAuthNo":"9962","VPSTxId":"{5A1BC414-5409-48DD-9B8B-DCDF096CE0BE}","VendorTxCode":"123456"}', $response->getTransactionReference()); $this->assertSame('Direct transaction from Simulator.', $response->getMessage()); } public function testDirectPurchaseFailure() { $httpResponse = $this->getMockHttpResponse('DirectPurchaseFailure.txt'); $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123456"}', $response->getTransactionReference()); $this->assertSame('The VendorTxCode \'984297\' has been used before. Each transaction you send should have a unique VendorTxCode.', $response->getMessage()); } public function testDirectPurchase3dSecure() { $httpResponse = $this->getMockHttpResponse('DirectPurchase3dSecure.txt'); $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->getMockRequest()->shouldReceive('getReturnUrl')->once()->andReturn('https://www.example.com/return'); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123456"}', $response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertSame('https://test.sagepay.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl()); $redirectData = $response->getRedirectData(); $this->assertSame('065379457749061954', $redirectData['MD']); $this->assertSame('BSkaFwYFFTYAGyFbAB0LFRYWBwsBZw0EGwECEX9YRGFWc08pJCVVKgAANS0KADoZCCAMBnIeOxcWRg0LERdOOTQRDFRdVHNYUgwTMBsBCxABJw4DJHE+ERgPCi8MVC0HIAROCAAfBUk4ER89DD0IWDkvMQ1VdFwoUFgwXVYvbHgvMkdBXXNbQGIjdl1ZUEc1XSwqAAgUUicYBDYcB3I2AjYjIzsn', $redirectData['PaReq']); $this->assertSame('https://www.example.com/return', $redirectData['TermUrl']); } public function testCaptureSuccess() { $httpResponse = $this->getMockHttpResponse('CaptureSuccess.txt'); $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertTrue($response->isSuccessful()); $this->assertSame('{"VendorTxCode":"123456"}', $response->getTransactionReference()); $this->assertSame('The transaction was RELEASEed successfully.', $response->getMessage()); } public function testCaptureFailure() { $httpResponse = $this->getMockHttpResponse('CaptureFailure.txt'); $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertFalse($response->isSuccessful()); $this->assertSame('{"VendorTxCode":"123456"}', $response->getTransactionReference()); $this->assertSame('You are trying to RELEASE a transaction that has already been RELEASEd or ABORTed.', $response->getMessage()); } } Message/PurchaseRequestTest.php 0000604 00000003112 15173246234 0012624 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Tests\TestCase; class PurchaseRequestTest extends TestCase { public function setUp() { $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); } public function testSignature() { $this->request->initialize( array( 'amount' => '12.00', 'description' => 'Test Product', 'transactionId' => 123, 'merchantId' => 'foo', 'merchantKey' => 'bar', 'returnUrl' => 'https://www.example.com/return', 'cancelUrl' => 'https://www.example.com/cancel', ) ); $data = $this->request->getData(); $this->assertSame('ab86df60906e97d3bfb362aff26fd9e6', $data['signature']); } public function testPurchase() { $this->request->setAmount('12.00')->setDescription('Test Product'); $response = $this->request->send(); $this->assertInstanceOf('Omnipay\PayFast\Message\PurchaseResponse', $response); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertNull($response->getCode()); $this->assertSame('https://www.payfast.co.za/eng/process', $response->getRedirectUrl()); $this->assertSame('POST', $response->getRedirectMethod()); $this->assertArrayHasKey('signature', $response->getData()); } } GatewayTest.php 0000604 00000001476 15173246234 0007531 0 ustar 00 <?php namespace Omnipay\PayFast; use Omnipay\Tests\GatewayTestCase; class GatewayTest extends GatewayTestCase { public function setUp() { parent::setUp(); $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); } public function testPurchase() { $request = $this->gateway->purchase(array('amount' => '12.00')); $this->assertInstanceOf('\Omnipay\PayFast\Message\PurchaseRequest', $request); $this->assertSame('12.00', $request->getAmount()); } public function testCompletePurchase() { $request = $this->gateway->completePurchase(array('amount' => '12.00')); $this->assertInstanceOf('\Omnipay\PayFast\Message\CompletePurchaseRequest', $request); $this->assertSame('12.00', $request->getAmount()); } } Mock/CustomerSuccess.txt 0000604 00000001704 15173246234 0011335 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response":{"token":"cus_Mb-8S1ZgEbLUUUJ97dfhfQ","email":"roland@pin.net.au","created_at":"2014-05-16T11:59:13Z","card":{"token":"card_ooPYTNYmvVr8gswiBwE8kQ","scheme":"master","display_number":"XXXX-XXXX-XXXX-0000","expiry_month":5,"expiry_year":2015,"name":"Roland Robot","address_line1":"42 Sevenoaks St","address_line2":"","address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"}}} Mock/CaptureSuccess.txt 0000604 00000000524 15173246234 0011136 0 ustar 00 HTTP/1.1 200 OK Date: Sat, 16 Feb 2013 08:21:03 GMT Server: Microsoft-IIS/6.0 P3P: CP="CUR" X-Powered-By: ASP.NET Content-Length: 85 Content-Type: Text/Plain Set-Cookie: ASPSESSIONIDSEHSCTTR=FNBHGPBDMGDJCNLCDCDPGKCA; secure; path=/ Cache-control: private VPSProtocol=3.00 Status=OK StatusDetail=The transaction was RELEASEed successfully. Mock/RefundSuccess.txt 0000604 00000001363 15173246234 0010760 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response": {"token": "rf_ERCQy--Ay6o-NKGiUVcKKA","success": null,"amount": 400,"currency": "AUD","charge": "ch_bZ3RhJnIUZ8HhfvH8CCvfA","created_at": "2012-10-27T13:00:00Z","error_message": null,"status_message": "Pending"}} Mock/CardFailure.txt 0000604 00000001340 15173246234 0010360 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"error":"invalid_resource","error_description":"One or more parameters were missing or invalid","messages":[{"param":"expiry_month","code":"expiry_month_invalid","message":"Expiry month can't be blank"}]} Mock/PurchaseFailure.txt 0000604 00000001171 15173246234 0011263 0 ustar 00 HTTP/1.1 422 Unprocessable Entity Cache-Control: no-cache Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:54:18 GMT Server: Apache/2.2.20 (Ubuntu) Status: 422 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 293436e475bfc6face410e6ed241efe9 X-Runtime: 0.161746 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 152 Connection: keep-alive {"error":"invalid_resource","error_description":"The current resource was deemed invalid.","messages":[{"code":"invalid","message":"Processing error"}]} Mock/RefundFailure.txt 0000604 00000001135 15173246234 0010734 0 ustar 00 HTTP/1.1 422 Unprocessable Entity Cache-Control: no-cache Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:54:18 GMT Server: Apache/2.2.20 (Ubuntu) Status: 422 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 293436e475bfc6face410e6ed241efe9 X-Runtime: 0.161746 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 152 Connection: keep-alive {"error": "insufficient_pin_balance","error_description": "Refund amount is more than your available Pin Payments balance."} Mock/PurchaseSuccess.txt 0000604 00000002133 15173246234 0011303 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response":{"token":"ch_fXIxWf0gj1yFHJcV1W-d-w","success":true,"amount":1000,"currency":"USD","description":"first purchase","email":"fads","ip_address":"","created_at":"2013-02-15T15:42:42Z","status_message":"Success!","error_message":null,"card":{"token":"card_vRGOXvw3NSGR59-TSzVEiw","display_number":"XXXX-XXXX-XXXX-0000","scheme":"visa","address_line1":"jkl","address_line2":"jkl","address_city":"jkl","address_postcode":"jkl","address_state":"jkl","address_country":"jkl"},"transfer":[],"amount_refunded":0,"total_fees":null,"merchant_entitlement":null,"refund_pending":false}} Mock/CardSuccess.txt 0000604 00000001562 15173246234 0010407 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response":{"token":"card_8LmnNMTYWG4zQZ4YnYQhBg","scheme":"master","display_number":"XXXX-XXXX-XXXX-0000","expiry_month":5,"expiry_year":2015,"name":"Roland Robot","address_line1":"42 Sevenoaks St","address_line2":"","address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"ip_address":"27.32.236.92"} Mock/CaptureFailure.txt 0000604 00000000601 15173246234 0011111 0 ustar 00 HTTP/1.1 200 OK Date: Sat, 16 Feb 2013 08:21:41 GMT Server: Microsoft-IIS/6.0 P3P: CP="CUR" X-Powered-By: ASP.NET Content-Length: 129 Content-Type: Text/Plain Set-Cookie: ASPSESSIONIDSEHSCTTR=NNBHGPBDLOMKKPGPNDDJFBAB; secure; path=/ Cache-control: private VPSProtocol=3.00 Status=INVALID StatusDetail=You are trying to RELEASE a transaction that has already been RELEASEd or ABORTed. Mock/CustomerFailure.txt 0000604 00000001356 15173246234 0011317 0 ustar 00 HTTP/1.1 422 Unprocessable Entity Cache-Control: no-cache Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:54:18 GMT Server: Apache/2.2.20 (Ubuntu) Status: 422 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 293436e475bfc6face410e6ed241efe9 X-Runtime: 0.161746 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 152 Connection: keep-alive {"error":"invalid_resource","error_description":"One or more parameters were missing or invalid","messages":[{"param":"email","code":"email_invalid","message":"Email can't be blank"},{"param":"email","code":"email_invalid","message":"Email is not formatted properly"}]} Message/ThreePartyPurchaseRequestTest.php 0000604 00000003632 15173272056 0014644 0 ustar 00 <?php namespace Omnipay\Migs\Message; use Omnipay\Tests\TestCase; class ThreePartyPurchaseRequestTest extends TestCase { public function setUp() { $this->request = new ThreePartyPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); } public function testSignature() { $this->request->initialize( array( 'amount' => '12.00', 'transactionId' => 123, 'returnUrl' => 'https://www.example.com/return', 'merchantId' => '123', 'merchantAccessCode' => '123', 'secureHash' => '123', ) ); $data = $this->request->getData(); $this->assertSame('FC86354CC09D414EF308A6FA8CE4F9BB', $data['vpc_SecureHash']); } public function testPurchase() { $this->request->initialize( array( 'amount' => '12.00', 'transactionId' => 123, 'returnUrl' => 'https://www.example.com/return', 'merchantId' => '123', 'merchantAccessCode' => '123', 'secureHash' => '123', ) ); $response = $this->request->send(); $this->assertInstanceOf('Omnipay\Migs\Message\ThreePartyPurchaseResponse', $response); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertNull($response->getCode()); $this->assertStringStartsWith('https://migs.mastercard.com.au/vpcpay?', $response->getRedirectUrl()); $this->assertSame('GET', $response->getRedirectMethod()); $this->assertArrayHasKey('vpc_SecureHash', $response->getData()); } } Message/TwoPartyPurchaseRequestTest.php 0000604 00000004020 15173272056 0014336 0 ustar 00 <?php namespace Omnipay\Migs\Message; use Omnipay\Tests\TestCase; class TwoPartyPurchaseRequestTest extends TestCase { public function setUp() { $this->request = new TwoPartyPurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); } public function testCalculateHash() { $data = array( 'vpc_Merchant' => '123', 'vpc_AccessCode' => '123', 'vpc_Version' => '1', 'vpc_Locale' => 'en', 'vpc_Command' => 'pay', 'vpc_Amount' => '1200', 'vpc_MerchTxnRef' => '123', 'vpc_OrderInfo' => '', 'vpc_ReturnURL' => 'https://www.example.com/return', 'vpc_CardNum' => '4111111111111111', 'vpc_CardExp' => '1305', 'vpc_CardSecurityCode' => '123', ); $this->request->setSecureHash('123'); $hash = $this->request->calculateHash($data); $this->assertSame('2624B4BABED7CCA98665238D75560600', $hash); } public function testPurchase() { $this->setMockHttpResponse('TwoPartyPurchaseSuccess.txt'); $this->request->initialize( array( 'amount' => '12.00', 'transactionId' => 123, 'card' => $this->getValidCard(), 'merchantId' => '123', 'merchantAccessCode' => '123', 'secureHash' => '123', 'returnUrl' => 'https://www.example.com/return' ) ); $response = $this->request->send(); $this->assertInstanceOf('Omnipay\Migs\Message\Response', $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('12345', $response->getTransactionReference()); $this->assertSame('Approved', $response->getMessage()); $this->assertNull($response->getCode()); $this->assertArrayHasKey('vpc_SecureHash', $response->getData()); } } Message/ThreePartyPurchaseResponseTest.php 0000604 00000001460 15173272056 0015007 0 ustar 00 <?php namespace Omnipay\Migs\Message; use Omnipay\Tests\TestCase; class ThreePartyPurchaseResponseTest extends TestCase { public function testConstruct() { $data = array('test' => '123'); $response = new ThreePartyPurchaseResponse($this->getMockRequest(), $data, 'https://example.com/'); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertSame($data, $response->getData()); $this->assertSame('https://example.com/', $response->getRedirectUrl()); $this->assertSame('GET', $response->getRedirectMethod()); $this->assertSame($data, $response->getRedirectData()); } } Message/ThreePartyCompletePurchaseRequestTest.php 0000604 00000003410 15173272056 0016327 0 ustar 00 <?php namespace Omnipay\Migs\Message; use Omnipay\Tests\TestCase; class ThreePartyCompletePurchaseRequestTest extends TestCase { public function setUp() { $this->request = new ThreePartyCompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); } public function testThreePartyCompletePurchaseSuccess() { $data = array(); $data['vpc_Message'] = "Approved"; $data['vpc_ReceiptNo'] = "12345"; $data['vpc_TxnResponseCode'] = "0"; $data['vpc_SecureHash'] = "8720B88CA00352B2A5F4D51C64E86BCB"; $response = new Response($this->getMockRequest(), $data); $this->assertInstanceOf('Omnipay\Migs\Message\Response', $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('12345', $response->getTransactionReference()); $this->assertSame('Approved', $response->getMessage()); $this->assertNull($response->getCode()); } public function testThreePartyCompletePurchaseFailure() { $data = array(); $data['vpc_Message'] = "Error"; $data['vpc_ReceiptNo'] = "12345"; $data['vpc_TxnResponseCode'] = "1"; $data['vpc_SecureHash'] = "8720B88CA00352B2A5F4D51C64E86BCB"; $response = new Response($this->getMockRequest(), $data); $this->assertInstanceOf('Omnipay\Migs\Message\Response', $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('12345', $response->getTransactionReference()); $this->assertNotSame('Approved', $response->getMessage()); $this->assertNull($response->getCode()); } } Message/TwoPartyPurchaseResponseTest.php 0000604 00000002463 15173272056 0014515 0 ustar 00 <?php namespace Omnipay\Migs\Message; use Omnipay\Tests\TestCase; class TwoPartyPurchaseResponseTest extends TestCase { public function testTwoPartyPurchaseSuccess() { $httpResponse = $this->getMockHttpResponse('TwoPartyPurchaseSuccess.txt'); $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertInstanceOf('Omnipay\Migs\Message\Response', $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('12345', $response->getTransactionReference()); $this->assertSame('Approved', $response->getMessage()); $this->assertNull($response->getCode()); } public function testTwoPartyPurchaseFailure() { $httpResponse = $this->getMockHttpResponse('TwoPartyPurchaseFailure.txt'); $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertInstanceOf('Omnipay\Migs\Message\Response', $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('12345', $response->getTransactionReference()); $this->assertSame('Declined', $response->getMessage()); $this->assertNull($response->getCode()); } } Mock/TwoPartyPurchaseFailure.txt 0000604 00000001324 15173272056 0012776 0 ustar 00 HTTP/1.1 200 OK Date: Fri, 05 Apr 2013 13:11:19 GMT Server: Apache Expires: Sun, 15 Jul 1990 00:00:00 GMT Pragma: no-cache Cache-Control: no-cache Content-Length: 469 P3P: CP="NOI DSP COR CURa ADMa TA1a OUR BUS IND UNI COM NAV INT" Content-Type: text/plain;charset=iso-8859-1 vpc_AVSRequestCode=Z&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=14&vpc_Amount=1000&vpc_BatchNo=12345&vpc_CSCResultCode=Unsupported&vpc_Card=VC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=123&vpc_Merchant=EXAMPLE&vpc_Message=Declined&vpc_OrderInfo=&vpc_ReceiptNo=12345&vpc_SecureHash=71B4E0DE9EACB5FC27C902379737D458&vpc_TransactionNo=12345&vpc_TxnResponseCode=2&vpc_Version=1 Mock/TwoPartyPurchaseSuccess.txt 0000604 00000001352 15173272056 0013020 0 ustar 00 HTTP/1.1 200 OK Date: Fri, 05 Apr 2013 12:29:13 GMT Server: Apache Expires: Sun, 15 Jul 1990 00:00:00 GMT Pragma: no-cache Cache-Control: no-cache Content-Length: 492 P3P: CP="NOI DSP COR CURa ADMa TA1a OUR BUS IND UNI COM NAV INT" Content-Type: text/plain;charset=iso-8859-1 vpc_AVSRequestCode=Z&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=Unsupported&vpc_AcqResponseCode=00&vpc_Amount=1000&vpc_AuthorizeId=12345&vpc_BatchNo=12345&vpc_CSCResultCode=Unsupported&vpc_Card=VC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=123&vpc_Merchant=EXAMPLE&vpc_Message=Approved&vpc_OrderInfo=&vpc_ReceiptNo=12345&vpc_SecureHash=58808781CF7265DEA89EA8B713FAB075&vpc_TransactionNo=12345&vpc_TxnResponseCode=0&vpc_Version=1 TwoPartyGatewayTest.php 0000604 00000002647 15173272056 0011245 0 ustar 00 <?php namespace Omnipay\Migs; use Omnipay\Tests\GatewayTestCase; class TwoPartyGatewayTest extends GatewayTestCase { public function setUp() { parent::setUp(); $this->gateway = new TwoPartyGateway($this->getHttpClient(), $this->getHttpRequest()); $this->gateway->setSecureHash(md5('example')); $this->options = array( 'amount' => '10.00', 'transactionId' => 12345, 'card' => $this->getValidCard(), ); } public function testPurchaseSuccess() { $this->setMockHttpResponse('TwoPartyPurchaseSuccess.txt'); $response = $this->gateway->purchase($this->options)->send(); $this->assertInstanceOf('\Omnipay\Migs\Message\Response', $response); $this->assertTrue($response->isSuccessful()); $this->assertEquals('12345', $response->getTransactionReference()); $this->assertSame('Approved', $response->getMessage()); } public function testPurchaseFailure() { $this->setMockHttpResponse('TwoPartyPurchaseFailure.txt'); $response = $this->gateway->purchase($this->options)->send(); $this->assertInstanceOf('\Omnipay\Migs\Message\Response', $response); $this->assertFalse($response->isSuccessful()); $this->assertEquals('12345', $response->getTransactionReference()); $this->assertEquals('Declined', $response->getMessage()); } } ThreePartyGatewayTest.php 0000604 00000002032 15173272056 0011527 0 ustar 00 <?php namespace Omnipay\Migs; use Omnipay\Tests\GatewayTestCase; class ThreePartyGatewayTest extends GatewayTestCase { public function setUp() { parent::setUp(); $this->gateway = new ThreePartyGateway($this->getHttpClient(), $this->getHttpRequest()); $this->options = array( 'amount' => '10.00', 'transactionId' => 12345, 'returnUrl' => 'https://www.example.com/return', ); } public function testPurchase() { $request = $this->gateway->purchase(array('amount' => '10.00')); $this->assertInstanceOf('\Omnipay\Migs\Message\ThreePartyPurchaseRequest', $request); $this->assertSame('10.00', $request->getAmount()); } public function testCompletePurchase() { $request = $this->gateway->completePurchase(array('amount' => '10.00')); $this->assertInstanceOf('\Omnipay\Migs\Message\ThreePartyCompletePurchaseRequest', $request); $this->assertSame('10.00', $request->getAmount()); } } Message/PurchaseResponseTest.php 0000604 00000001437 15173311267 0013001 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Tests\TestCase; class PurchaseResponseTest extends TestCase { public function testConstruct() { $data = array('test' => '123'); $response = new PurchaseResponse($this->getMockRequest(), $data, 'https://example.com/'); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertSame($data, $response->getData()); $this->assertSame('https://example.com/', $response->getRedirectUrl()); $this->assertSame('POST', $response->getRedirectMethod()); $this->assertSame($data, $response->getRedirectData()); } } Message/CompletePurchaseRequestTest.php 0000604 00000005752 15173311267 0014330 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Tests\TestCase; class CompletePurchaseRequestTest extends TestCase { public function setUp() { $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); } public function getItnPostData() { return array( 'm_payment_id' => '', 'pf_payment_id' => '61493', 'payment_status' => 'COMPLETE', 'item_name' => 'fjdksl', 'item_description' => '', 'amount_gross' => '12.00', 'amount_fee' => '-0.27', 'amount_net' => '11.73', 'custom_str1' => '', 'custom_str2' => '', 'custom_str3' => '', 'custom_str4' => '', 'custom_str5' => '', 'custom_int1' => '', 'custom_int2' => '', 'custom_int3' => '', 'custom_int4' => '', 'custom_int5' => '', 'name_first' => 'Test', 'name_last' => 'User 01', 'email_address' => 'sbtu01@payfast.co.za', 'merchant_id' => '10000103', 'signature' => '92ac916145511e9050383b008729e162', ); } public function testCompletePurchaseItnSuccess() { $this->getHttpRequest()->request->replace($this->getItnPostData()); $this->setMockHttpResponse('CompletePurchaseItnSuccess.txt'); $response = $this->request->send(); $this->assertInstanceOf('Omnipay\PayFast\Message\CompletePurchaseItnResponse', $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('61493', $response->getTransactionReference()); $this->assertSame('COMPLETE', $response->getMessage()); $this->assertNull($response->getCode()); } public function testCompletePurchaseItnInvalid() { $this->getHttpRequest()->request->replace($this->getItnPostData()); $this->setMockHttpResponse('CompletePurchaseItnFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('INVALID', $response->getMessage()); $this->assertNull($response->getCode()); } public function testCompletePurchasePdtSuccess() { $this->getHttpRequest()->query->replace(array('pt' => 'abc')); $this->setMockHttpResponse('CompletePurchasePdtFailure.txt'); $response = $this->request->send(); $this->assertInstanceOf('Omnipay\PayFast\Message\CompletePurchasePdtResponse', $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('FAIL', $response->getMessage()); $this->assertNull($response->getCode()); } } Mock/CompletePurchasePdtSuccess.txt 0000604 00000001276 15173311267 0013452 0 ustar 00 HTTP/1.1 200 OK Date: Thu, 07 Mar 2013 04:50:36 GMT Server: Apache/2.2.3 (CentOS) Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Length: 397 Connection: close Content-Type: text/html; charset=UTF-8 SUCCESS m_payment_id= pf_payment_id=61484 payment_status=COMPLETE item_name=fjdksl item_description= amount_gross=12.00 amount_fee=-0.27 amount_net=11.73 custom_str1= custom_str2= custom_str3= custom_str4= custom_str5= custom_int1= custom_int2= custom_int3= custom_int4= custom_int5= name_first=Test name_last=User+01 email_address=sbtu01%40payfast.co.za merchant_id=10000103 Mock/CompletePurchaseItnSuccess.txt 0000604 00000000512 15173311267 0013445 0 ustar 00 HTTP/1.1 200 OK Date: Thu, 07 Mar 2013 05:30:11 GMT Server: Apache/2.2.3 (CentOS) Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Length: 5 Connection: close Content-Type: text/html; charset=UTF-8 VALID Mock/CompletePurchaseItnFailure.txt 0000604 00000000746 15173311267 0013435 0 ustar 00 HTTP/1.1 200 OK Date: Thu, 07 Mar 2013 04:57:24 GMT Server: Apache/2.2.3 (CentOS) Set-Cookie: refer_session=Direct; path=/; domain=.payfast.co.za, refer_first=Direct; expires=Fri, 07-Mar-2014 04:57:24 GMT; path=/; domain=.payfast.co.za Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Length: 7 Connection: close Content-Type: text/html; charset=UTF-8 INVALID Mock/CompletePurchasePdtFailure.txt 0000604 00000000511 15173311267 0013420 0 ustar 00 HTTP/1.1 200 OK Date: Thu, 07 Mar 2013 05:07:38 GMT Server: Apache/2.2.3 (CentOS) Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Length: 4 Connection: close Content-Type: text/html; charset=UTF-8 FAIL DirectGatewayTest.php 0000604 00000015551 15173341464 0010664 0 ustar 00 <?php namespace Omnipay\SagePay; use Omnipay\Tests\GatewayTestCase; class DirectGatewayTest extends GatewayTestCase { public function setUp() { parent::setUp(); $this->gateway = new DirectGateway($this->getHttpClient(), $this->getHttpRequest()); $this->purchaseOptions = array( 'amount' => '10.00', 'transactionId' => '123', 'card' => $this->getValidCard(), 'returnUrl' => 'https://www.example.com/return', ); $this->captureOptions = array( 'amount' => '10.00', 'transactionId' => '123', 'transactionReference' => '{"SecurityKey":"JEUPDN1N7E","TxAuthNo":"4255","VPSTxId":"{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}","VendorTxCode":"438791"}', ); } public function testAuthorizeFailureSuccess() { $this->setMockHttpResponse('DirectPurchaseSuccess.txt'); $response = $this->gateway->authorize($this->purchaseOptions)->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"SecurityKey":"OUWLNYQTVT","TxAuthNo":"9962","VPSTxId":"{5A1BC414-5409-48DD-9B8B-DCDF096CE0BE}","VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('Direct transaction from Simulator.', $response->getMessage()); } public function testAuthorizeFailure() { $this->setMockHttpResponse('DirectPurchaseFailure.txt'); $response = $this->gateway->authorize($this->purchaseOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('The VendorTxCode \'984297\' has been used before. Each transaction you send should have a unique VendorTxCode.', $response->getMessage()); } public function testAuthorize3dSecure() { $this->setMockHttpResponse('DirectPurchase3dSecure.txt'); $response = $this->gateway->authorize($this->purchaseOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertSame('https://test.sagepay.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl()); $redirectData = $response->getRedirectData(); $this->assertSame('065379457749061954', $redirectData['MD']); $this->assertSame('BSkaFwYFFTYAGyFbAB0LFRYWBwsBZw0EGwECEX9YRGFWc08pJCVVKgAANS0KADoZCCAMBnIeOxcWRg0LERdOOTQRDFRdVHNYUgwTMBsBCxABJw4DJHE+ERgPCi8MVC0HIAROCAAfBUk4ER89DD0IWDkvMQ1VdFwoUFgwXVYvbHgvMkdBXXNbQGIjdl1ZUEc1XSwqAAgUUicYBDYcB3I2AjYjIzsn', $redirectData['PaReq']); $this->assertSame('https://www.example.com/return', $redirectData['TermUrl']); } public function testPurchaseSuccess() { $this->setMockHttpResponse('DirectPurchaseSuccess.txt'); $response = $this->gateway->purchase($this->purchaseOptions)->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"SecurityKey":"OUWLNYQTVT","TxAuthNo":"9962","VPSTxId":"{5A1BC414-5409-48DD-9B8B-DCDF096CE0BE}","VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('Direct transaction from Simulator.', $response->getMessage()); } public function testPurchaseFailure() { $this->setMockHttpResponse('DirectPurchaseFailure.txt'); $response = $this->gateway->purchase($this->purchaseOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('The VendorTxCode \'984297\' has been used before. Each transaction you send should have a unique VendorTxCode.', $response->getMessage()); } public function testPurchase3dSecure() { $this->setMockHttpResponse('DirectPurchase3dSecure.txt'); $response = $this->gateway->purchase($this->purchaseOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertSame('https://test.sagepay.com/Simulator/3DAuthPage.asp', $response->getRedirectUrl()); $redirectData = $response->getRedirectData(); $this->assertSame('065379457749061954', $redirectData['MD']); $this->assertSame('BSkaFwYFFTYAGyFbAB0LFRYWBwsBZw0EGwECEX9YRGFWc08pJCVVKgAANS0KADoZCCAMBnIeOxcWRg0LERdOOTQRDFRdVHNYUgwTMBsBCxABJw4DJHE+ERgPCi8MVC0HIAROCAAfBUk4ER89DD0IWDkvMQ1VdFwoUFgwXVYvbHgvMkdBXXNbQGIjdl1ZUEc1XSwqAAgUUicYBDYcB3I2AjYjIzsn', $redirectData['PaReq']); $this->assertSame('https://www.example.com/return', $redirectData['TermUrl']); } public function testCaptureSuccess() { $this->setMockHttpResponse('CaptureSuccess.txt'); $response = $this->gateway->capture($this->captureOptions)->send(); $this->assertTrue($response->isSuccessful()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('The transaction was RELEASEed successfully.', $response->getMessage()); } public function testCaptureFailure() { $this->setMockHttpResponse('CaptureFailure.txt'); $response = $this->gateway->capture($this->captureOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('You are trying to RELEASE a transaction that has already been RELEASEd or ABORTed.', $response->getMessage()); } public function testRefundSuccess() { $this->setMockHttpResponse('CaptureSuccess.txt'); $response = $this->gateway->refund($this->captureOptions)->send(); $this->assertTrue($response->isSuccessful()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('The transaction was RELEASEed successfully.', $response->getMessage()); } public function testRefundFailure() { $this->setMockHttpResponse('CaptureFailure.txt'); $response = $this->gateway->refund($this->captureOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('You are trying to RELEASE a transaction that has already been RELEASEd or ABORTed.', $response->getMessage()); } } ServerGatewayTest.php 0000604 00000014715 15173341464 0010721 0 ustar 00 <?php namespace Omnipay\SagePay; use Omnipay\Tests\GatewayTestCase; class ServerGatewayTest extends GatewayTestCase { protected $error_3082_text = '3082 : The Description value is too long.'; public function setUp() { parent::setUp(); $this->gateway = new ServerGateway($this->getHttpClient(), $this->getHttpRequest()); $this->gateway->setVendor('example'); $this->purchaseOptions = array( 'amount' => '10.00', 'transactionId' => '123', 'card' => $this->getValidCard(), 'returnUrl' => 'https://www.example.com/return', ); $this->completePurchaseOptions = array( 'amount' => '10.00', 'transactionId' => '123', 'transactionReference' => '{"SecurityKey":"JEUPDN1N7E","TxAuthNo":"4255","VPSTxId":"{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}","VendorTxCode":"438791"}', ); } public function testInheritsDirectGateway() { $this->assertInstanceOf('Omnipay\SagePay\DirectGateway', $this->gateway); } public function testAuthorizeSuccess() { $this->setMockHttpResponse('ServerPurchaseSuccess.txt'); $response = $this->gateway->authorize($this->purchaseOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('{"SecurityKey":"IK776BWNHN","VPSTxId":"{1E7D9C70-DBE2-4726-88EA-D369810D801D}","VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('Server transaction registered successfully.', $response->getMessage()); $this->assertSame('https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl()); } public function testAuthorizeFailure() { $this->setMockHttpResponse('ServerPurchaseFailure.txt'); $response = $this->gateway->authorize($this->purchaseOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame($this->error_3082_text, $response->getMessage()); } public function testCompleteAuthorizeSuccess() { $this->getHttpRequest()->request->replace( array( 'Status' => 'OK', 'TxAuthNo' => 'b', 'AVSCV2' => 'c', 'AddressResult' => 'd', 'PostCodeResult' => 'e', 'CV2Result' => 'f', 'GiftAid' => 'g', '3DSecureStatus' => 'h', 'CAVV' => 'i', 'AddressStatus' => 'j', 'PayerStatus' => 'k', 'CardType' => 'l', 'Last4Digits' => 'm', // New fields for protocol v3.00 'DeclineCode' => '00', 'ExpiryDate' => '0722', 'BankAuthCode' => '999777', 'VPSSignature' => md5( '{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}' . '438791' . 'OK' . 'bexamplecJEUPDN1N7Edefghijklm' . '00' . '0722' . '999777' ), ) ); $response = $this->gateway->completeAuthorize($this->completePurchaseOptions)->send(); $this->assertTrue($response->isSuccessful()); $this->assertSame( '{"SecurityKey":"JEUPDN1N7E","TxAuthNo":"b","VPSTxId":"{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}","VendorTxCode":"123"}', $response->getTransactionReference() ); $this->assertNull($response->getMessage()); } /** * @expectedException Omnipay\Common\Exception\InvalidResponseException */ public function testCompleteAuthorizeInvalid() { $response = $this->gateway->completeAuthorize($this->completePurchaseOptions)->send(); } public function testPurchaseSuccess() { $this->setMockHttpResponse('ServerPurchaseSuccess.txt'); $response = $this->gateway->purchase($this->purchaseOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('{"SecurityKey":"IK776BWNHN","VPSTxId":"{1E7D9C70-DBE2-4726-88EA-D369810D801D}","VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame('Server transaction registered successfully.', $response->getMessage()); $this->assertSame('https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl()); } public function testPurchaseFailure() { $this->setMockHttpResponse('ServerPurchaseFailure.txt'); $response = $this->gateway->purchase($this->purchaseOptions)->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertSame($this->error_3082_text, $response->getMessage()); } public function testCompletePurchaseSuccess() { $this->getHttpRequest()->request->replace( array( 'Status' => 'OK', 'TxAuthNo' => 'b', 'AVSCV2' => 'c', 'AddressResult' => 'd', 'PostCodeResult' => 'e', 'CV2Result' => 'f', 'GiftAid' => 'g', '3DSecureStatus' => 'h', 'CAVV' => 'i', 'AddressStatus' => 'j', 'PayerStatus' => 'k', 'CardType' => 'l', 'Last4Digits' => 'm', 'VPSSignature' => md5('{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}438791OKbexamplecJEUPDN1N7Edefghijklm'), ) ); $response = $this->gateway->completePurchase($this->completePurchaseOptions)->send(); $this->assertTrue($response->isSuccessful()); $this->assertSame('{"SecurityKey":"JEUPDN1N7E","TxAuthNo":"b","VPSTxId":"{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}","VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertNull($response->getMessage()); } /** * @expectedException Omnipay\Common\Exception\InvalidResponseException */ public function testCompletePurchaseInvalid() { $response = $this->gateway->completePurchase($this->completePurchaseOptions)->send(); } } Message/ServerCompleteAuthorizeResponseTest.php 0000604 00000007226 15173341464 0016065 0 ustar 00 <?php namespace Omnipay\SagePay\Message; use Omnipay\Tests\TestCase; use Mockery as m; class ServerCompleteAuthorizeResponseTest extends TestCase { public function testServerCompleteAuthorizeResponseSuccess() { $response = new ServerCompleteAuthorizeResponse( $this->getMockRequest(), array( 'Status' => 'OK', 'TxAuthNo' => 'b', 'AVSCV2' => 'c', 'AddressResult' => 'd', 'PostCodeResult' => 'e', 'CV2Result' => 'f', 'GiftAid' => 'g', '3DSecureStatus' => 'h', 'CAVV' => 'i', 'AddressStatus' => 'j', 'PayerStatus' => 'k', 'CardType' => 'l', 'Last4Digits' => 'm', 'DeclineCode' => '00', 'ExpiryDate' => '0722', 'BankAuthCode' => '999777', ) ); $this->getMockRequest()->shouldReceive('getTransactionId')->once()->andReturn('123'); $this->getMockRequest()->shouldReceive('getTransactionReference')->once()->andReturn('{"SecurityKey":"JEUPDN1N7E","TxAuthNo":"4255","VPSTxId":"{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}","VendorTxCode":"438791"}'); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"SecurityKey":"JEUPDN1N7E","TxAuthNo":"b","VPSTxId":"{F955C22E-F67B-4DA3-8EA3-6DAC68FA59D2}","VendorTxCode":"123"}', $response->getTransactionReference()); $this->assertNull($response->getMessage()); } public function testServerCompleteAuthorizeResponseFailure() { $response = new ServerCompleteAuthorizeresponse($this->getMockRequest(), array('Status' => 'INVALID')); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); } public function testConfirm() { $response = m::mock('\Omnipay\SagePay\Message\ServerCompleteAuthorizeResponse')->makePartial(); $response->shouldReceive('sendResponse')->once()->with('OK', 'https://www.example.com/', 'detail'); $response->confirm('https://www.example.com/', 'detail'); } public function testError() { $response = m::mock('\Omnipay\SagePay\Message\ServerCompleteAuthorizeResponse')->makePartial(); $response->shouldReceive('sendResponse')->once()->with('ERROR', 'https://www.example.com/', 'detail'); $response->error('https://www.example.com/', 'detail'); } public function testInvalid() { $response = m::mock('\Omnipay\SagePay\Message\ServerCompleteAuthorizeResponse')->makePartial(); $response->shouldReceive('sendResponse')->once()->with('INVALID', 'https://www.example.com/', 'detail'); $response->invalid('https://www.example.com/', 'detail'); } public function testSendResponse() { $response = m::mock('\Omnipay\SagePay\Message\ServerCompleteAuthorizeResponse')->makePartial(); $response->shouldReceive('exitWith')->once()->with("Status=FOO\r\nRedirectUrl=https://www.example.com/"); $response->sendResponse('FOO', 'https://www.example.com/'); } public function testSendResponseDetail() { $response = m::mock('\Omnipay\SagePay\Message\ServerCompleteAuthorizeResponse')->makePartial(); $response->shouldReceive('exitWith')->once()->with("Status=FOO\r\nRedirectUrl=https://www.example.com/\r\nStatusDetail=Bar"); $response->sendResponse('FOO', 'https://www.example.com/', 'Bar'); } } Message/ServerAuthorizeRequestTest.php 0000604 00000001633 15173341464 0014222 0 ustar 00 <?php namespace Omnipay\SagePay\Message; use Omnipay\Tests\TestCase; class ServerAuthorizeRequestTest extends TestCase { public function setUp() { parent::setUp(); $this->request = new ServerAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'amount' => '12.00', 'transactionId' => '123', 'card' => $this->getValidCard(), ) ); } public function testProfile() { $this->assertSame($this->request, $this->request->setProfile('NORMAL')); $this->assertSame('NORMAL', $this->request->getProfile()); } public function getData() { $data = $this->request->getData(); $this->assertSame('https://www.example.com/return', $data['NotificationURL']); $this->assertSame('LOW', $data['Profile']); } } Message/DirectAuthorizeRequestTest.php 0000604 00000022531 15173341464 0014166 0 ustar 00 <?php namespace Omnipay\SagePay\Message; use Omnipay\Tests\TestCase; class DirectAuthorizeRequestTest extends TestCase { /** * @var \Omnipay\Common\Message\AbstractRequest $request */ protected $request; public function setUp() { parent::setUp(); $this->request = new DirectAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'amount' => '12.00', 'currency' => 'GBP', 'transactionId' => '123', 'card' => $this->getValidCard(), ) ); } public function testGetDataDefaults() { $data = $this->request->getData(); $this->assertSame('E', $data['AccountType']); $this->assertSame(0, $data['ApplyAVSCV2']); $this->assertSame(0, $data['Apply3DSecure']); } public function testGetData() { $this->request->setAccountType('M'); $this->request->setApplyAVSCV2(2); $this->request->setApply3DSecure(3); $this->request->setDescription('food'); $this->request->setClientIp('127.0.0.1'); $this->request->setReferrerId('3F7A4119-8671-464F-A091-9E59EB47B80C'); $data = $this->request->getData(); $this->assertSame('M', $data['AccountType']); $this->assertSame('food', $data['Description']); $this->assertSame('12.00', $data['Amount']); $this->assertSame('GBP', $data['Currency']); $this->assertSame('123', $data['VendorTxCode']); $this->assertSame('127.0.0.1', $data['ClientIPAddress']); $this->assertSame(2, $data['ApplyAVSCV2']); $this->assertSame(3, $data['Apply3DSecure']); $this->assertSame('3F7A4119-8671-464F-A091-9E59EB47B80C', $data['ReferrerID']); } public function testNoBasket() { // First with no basket set at all. $data = $this->request->getData(); $this->assertArrayNotHasKey('BasketXML', $data); // Then with a basket containing no items. $items = new \Omnipay\Common\ItemBag(array()); $this->request->setItems($items); $data = $this->request->getData(); $this->assertArrayNotHasKey('BasketXML', $data); } public function testBasket() { $items = new \Omnipay\Common\ItemBag(array( new \Omnipay\Common\Item(array( 'name' => 'Name', 'description' => 'Description', 'quantity' => 1, 'price' => 1.23, )) )); $basketXml = '<basket><item>' . '<description>Name</description><quantity>1</quantity>' . '<unitNetAmount>1.23</unitNetAmount><unitTaxAmount>0.00</unitTaxAmount>' . '<unitGrossAmount>1.23</unitGrossAmount><totalGrossAmount>1.23</totalGrossAmount>' . '</item></basket>'; $this->request->setItems($items); $data = $this->request->getData(); // The element does exist, and must contain the basket XML, with optional XML header and // trailing newlines. $this->assertArrayHasKey('BasketXML', $data); $this->assertContains($basketXml, $data['BasketXML']); } public function testGetDataNoReferrerId() { // Default value is equivalent to this: $this->request->setReferrerId(''); $data = $this->request->getData(); $this->assertArrayNotHasKey('ReferrerID', $data); } public function testGetDataCustomerDetails() { $card = $this->request->getCard(); $data = $this->request->getData(); $this->assertSame($card->getFirstName(), $data['BillingFirstnames']); $this->assertSame($card->getLastName(), $data['BillingSurname']); $this->assertSame($card->getBillingAddress1(), $data['BillingAddress1']); $this->assertSame($card->getBillingAddress2(), $data['BillingAddress2']); $this->assertSame($card->getBillingCity(), $data['BillingCity']); $this->assertSame($card->getBillingPostcode(), $data['BillingPostCode']); $this->assertSame($card->getBillingState(), $data['BillingState']); $this->assertSame($card->getBillingCountry(), $data['BillingCountry']); $this->assertSame($card->getBillingPhone(), $data['BillingPhone']); $this->assertSame($card->getFirstName(), $data['DeliveryFirstnames']); $this->assertSame($card->getLastName(), $data['DeliverySurname']); $this->assertSame($card->getShippingAddress1(), $data['DeliveryAddress1']); $this->assertSame($card->getShippingAddress2(), $data['DeliveryAddress2']); $this->assertSame($card->getShippingCity(), $data['DeliveryCity']); $this->assertSame($card->getShippingPostcode(), $data['DeliveryPostCode']); $this->assertSame($card->getShippingState(), $data['DeliveryState']); $this->assertSame($card->getShippingCountry(), $data['DeliveryCountry']); $this->assertSame($card->getShippingPhone(), $data['DeliveryPhone']); } public function testGetDataCustomerDetailsIgnoresStateOutsideUS() { $card = $this->request->getCard(); $card->setBillingCountry('UK'); $card->setShippingCountry('NZ'); $data = $this->request->getData(); // these must be empty string, not null // (otherwise Guzzle ignores them, and SagePay throws a fit) $this->assertSame('', $data['BillingState']); $this->assertSame('', $data['DeliveryState']); } public function testGetDataVisa() { $this->request->getCard()->setNumber('4929000000006'); $data = $this->request->getData(); $this->assertSame('visa', $data['CardType']); } public function testGetDataMastercard() { $this->request->getCard()->setNumber('5404000000000001'); $data = $this->request->getData(); $this->assertSame('mc', $data['CardType']); } public function testGetDataDinersClub() { $this->request->getCard()->setNumber('30569309025904'); $data = $this->request->getData(); $this->assertSame('dc', $data['CardType']); } public function testGetDataNullBillingAddress2() { $card = $this->request->getCard(); // This emulates not setting the billing address 2 at all // (it defaults to null). $card->setBillingAddress2(null); $data = $this->request->getData(); $this->assertNull($data['BillingAddress2']); // This tests that the BillingAddress2 may be left unset, // which defaults to null. When it is sent to SagePay, it gets // converted to an empty string. I'm not clear how that would be // tested. } public function testBasketWithNoDiscount() { $items = new \Omnipay\Common\ItemBag(array( new \Omnipay\Common\Item(array( 'name' => 'Name', 'description' => 'Description', 'quantity' => 1, 'price' => 1.23, )) )); $this->request->setItems($items); $data = $this->request->getData(); // The element does exist, and must contain the basket XML, with optional XML header and // trailing newlines. $this->assertArrayHasKey('BasketXML', $data); $this->assertNotContains('<discount>', $data['BasketXML']); } public function testMixedBasketWithSpecialChars() { $items = new \Omnipay\Common\ItemBag(array( new \Omnipay\Common\Item(array( 'name' => "Denisé's Odd & Wierd £name? #12345678901234567890123456789012345678901234567890123456789012345678901234567890", 'description' => 'Description', 'quantity' => 2, 'price' => 4.23, )), array( 'name' => "Denisé's \"Odd\" & Wierd £discount? #", 'description' => 'My Offer', 'quantity' => 2, 'price' => -0.10, ), array( // 101 character name 'name' => '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901', 'description' => 'My 2nd Offer', 'quantity' => 1, 'price' => -1.60, ) )); // Names/descriptions should be max 100 characters in length, once invalid characters have been removed. $expected = '<basket><item>' . '<description>Denis\'s Odd & Wierd name 123456789012345678901234567890123456789012345678901234567890123456789012345</description><quantity>2</quantity>' . '<unitNetAmount>4.23</unitNetAmount><unitTaxAmount>0.00</unitTaxAmount>' . '<unitGrossAmount>4.23</unitGrossAmount><totalGrossAmount>8.46</totalGrossAmount>' . '</item><discounts>' . '<discount><fixed>0.2</fixed><description>Denis\'s "Odd" Wierd discount? #</description></discount>' . '<discount><fixed>1.6</fixed><description>1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890</description></discount>' . '</discounts></basket>'; $this->request->setItems($items); $data = $this->request->getData(); $this->assertArrayHasKey('BasketXML', $data); $this->assertContains($expected, $data['BasketXML'], 'Basket XML does not match the expected output'); } } Message/ServerAuthorizeResponseTest.php 0000604 00000003675 15173341464 0014400 0 ustar 00 <?php namespace Omnipay\SagePay\Message; use Omnipay\Tests\TestCase; class ServerAuthorizeResponseTest extends TestCase { public function setUp() { $this->getMockRequest()->shouldReceive('getTransactionId')->andReturn('123456'); } public function testServerPurchaseSuccess() { $httpResponse = $this->getMockHttpResponse('ServerPurchaseSuccess.txt'); $response = new ServerAuthorizeResponse($this->getMockRequest(), $httpResponse->getBody()); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('{"SecurityKey":"IK776BWNHN","VPSTxId":"{1E7D9C70-DBE2-4726-88EA-D369810D801D}","VendorTxCode":"123456"}', $response->getTransactionReference()); $this->assertSame('Server transaction registered successfully.', $response->getMessage()); $this->assertSame('https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D}', $response->getRedirectUrl()); $this->assertSame('GET', $response->getRedirectMethod()); $this->assertNull($response->getRedirectData()); } public function testServerPurchaseRepeated() { $response = new ServerAuthorizeResponse($this->getMockRequest(), 'Status=OK REPEATED'); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); } public function testServerPurchaseFailure() { $httpResponse = $this->getMockHttpResponse('ServerPurchaseFailure.txt'); $response = new ServerAuthorizeResponse($this->getMockRequest(), $httpResponse->getBody()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('{"VendorTxCode":"123456"}', $response->getTransactionReference()); $this->assertSame('3082 : The Description value is too long.', $response->getMessage()); } } Mock/ServerPurchaseFailure.txt 0000604 00000000510 15173341464 0012447 0 ustar 00 HTTP/1.1 200 OK P3P: CP="CUR" Content-Language: en-GB Content-Length: 88 Date: Tue, 20 Jan 2015 16:45:41 GMT Server: undisclosed Set-Cookie: NSC_WRE-uftu.tbhfqbz.dpn-Kbwb7=f76fde52445f8236609ebb88e4554f525455a4a4d5e0;path=/;secure;httponly VPSProtocol=3.00 Status=INVALID StatusDetail=3082 : The Description value is too long. Mock/DirectPurchaseFailure.txt 0000604 00000000634 15173341464 0012422 0 ustar 00 HTTP/1.1 200 OK Date: Sat, 16 Feb 2013 06:40:30 GMT Server: Microsoft-IIS/6.0 P3P: CP="CUR" X-Powered-By: ASP.NET Content-Length: 156 Content-Type: Text/Plain Set-Cookie: ASPSESSIONIDSEHSCTTR=PIMGGPBDEAHAGKNHFGMICIAM; secure; path=/ Cache-control: private VPSProtocol=3.00 Status=INVALID StatusDetail=The VendorTxCode '984297' has been used before. Each transaction you send should have a unique VendorTxCode. Mock/ServerPurchaseSuccess.txt 0000604 00000001024 15173341464 0012471 0 ustar 00 HTTP/1.1 200 OK Date: Sat, 16 Feb 2013 09:02:04 GMT Server: Microsoft-IIS/6.0 P3P: CP="CUR" X-Powered-By: ASP.NET Content-Length: 281 Content-Type: Text/Plain Set-Cookie: ASPSESSIONIDSEHSCTTR=JAEHGPBDBOBICGBGJEHFJHPE; secure; path=/ Cache-control: private VPSProtocol=3.00 Status=OK StatusDetail=Server transaction registered successfully. VPSTxId={1E7D9C70-DBE2-4726-88EA-D369810D801D} SecurityKey=IK776BWNHN NextURL=https://test.sagepay.com/Simulator/VSPServerPaymentPage.asp?TransactionID={1E7D9C70-DBE2-4726-88EA-D369810D801D} Mock/DirectPurchaseSuccess.txt 0000604 00000000760 15173341464 0012443 0 ustar 00 HTTP/1.1 200 OK Date: Sat, 16 Feb 2013 06:39:41 GMT Server: Microsoft-IIS/6.0 P3P: CP="CUR" X-Powered-By: ASP.NET Content-Length: 249 Content-Type: Text/Plain Set-Cookie: ASPSESSIONIDSEHSCTTR=CIMGGPBDFDIKICAGIIHCNFHJ; secure; path=/ Cache-control: private VPSProtocol=3.00 Status=OK StatusDetail=Direct transaction from Simulator. VPSTxId={5A1BC414-5409-48DD-9B8B-DCDF096CE0BE} SecurityKey=OUWLNYQTVT TxAuthNo=9962 AVSCV2=ALL MATCH AddressResult=MATCHED PostCodeResult=MATCHED CV2Result=MATCHED Mock/DirectPurchase3dSecure.txt 0000604 00000001144 15173341464 0012505 0 ustar 00 HTTP/1.1 200 OK Date: Sat, 16 Feb 2013 06:53:15 GMT Server: Microsoft-IIS/6.0 P3P: CP="CUR" X-Powered-By: ASP.NET Content-Length: 359 Content-Type: Text/Plain Set-Cookie: ASPSESSIONIDSEHSCTTR=FDNGGPBDBPAHLBIMINACENLN; secure; path=/ Cache-control: private VPSProtocol=3.00 Status=3DAUTH 3DSecureStatus=OK MD=065379457749061954 ACSURL=https://test.sagepay.com/Simulator/3DAuthPage.asp PAReq=BSkaFwYFFTYAGyFbAB0LFRYWBwsBZw0EGwECEX9YRGFWc08pJCVVKgAANS0KADoZCCAMBnIeOxcWRg0LERdOOTQRDFRdVHNYUgwTMBsBCxABJw4DJHE+ERgPCi8MVC0HIAROCAAfBUk4ER89DD0IWDkvMQ1VdFwoUFgwXVYvbHgvMkdBXXNbQGIjdl1ZUEc1XSwqAAgUUicYBDYcB3I2AjYjIzsn
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings