From 02d7df21260cc6f0ee62a1aa5c492e19b3e38b5b Mon Sep 17 00:00:00 2001 From: Hugo Vacher Date: Tue, 27 Feb 2018 11:18:21 -0500 Subject: [PATCH 1/2] Send CVV2 with card reference transactions If the CVV2 is available, it should be sent with the transaction. --- src/Message/AuthorizeRequest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Message/AuthorizeRequest.php b/src/Message/AuthorizeRequest.php index a6a3329..127d3dc 100644 --- a/src/Message/AuthorizeRequest.php +++ b/src/Message/AuthorizeRequest.php @@ -239,6 +239,9 @@ public function getData() if ($this->getCardReference()) { $data['ORIGID'] = $this->getCardReference(); + if ($this->getCard()) { + $data['CVV2'] = $this->getCard()->getCvv(); + } } else { $this->validate('card'); $this->getCard()->validate(); From 086cd477f5afacb57e64b7d6e82e514f0f4582e4 Mon Sep 17 00:00:00 2001 From: Hugo Vacher Date: Tue, 27 Feb 2018 11:31:52 -0500 Subject: [PATCH 2/2] Add unit test --- tests/ProGatewayTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/ProGatewayTest.php b/tests/ProGatewayTest.php index fee8568..6c6b074 100644 --- a/tests/ProGatewayTest.php +++ b/tests/ProGatewayTest.php @@ -86,6 +86,26 @@ public function testReferencePurchaseSuccess() $this->assertEquals('A10A6AE7042E', $response->getTransactionReference()); } + public function testReferencePurchaseWithCvvSuccess() + { + $options = array( + 'amount' => '10.00', + 'cardReference' => 'abc123', + 'card' => new CreditCard(array( + 'cvv' => '123', + )), + ); + + $this->setMockHttpResponse('PurchaseSuccess.txt'); + + $request = $this->gateway->purchase($options); + $response = $request->send(); + + $this->assertArrayHasKey('CVV2', $request->getData()); + $this->assertTrue($response->isSuccessful()); + $this->assertEquals('A10A6AE7042E', $response->getTransactionReference()); + } + public function testPurchaseError() { $this->setMockHttpResponse('PurchaseFailure.txt');