Skip to content

Commit 652b6b7

Browse files
committed
README: examples code snippets for capture()
1 parent e22e89e commit 652b6b7

File tree

1 file changed

+59
-7
lines changed

1 file changed

+59
-7
lines changed

README.md

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,65 @@ If the `useAuthenticate` parameter was set when the transaction was originally
631631
authorized, then it must be used in the capture too.
632632

633633
* Setting the `useAuthenticate` parameter will cause the capture to send
634-
an `AUTHORISE` request. You must supply an `amount` and `description`
635-
when doing this. You can capture multiple amounts up to 115% of the
636-
original `AUTHENTICATED` amount.
637-
* Resetting the `useAuthenticate` parameter (the default) will cause the
638-
capture to send a `RELEASE` request. This will release the total amount
639-
that was originally `DEFERRED`. You can only capture a deferred payment
640-
once, and it will be for the full amount.
634+
an `AUTHORISE` request. You must supply an `amount`, a `description`
635+
and a new `transactionId` when doing this.
636+
You can capture multiple amounts up to 115% of the
637+
original `AUTHENTICATED` (with 3D Secure) or `REGISTERED` (without 3D Secure)
638+
amount.
639+
* Resetting the `useAuthenticate` parameter (false, the default mode) will cause
640+
the capture to send a `RELEASE` request. This will release the provided amount
641+
(up to the original deferred amount, but no higher) that was originally `DEFERRED`.
642+
You can only capture a deferred payment once, then the deferred payment will be
643+
closed.
644+
645+
Examples of each:
646+
647+
```php
648+
$captureRequest = $gateway->capture([
649+
// authenticate is not set
650+
'useAuthenticate' => false,
651+
// Provide either the original transactionReference:
652+
'transactionReference' => $deferredTransactionReference,
653+
// Or the individual items:
654+
'securityKey' => $savedSecurityKey(),
655+
'txAuthNo' => $savedTxAuthNo(),
656+
'vpsTxId' => $savedVPSTxId(),
657+
'relatedTransactionId' => $savedTransactionId,
658+
// Up to the original amount, one chance only.
659+
'amount' => '99.99',
660+
]);
661+
```
662+
663+
```php
664+
$captureRequest = $gateway->capture([
665+
// authenticate is set
666+
'useAuthenticate' => true,
667+
// Provide either the original transactionReference:
668+
'transactionReference' => $deferredTransactionReference,
669+
// Or the individual items:
670+
'securityKey' => $savedSecurityKey(),
671+
'txAuthNo' => $savedTxAuthNo(),
672+
'vpsTxId' => $savedVPSTxId(),
673+
'relatedTransactionId' => $savedTransactionId,
674+
// Up to 115% of the original amount, in as many chunks as you like.
675+
'amount' => '9.99',
676+
// The capture becomes a transaction in its own right.
677+
'transactionId' => $newTransactionId,
678+
'currency' => 'GBP',
679+
'description' => 'Take staged payment number 1',
680+
]);
681+
```
682+
683+
In both cases, send the message and check the result.
684+
685+
```php
686+
$captureResponse = $captureRequest->send();
687+
688+
if ($captureResponse->isSuccessful()) {
689+
// The capture will successful.
690+
// There will never be a redirect here.
691+
}
692+
```
641693

642694
### Delete Card
643695

0 commit comments

Comments
 (0)