Skip to content

Commit ab9cac1

Browse files
authored
Merge pull request #63 from academe/pr60
PR60 + test
2 parents 4cef58d + 587d5fa commit ab9cac1

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/Message/AIMAbstractRequest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function setTransactionReference($value)
118118
$transactionRef = new TransactionReference();
119119
$transactionRef->setTransId($value);
120120
}
121+
121122
return $this->setParameter('transactionReference', $transactionRef);
122123
}
123124

@@ -130,6 +131,7 @@ public function setCardReference($value)
130131
if (!($value instanceof CardReference)) {
131132
$value = new CardReference($value);
132133
}
134+
133135
return parent::setCardReference($value);
134136
}
135137

@@ -140,15 +142,18 @@ public function setCardReference($value)
140142
public function getCardReference($serialize = true)
141143
{
142144
$value = parent::getCardReference();
145+
143146
if ($serialize) {
144147
$value = (string)$value;
145148
}
149+
146150
return $value;
147151
}
148152

149153
public function sendData($data)
150154
{
151155
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
156+
152157
$data = $data->saveXml();
153158
$httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
154159

@@ -162,10 +167,12 @@ public function sendData($data)
162167
public function getBaseData()
163168
{
164169
$data = new \SimpleXMLElement('<' . $this->requestType . '/>');
170+
165171
$data->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');
166172
$this->addAuthentication($data);
167173
$this->addReferenceId($data);
168174
$this->addTransactionType($data);
175+
169176
return $data;
170177
}
171178

@@ -178,6 +185,7 @@ protected function addAuthentication(\SimpleXMLElement $data)
178185
protected function addReferenceId(\SimpleXMLElement $data)
179186
{
180187
$txnId = $this->getTransactionId();
188+
181189
if (!empty($txnId)) {
182190
$data->refId = $this->getTransactionId();
183191
}
@@ -189,6 +197,7 @@ protected function addTransactionType(\SimpleXMLElement $data)
189197
// The extending class probably hasn't specified an "action"
190198
throw new InvalidRequestException();
191199
}
200+
192201
$data->transactionRequest->transactionType = $this->action;
193202
}
194203

@@ -213,6 +222,8 @@ protected function addBillingData(\SimpleXMLElement $data)
213222
/** @var CreditCard $card */
214223
if ($card = $this->getCard()) {
215224
// A card is present, so include billing and shipping details
225+
$req->customer->email = $card->getEmail();
226+
216227
$req->billTo->firstName = $card->getBillingFirstName();
217228
$req->billTo->lastName = $card->getBillingLastName();
218229
$req->billTo->company = $card->getBillingCompany();

src/Message/CIMAbstractRequest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ public function setValidationMode($value)
2424
public function getValidationMode()
2525
{
2626
$validationMode = $this->getParameter('validationMode');
27+
2728
if ($validationMode !== self::VALIDATION_MODE_NONE) {
2829
$validationMode = $this->getDeveloperMode() ? self::VALIDATION_MODE_TEST : self::VALIDATION_MODE_LIVE;
2930
}
31+
3032
return $validationMode;
3133
}
3234

@@ -100,6 +102,7 @@ public function getDefaultBillTo()
100102
public function sendData($data)
101103
{
102104
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
105+
103106
$data = $data->saveXml();
104107
$httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
105108

src/Message/CIMAuthorizeRequest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ protected function addPayment(\SimpleXMLElement $data)
1515

1616
/** @var mixed $req */
1717
$req = $data->transactionRequest;
18+
1819
/** @var CardReference $cardRef */
1920
$cardRef = $this->getCardReference(false);
21+
2022
$req->profile->customerProfileId = $cardRef->getCustomerProfileId();
23+
2124
$req->profile->paymentProfile->paymentProfileId = $cardRef->getPaymentProfileId();
25+
2226
if ($shippingProfileId = $cardRef->getShippingProfileId()) {
2327
$req->profile->shippingProfileId = $shippingProfileId;
2428
}

tests/Message/AIMAuthorizeRequestTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ class AIMAuthorizeRequestTest extends TestCase
1212
public function setUp()
1313
{
1414
$this->request = new AIMAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
15+
$card = $this->getValidCard();
16+
$card['email'] = 'example@example.net';
1517
$this->request->initialize(
1618
array(
1719
'clientIp' => '10.0.0.1',
1820
'amount' => '12.00',
1921
'customerId' => 'cust-id',
20-
'card' => $this->getValidCard(),
22+
'card' => $card,
2123
'duplicateWindow' => 0
2224
)
2325
);
@@ -30,6 +32,7 @@ public function testGetData()
3032
$this->assertEquals('authOnlyTransaction', $data->transactionRequest->transactionType);
3133
$this->assertEquals('10.0.0.1', $data->transactionRequest->customerIP);
3234
$this->assertEquals('cust-id', $data->transactionRequest->customer->id);
35+
$this->assertEquals('example@example.net', $data->transactionRequest->customer->email);
3336

3437
// Issue #38 Make sure the transactionRequest properties are correctly ordered.
3538
// This feels messy, but works.

0 commit comments

Comments
 (0)