Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/Payment/Mollie.php
Show First 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | public function webhook(): int | ||||
// Get the payment details from Mollie | // Get the payment details from Mollie | ||||
// TODO: Consider https://github.com/mollie/mollie-api-php/issues/502 when it's fixed | // TODO: Consider https://github.com/mollie/mollie-api-php/issues/502 when it's fixed | ||||
$mollie_payment = mollie()->payments()->get($payment_id); | $mollie_payment = mollie()->payments()->get($payment_id); | ||||
$refunds = []; | $refunds = []; | ||||
if ($mollie_payment->isPaid()) { | if ($mollie_payment->isPaid()) { | ||||
// The payment is paid. Update the balance, and notify the user | // The payment is paid. Update the balance, and notify the user | ||||
if ($payment->status != Payment::STATUS_PAID && $payment->amount > 0) { | if ($payment->status != Payment::STATUS_PAID && $payment->amount >= 0) { | ||||
$credit = true; | $credit = true; | ||||
$notify = $payment->type == Payment::TYPE_RECURRING; | $notify = $payment->type == Payment::TYPE_RECURRING; | ||||
} | } | ||||
// The payment has been (partially) refunded. | // The payment has been (partially) refunded. | ||||
// Let's process refunds with status "refunded". | // Let's process refunds with status "refunded". | ||||
if ($mollie_payment->hasRefunds()) { | if ($mollie_payment->hasRefunds()) { | ||||
foreach ($mollie_payment->refunds() as $refund) { | foreach ($mollie_payment->refunds() as $refund) { | ||||
▲ Show 20 Lines • Show All 258 Lines • Show Last 20 Lines |