Skip to content

Commit a0c8b21

Browse files
committed
Merge pull request #27 from AxiomSteve/master
Allow authorize request with customerId instead of token or nonce
2 parents 15b4fb4 + f4f360d commit a0c8b21

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/Message/AuthorizeRequest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ public function getData()
3737
// special validation
3838
if ($this->getPaymentMethodToken()) {
3939
$data['paymentMethodToken'] = $this->getPaymentMethodToken();
40-
} elseif($this->getToken()) {
40+
} elseif ($this->getToken()) {
4141
$data['paymentMethodNonce'] = $this->getToken();
42+
} elseif ($this->getCustomerId()) {
43+
$data['customerId'] = $this->getCustomerId();
4244
} else {
43-
throw new InvalidRequestException("The token (payment nonce) or paymentMethodToken field should be set.");
45+
throw new InvalidRequestException("The token (payment nonce), paymentMethodToken or customerId field should be set.");
4446
}
4547

4648
// Remove null values

tests/Message/AuthorizeRequestTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,28 @@ public function testPaymentMethodNonce()
9393
$this->assertArrayNotHasKey('paymentMethodToken', $data);
9494
}
9595

96+
public function testCustomerId()
97+
{
98+
$this->request->initialize(
99+
array(
100+
'amount' => '10.00',
101+
'transactionId' => '684',
102+
'testMode' => false,
103+
'taxExempt' => false,
104+
'card' => array(
105+
'firstName' => 'Kayla',
106+
'shippingCompany' => 'League',
107+
),
108+
'customerId' => 'abc123'
109+
)
110+
);
111+
112+
$data = $this->request->getData();
113+
$this->assertSame('abc123', $data['customerId']);
114+
$this->assertArrayNotHasKey('paymentMethodToken', $data);
115+
$this->assertArrayNotHasKey('paymentMethodNonce', $data);
116+
}
117+
96118
public function testSubMerchantSale()
97119
{
98120
$this->request->initialize(

0 commit comments

Comments
 (0)