Refunds

Refunds

A refund returns all or part of a paid payment. Several partial refunds may be issued as long as they total no more than the payment. Make a payment first, by paying a payment intent or completing a Guest checkout.

Read the Refunds docs

Every demonstration here makes a real PayMongo API call in test mode. Nothing is simulated, and no real money moves.

Refund a payment

Refund an amount of a paid payment. The reason requested_by_customer is sent as a raw string, since the package's RefundReason enum has only duplicate, fraudulent, and others.

Test mode: The amount may not exceed what is left of the payment after earlier refunds. A Maya payment can only be refunded in full on the day it was paid.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$refund = Paymongo::refunds()->create(
    attributes: [
        'amount' => 10000,
        'reason' => 'requested_by_customer',
        'notes' => 'Refunded from the Laravel PayMongo Playground',
        'payment_id' => '{payment id}',
    ],
);

Retrieve refund

Fetch a refund issued in the Playground to see whether it is still pending or has succeeded.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$refund = Paymongo::refunds()->retrieve(
    id: '{refund id}',
);

List refunds

Fetch one cursor page of refunds.

Test mode: PayMongo lists every refund on the account. The Playground shows only the ones issued through it.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$refund = Paymongo::refunds()->list(
    params: [
        'limit' => 20,
    ],
);

List the refunds of a payment

Narrow the list to one payment with the payment_id parameter.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$refund = Paymongo::refunds()->list(
    params: [
        'limit' => 20,
        'payment_id' => '{payment id}',
    ],
);