Skip to content

Commit

Permalink
Merge pull request #16 from mightytroll/XOL-3122
Browse files Browse the repository at this point in the history
XOL-3122 Authorize.net solution certification
  • Loading branch information
anush authored Oct 17, 2016
2 parents c56f982 + 2138022 commit c19bf0e
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/AIMGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions src/Message/AIMAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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.
*
Expand Down
13 changes: 13 additions & 0 deletions src/Message/AIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 0 additions & 5 deletions src/Message/CIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 10 additions & 0 deletions src/Message/SIMAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions tests/Message/AIMPurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function setUp()
'amount' => '12.00',
'customerId' => 'cust-id',
'card' => $this->getValidCard(),
'solutionId' => 'AAA100302',
)
);
}
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion tests/Message/CIMPurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
);
}
Expand All @@ -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);
}
}

0 comments on commit c19bf0e

Please sign in to comment.