Voiding requests

Igor Cândido edited this page Mar 21, 2018 · 4 revisions

Voiding 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 void

At first you need to create and fill Void model:

    //$responsePreauth - successful pre-authorization response
    $void = $judopay->getModel('VoidTransaction');
    $void->setAttributeValues(
        array(
            'judoId' => 'xxxxxxxxx',
            'receiptId' => $responsePreauth['receiptId'],
            'amount' => 1000.00
        )
    );

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

Check the void result

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

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

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

Array
(
    [receiptId] => xxxxxxxxxx
    [originalReceiptId] => xxxxxxxxx
    [type] => VOID
    [createdAt] => 2016-08-17T14:27:08.6789+01:00
    [result] => Success
    [message] => Void successful
    [judoId] => xxxxxxxx
    [merchantName] => xxxxxxx
    [appearsOnStatementAs] => xxxxxxxxxx    
    [originalAmount] => 1,000.00
    [amountCollected] => 0.00
    [netAmount] => 1,000.00
    [amount] => 1,000.00
    [currency] => GBP
    [cardDetails] => Array
        (
            [cardLastfour] => 3436
            [endDate] => 1220
            [cardToken] => xxxxxxxxxxxxxxxxxxxxxxxxx
            [cardType] => 1
        )

    [consumer] => Array
        (
            [consumerToken] => xxxxxxxxxx
            [yourConsumerReference] => xxxxxxx
        )
)

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.