payments->get($paymentId);
if ($payment->canBeRefunded() && $payment->amountRemaining->currency === 'EUR' && $payment->amountRemaining->value >= '2.00') {
/*
* Refund € 2,00 of the payment.
*
* https://docs.mollie.com/reference/v2/refunds-api/create-refund
*/
$refund = $payment->refund([
"amount" => [
"currency" => "EUR",
"value" => "2.00", // You must send the correct number of decimals, thus we enforce the use of strings
],
]);
echo "{$refund->amount->currency} {$refund->amount->value} of payment {$paymentId} refunded.", PHP_EOL;
} else {
echo "Payment {$paymentId} can not be refunded.", PHP_EOL;
}
/*
* Retrieve all refunds on a payment.
*/
echo "
";
foreach ($payment->refunds() as $refund) {
echo "