Refund a Payment

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

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

Creating a new refund

To refund money you need to create and fill Refund model:

    //$responsePayment - successful payment response
    $refund = $judopay->getModel('Refund');
            'receiptId' => $responsePayment['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 refund result

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

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

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

    [receiptId] => xxxxxxxxxx
    [originalReceiptId] => xxxxxxxx
    [yourPaymentReference] => xxxxxx
    [type] => Refund
    [createdAt] => 2016-08-17T12:44:55.4751+01:00
    [result] => Success
    [message] => Refund successful
    [judoId] => xxxxxxxxxx
    [merchantName] => xxxxxxx
    [appearsOnStatementAs] => xxxxxxxxxx    
    [originalAmount] => 10.00
    [netAmount] => 0.00
    [amount] => 10.00
    [currency] => GBP
    [cardDetails] => Array
            [cardLastfour] => 3436
            [endDate] => 1216
            [cardToken] => xxxxxxxxxxxxxx
            [cardType] => 1

    [consumer] => Array
            [consumerToken] => xxxxxxxxx
            [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.