Skip to content

Commit eb5f6da

Browse files
committed
Add payment token support
1 parent 7960ce3 commit eb5f6da

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Diff for: src/Message/AbstractRequest.php

+10
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,14 @@ public function getEndpoint()
340340
{
341341
return $this->endpoint;
342342
}
343+
344+
public function getPaymentToken()
345+
{
346+
return $this->getParameter('payment_token');
347+
}
348+
349+
public function setPaymentToken($value)
350+
{
351+
return $this->setParameter('payment_token', $value);
352+
}
343353
}

Diff for: src/Message/DirectPostCreateCardRequest.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ class DirectPostCreateCardRequest extends AbstractRequest
1111

1212
public function getData()
1313
{
14-
$this->validate('card');
15-
$this->getCard()->validate();
16-
14+
$this->validate('card');
1715
$data = $this->getBaseData();
1816

19-
$data['ccnumber'] = $this->getCard()->getNumber();
20-
$data['ccexp'] = $this->getCard()->getExpiryDate('my');
17+
if ($paymentToken = $this->getPaymentToken()) {
18+
$data['payment_token'] = $paymentToken;
19+
} else {
20+
$this->getCard()->validate();
21+
$data['ccnumber'] = $this->getCard()->getNumber();
22+
$data['ccexp'] = $this->getCard()->getExpiryDate('my');
23+
}
2124
$data['payment'] = 'creditcard';
2225

2326
if ('update_customer' === $this->customer_vault) {

0 commit comments

Comments
 (0)