Skip to content

Commit

Permalink
Merge pull request #27 from AxiomSteve/master
Browse files Browse the repository at this point in the history
Allow authorize request with customerId instead of token or nonce
  • Loading branch information
delatbabel committed May 16, 2016
2 parents 15b4fb4 + f4f360d commit a0c8b21
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Message/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ public function getData()
// special validation
if ($this->getPaymentMethodToken()) {
$data['paymentMethodToken'] = $this->getPaymentMethodToken();
} elseif($this->getToken()) {
} elseif ($this->getToken()) {
$data['paymentMethodNonce'] = $this->getToken();
} elseif ($this->getCustomerId()) {
$data['customerId'] = $this->getCustomerId();
} else {
throw new InvalidRequestException("The token (payment nonce) or paymentMethodToken field should be set.");
throw new InvalidRequestException("The token (payment nonce), paymentMethodToken or customerId field should be set.");
}

// Remove null values
Expand Down
22 changes: 22 additions & 0 deletions tests/Message/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,28 @@ public function testPaymentMethodNonce()
$this->assertArrayNotHasKey('paymentMethodToken', $data);
}

public function testCustomerId()
{
$this->request->initialize(
array(
'amount' => '10.00',
'transactionId' => '684',
'testMode' => false,
'taxExempt' => false,
'card' => array(
'firstName' => 'Kayla',
'shippingCompany' => 'League',
),
'customerId' => 'abc123'
)
);

$data = $this->request->getData();
$this->assertSame('abc123', $data['customerId']);
$this->assertArrayNotHasKey('paymentMethodToken', $data);
$this->assertArrayNotHasKey('paymentMethodNonce', $data);
}

public function testSubMerchantSale()
{
$this->request->initialize(
Expand Down

0 comments on commit a0c8b21

Please sign in to comment.