Skip to content

Commit

Permalink
XOL-3365 Do not send customerIP for AIM request since it errors out (#17
Browse files Browse the repository at this point in the history
)

* Do not send customerIP for AIM request since it errors out

* Fixed failing tests
  • Loading branch information
anush authored Feb 24, 2017
1 parent c19bf0e commit 29e2193
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
9 changes: 0 additions & 9 deletions src/Message/AIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public function getData()
$this->addPayment($data);
$this->addSolutionId($data);
$this->addDescription($data);
$this->addCustomerIP($data);
$this->addBillingData($data);
$this->addRetail($data);
$this->addTransactionSettings($data);
Expand Down Expand Up @@ -59,14 +58,6 @@ protected function addDescription(\SimpleXMLElement $data)
}
}

protected function addCustomerIP(\SimpleXMLElement $data)
{
$ip = $this->getClientIp();
if (!empty($ip)) {
$data->transactionRequest->customerIP = $ip;
}
}

protected function addRetail(\SimpleXMLElement $data)
{
if ($this->isCardPresent()) {
Expand Down
12 changes: 10 additions & 2 deletions src/Message/CIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,24 @@ protected function addPayment(\SimpleXMLElement $data)

return $data;
}

}

protected function addBillingData(\SimpleXMLElement $data)
{
if ($this->isCardPresent()) {
return parent::addBillingData($data);
} else {
// Do nothing since billing information is already part of the customer profile
// Billing information is already part of the customer profile, so just add the IP address
$this->addCustomerIP($data);
return $data;
}
}

protected function addCustomerIP(\SimpleXMLElement $data)
{
$ip = $this->getClientIp();
if (!empty($ip)) {
$data->transactionRequest->customerIP = $ip;
}
}
}
11 changes: 6 additions & 5 deletions tests/CIMGatewayIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,25 @@ public function testCustomerAndPaymentProfile()
{
// Create a customer profile with the specified email (email is the identifier)
$email = uniqid('', true) . '@example.com';
$cardRef = $this->createCard(array('email' => $email));
$this->createCard(array('email' => $email));

// Create a new card in an existing customer profile
$card = $this->getValidCard();
$params = array(
'card' => $this->getValidCard(),
'card' => $card,
'name' => 'Kaywinnet Lee Frye',
'email' => $email,
);
$params['card']['number'] = '4007000000027';
$request = $this->gateway->createCard($params);
$request->setDeveloperMode(true);
$response = $request->send();
$this->assertTrue($response->isSuccessful(), 'Should be successful as we have created a payment profile');
$this->assertNotNull($response->getCardReference(), 'Card reference should be returned');
$cardRef = $response->getCardReference();

// Create a card with same number in an existing customer profile (should fail)
$params = array(
'card' => $this->getValidCard(),
'card' => $card,
'name' => 'Kaywinnet Lee Frye',
'email' => $email,
);
Expand All @@ -96,7 +97,7 @@ public function testCustomerAndPaymentProfile()

// Create a card with the same number in an existing customer profile with auto-update enabled
$params = array(
'card' => $this->getValidCard(),
'card' => $card,
'name' => 'Kaywinnet Lee Frye',
'email' => $email,
'forceCardUpdate' => true
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/AIMAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public function testGetData()
$data = $this->request->getData();

$this->assertEquals('authOnlyTransaction', $data->transactionRequest->transactionType);
$this->assertEquals('10.0.0.1', $data->transactionRequest->customerIP);
$this->assertEquals('cust-id', $data->transactionRequest->customer->id);

$setting = $data->transactionRequest->transactionSettings->setting[0];
$this->assertEquals('testRequest', $setting->settingName);
$this->assertEquals('false', $setting->settingValue);
$this->assertObjectNotHasAttribute('customerIP', $data->transactionRequest, 'should only set IP in shipTo');
$this->assertObjectNotHasAttribute('trackData', $data->transactionRequest->payment);
$this->assertObjectNotHasAttribute('retail', $data->transactionRequest);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/AIMPurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public function testGetData()
$data = $this->request->getData();

$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);
$this->assertEquals('false', $setting->settingValue);
$this->assertObjectNotHasAttribute('customerIP', $data->transactionRequest);
}
}
8 changes: 6 additions & 2 deletions tests/Message/CIMAuthorizeRequestTest.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 authorize transaction'
'description' => 'Test authorize transaction',
'clientIp' => '10.0.0.1'
)
);
}
Expand All @@ -26,6 +27,7 @@ public function testGetData()
$data = $this->request->getData();

$this->assertEquals('12.00', $data->transactionRequest->amount);
$this->assertEquals('10.0.0.1', $data->transactionRequest->customerIP);
$this->assertEquals('28972085', $data->transactionRequest->profile->customerProfileId);
$this->assertEquals('26317841', $data->transactionRequest->profile->paymentProfile->paymentProfileId);
$this->assertEquals('27057151', $data->transactionRequest->profile->shippingProfileId);
Expand All @@ -38,12 +40,14 @@ public function testShouldUseTrackDataIfCardPresent()
$card['tracks'] = '%B4242424242424242^SMITH/JOHN ^2511126100000000000000444000000?;4242424242424242=25111269999944401?';
$this->request->initialize(array(
'card' => $card,
'amount' => 21.00
'amount' => 21.00,
'clientIp' => '10.0.0.1'
));

$data = $this->request->getData();

$this->assertObjectNotHasAttribute('profile', $data->transactionRequest);
$this->assertObjectNotHasAttribute('customerIP', $data->transactionRequest, 'should not set IP for card present');
$this->assertObjectHasAttribute('trackData', $data->transactionRequest->payment);
}
}

0 comments on commit 29e2193

Please sign in to comment.