Skip to content

Commit

Permalink
XOL-5253 Allow accepting raw cards for AuthorizeNet_CIM (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Derick Mathew authored Jul 21, 2020
1 parent 78dfa34 commit b988bee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Message/AIMAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,9 @@ protected function isCardPresent()
// If the credit card has track data, then consider this a "card present" scenario
return ($card = $this->getCard()) && $card->getTracks();
}

protected function isRawCard()
{
return $this->getCard() && !$this->getCardReference();
}
}
2 changes: 2 additions & 0 deletions src/Message/CIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ protected function addPayment(\SimpleXMLElement $data)
if ($this->isCardPresent()) {
// Prefer the track data if present over the payment profile (better rate)
return parent::addPayment($data);
} else if ($this->isRawCard()) {
return parent::addPayment($data);
} else {
$this->validate('cardReference');

Expand Down
16 changes: 16 additions & 0 deletions tests/Message/CIMAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,20 @@ public function testShouldUseTrackDataIfCardPresent()
$this->assertObjectNotHasAttribute('customerIP', $data->transactionRequest, 'should not set IP for card present');
$this->assertObjectHasAttribute('trackData', $data->transactionRequest->payment);
}

public function testShouldAddPaymentIfRawCard()
{
$card = $this->getValidCard();
$this->request->initialize(array(
'card' => $card,
'amount' => 21.00
));

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

$this->assertObjectNotHasAttribute('profile', $data->transactionRequest);
$this->assertObjectHasAttribute('cardNumber', $data->transactionRequest->payment->creditCard);
$this->assertObjectHasAttribute('expirationDate', $data->transactionRequest->payment->creditCard);
$this->assertObjectHasAttribute('cardCode', $data->transactionRequest->payment->creditCard);
}
}

0 comments on commit b988bee

Please sign in to comment.