Skip to content

Commit

Permalink
Merge pull request #39 from thephpleague/issue38
Browse files Browse the repository at this point in the history
Issue38
  • Loading branch information
judgej authored Jun 16, 2016
2 parents bd9523c + 45c85fc commit 439bb6e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Message/AIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public function getData()
$data = $this->getBaseData();
$data->transactionRequest->amount = $this->getAmount();
$this->addPayment($data);
$this->addCustomerIP($data);
$this->addBillingData($data);
$this->addCustomerIP($data);
$this->addTransactionSettings($data);

return $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Message/AIMResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(AbstractRequest $request, $data)
$xml = preg_replace('/<createTransactionResponse[^>]+>/', '<createTransactionResponse>', (string)$data);

try {
$xml = simplexml_load_string($xml);
$xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOWARNING);
} catch (\Exception $e) {
throw new InvalidResponseException();
}
Expand Down
17 changes: 17 additions & 0 deletions tests/Message/AIMAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ public function testGetData()
$this->assertEquals('10.0.0.1', $data->transactionRequest->customerIP);
$this->assertEquals('cust-id', $data->transactionRequest->customer->id);

// Issue #38 Make sure the transactionRequest properties are correctly ordered.
// This feels messy, but works.
$transactionRequestProperties = array_keys(get_object_vars($data->transactionRequest));
// The names of the properies of the $data->transactionRequest object, in the order in
// which they must be defined for Authorize.Net to accept the transaction.
$keys = array(
"transactionType",
"amount",
"payment",
"customer",
"billTo",
"shipTo",
"customerIP",
"transactionSettings"
);
$this->assertEquals($keys, $transactionRequestProperties);

$setting = $data->transactionRequest->transactionSettings->setting[0];
$this->assertEquals('testRequest', $setting->settingName);
$this->assertEquals('false', $setting->settingValue);
Expand Down

0 comments on commit 439bb6e

Please sign in to comment.