Collecting on a Pre Authorization

Michael Hancock edited this page Apr 5, 2017 · 5 revisions

Collecting a pre-auth requires that you have the receiptId and amount of the pre-auth transaction. Before you make a payment please check if your SDK is initialized.

Creating a new collection

To collect a pre-auth funds you need to create and fill Collection model:

    //$responsePreauth - successful pre-authorization response
    $collection = $judopay->getModel('Collection');
    $collection->setAttributeValues(
        array(
            'receiptId' => $responsePreauth['receiptId'],
            'yourPaymentReference' => 'xxxxxx',
            'amount' => 10.00,
        )
    );

You can check on the required fields and the format of each field in the Judopay REST API reference.

Check the collection result

And after that you need to send the request to the API. Your code will look like that:

    $response = $collection->create();
    if ($response['result'] === 'Success') {
        echo 'Successfully collected';
    } else {
        echo 'There were some problems while processing your collection';
    }

If the collection is successful, you'll receive a response array like this:

Array
(
    [receiptId] => xxxxxxxxxx
    [originalReceiptId] => xxxxxxxxx
    [yourPaymentReference] => xxxxxxxx
    [type] => Collection
    [createdAt] => 2016-08-17T12:20:29.8003+01:00
    [result] => Success
    [message] => Collection successful
    [judoId] => xxxxxxxxxx
    [merchantName] => xxxxxx
    [appearsOnStatementAs] => xxxxxxxx    
    [originalAmount] => 10.00
    [netAmount] => 10.00
    [amount] => 10.00
    [currency] => GBP
    [cardDetails] => Array
        (
            [cardLastfour] => 3436
            [endDate] => 1216
            [cardToken] => xxxxxxxxxxxxxxxx
            [cardType] => 1
        )

    [consumer] => Array
        (
            [consumerToken] => xxxxxxxxxxx
            [yourConsumerReference] => xxxxxx
        )
)

It is also important to handle different exceptions in your code. See our Error handling section.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.