Performing a Pre Authorization

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

Before you make a payment please check if your SDK is initialized

Create pre-authorization

To make a new pre-authorization with full card details:

    $preauth = $judopay->getModel('Preauth');
    $preauth->setAttributeValues(
        array(
            'judoId' => 'your_judo_id',
            'yourConsumerReference' => '12345',
            'yourPaymentReference' => '12345',
            'amount' => 1.01,
            'currency' => 'GBP',
            'cardNumber' => '4976000000003436',
            'expiryDate' => '12/15',
            'cv2' => 452
        )
    );

Note: Please make sure that you are using a unique Consumer Reference for each different consumer, and a unique Payment Reference for each transaction.

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

Check the pre-authorization result

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

    $response = $preauth->create();
    if ($response['result'] === 'Success') {
        echo 'Pre-authorization successful';
    } else {
        echo 'There were some problems while processing your pre-authorization';
    }

If the pre-authorization is successful, you'll receive a response array like this:

Array
(
    [receiptId] => xxxxxxxx
    [yourPaymentReference] => 12345
    [type] => PreAuth
    [createdAt] => 2016-08-15T08:50:46.9845+01:00
    [result] => Success
    [message] => AuthCode: xxxxxxx
    [judoId] => xxxxxxxxx
    [merchantName] => xxxx
    [appearsOnStatementAs] => xxxxxxxx    
    [originalAmount] => 1.01
    [amountCollected] => 0.00
    [netAmount] => 1.01
    [amount] => 1.01
    [currency] => GBP
    [cardDetails] => Array
        (
            [cardLastfour] => 3436
            [endDate] => 1220
            [cardToken] => xxxxxxxxx
            [cardType] => 1
        )

    [consumer] => Array
        (
            [consumerToken] => xxxxxxxxxxxxx
            [yourConsumerReference] => 12345
        )

    [risks] => Array
        (
            [postCodeCheck] => UNKNOWN
        )

)

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.