From 21380229319b1ea22845b7858c08b9db67399f9e Mon Sep 17 00:00:00 2001 From: "igor.s" Date: Thu, 6 Oct 2016 00:03:22 +0000 Subject: [PATCH] XOL-3122 Passing SolutionID to all transaction requests. --- src/AIMGateway.php | 11 +++++++++++ src/Message/AIMAbstractRequest.php | 21 +++++++++++++++++++++ src/Message/AIMAuthorizeRequest.php | 13 +++++++++++++ src/Message/CIMAuthorizeRequest.php | 5 ----- src/Message/SIMAbstractRequest.php | 10 ++++++++++ tests/Message/AIMPurchaseRequestTest.php | 2 ++ tests/Message/CIMPurchaseRequestTest.php | 4 +++- 7 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/AIMGateway.php b/src/AIMGateway.php index 53b6eea1..65cd2596 100644 --- a/src/AIMGateway.php +++ b/src/AIMGateway.php @@ -24,6 +24,7 @@ public function getDefaultParameters() return array( 'apiLoginId' => '', 'transactionKey' => '', + 'solutionId' => '', 'testMode' => false, 'developerMode' => false, 'liveEndpoint' => 'https://api.authorize.net/xml/v1/request.api', @@ -103,6 +104,16 @@ public function getDeviceType() return $this->getParameter('deviceType'); } + public function setSolutionId($value) + { + return $this->setParameter('solutionId', $value); + } + + public function getSolutionId() + { + return $this->getParameter('solutionId'); + } + /** * Sets the type of device used to collect the credit card data. A device type is required for card present * transactions. diff --git a/src/Message/AIMAbstractRequest.php b/src/Message/AIMAbstractRequest.php index 84f2d2f0..96799cf8 100644 --- a/src/Message/AIMAbstractRequest.php +++ b/src/Message/AIMAbstractRequest.php @@ -36,6 +36,16 @@ public function setTransactionKey($value) return $this->setParameter('transactionKey', $value); } + public function getSolutionId() + { + return $this->getParameter('solutionId'); + } + + public function setSolutionId($value) + { + return $this->setParameter('solutionId', $value); + } + public function getDeveloperMode() { return $this->getParameter('developerMode'); @@ -202,6 +212,17 @@ protected function addTransactionType(\SimpleXMLElement $data) $data->transactionRequest->transactionType = $this->action; } + protected function addSolutionId(\SimpleXMLElement $data) + { + /** @var mixed $req */ + $req = $data->transactionRequest; + + $solution = $this->getSolutionId(); + if (!empty($solution)) { + $req->solution->id = $solution; + } + } + /** * Adds billing data to a partially filled request data object. * diff --git a/src/Message/AIMAuthorizeRequest.php b/src/Message/AIMAuthorizeRequest.php index 7df44c8d..d4e77687 100644 --- a/src/Message/AIMAuthorizeRequest.php +++ b/src/Message/AIMAuthorizeRequest.php @@ -17,6 +17,8 @@ public function getData() $data = $this->getBaseData(); $data->transactionRequest->amount = $this->getAmount(); $this->addPayment($data); + $this->addSolutionId($data); + $this->addDescription($data); $this->addCustomerIP($data); $this->addBillingData($data); $this->addRetail($data); @@ -46,6 +48,17 @@ protected function addPayment(\SimpleXMLElement $data) } } + protected function addDescription(\SimpleXMLElement $data) + { + /** @var mixed $req */ + $req = $data->transactionRequest; + + $description = $this->getDescription(); + if (!empty($description)) { + $req->order->description = $description; + } + } + protected function addCustomerIP(\SimpleXMLElement $data) { $ip = $this->getClientIp(); diff --git a/src/Message/CIMAuthorizeRequest.php b/src/Message/CIMAuthorizeRequest.php index 6125a12f..51abd84a 100644 --- a/src/Message/CIMAuthorizeRequest.php +++ b/src/Message/CIMAuthorizeRequest.php @@ -28,11 +28,6 @@ protected function addPayment(\SimpleXMLElement $data) $req->profile->shippingProfileId = $shippingProfileId; } - $desc = $this->getDescription(); - if (!empty($desc)) { - $req->order->description = $desc; - } - return $data; } diff --git a/src/Message/SIMAbstractRequest.php b/src/Message/SIMAbstractRequest.php index b8f52e6a..58ae790d 100644 --- a/src/Message/SIMAbstractRequest.php +++ b/src/Message/SIMAbstractRequest.php @@ -34,6 +34,16 @@ public function setTransactionKey($value) return $this->setParameter('transactionKey', $value); } + public function getSolutionId() + { + return $this->getParameter('solutionId'); + } + + public function setSolutionId($value) + { + return $this->setParameter('solutionId', $value); + } + public function getDeveloperMode() { return $this->getParameter('developerMode'); diff --git a/tests/Message/AIMPurchaseRequestTest.php b/tests/Message/AIMPurchaseRequestTest.php index e7e47e08..77ec02bd 100644 --- a/tests/Message/AIMPurchaseRequestTest.php +++ b/tests/Message/AIMPurchaseRequestTest.php @@ -18,6 +18,7 @@ public function setUp() 'amount' => '12.00', 'customerId' => 'cust-id', 'card' => $this->getValidCard(), + 'solutionId' => 'AAA100302', ) ); } @@ -29,6 +30,7 @@ public function testGetData() $this->assertEquals('authCaptureTransaction', $data->transactionRequest->transactionType); $this->assertEquals('10.0.0.1', $data->transactionRequest->customerIP); $this->assertEquals('cust-id', $data->transactionRequest->customer->id); + $this->assertEquals('AAA100302', $data->transactionRequest->solution->id); $setting = $data->transactionRequest->transactionSettings->setting[0]; $this->assertEquals('testRequest', $setting->settingName); diff --git a/tests/Message/CIMPurchaseRequestTest.php b/tests/Message/CIMPurchaseRequestTest.php index aa90610e..076b98e7 100644 --- a/tests/Message/CIMPurchaseRequestTest.php +++ b/tests/Message/CIMPurchaseRequestTest.php @@ -16,7 +16,8 @@ public function setUp() array( 'cardReference' => '{"customerProfileId":"28972085","customerPaymentProfileId":"26317841","customerShippingAddressId":"27057151"}', 'amount' => '12.00', - 'description' => 'Test purchase transaction' + 'description' => 'Test purchase transaction', + 'solutionId' => 'AAA100302', ) ); } @@ -29,5 +30,6 @@ public function testGetData() $this->assertEquals('26317841', $data->transactionRequest->profile->paymentProfile->paymentProfileId); $this->assertEquals('27057151', $data->transactionRequest->profile->shippingProfileId); $this->assertEquals('Test purchase transaction', $data->transactionRequest->order->description); + $this->assertEquals('AAA100302', $data->transactionRequest->solution->id); } }