Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/Payment/Stripe.php
Show First 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | public function webhook(): int | ||||
default: | default: | ||||
$status = Payment::STATUS_FAILED; | $status = Payment::STATUS_FAILED; | ||||
} | } | ||||
if ($status == Payment::STATUS_PAID) { | if ($status == Payment::STATUS_PAID) { | ||||
$payment->wallet->setSetting('stripe_mandate_id', $intent->id); | $payment->wallet->setSetting('stripe_mandate_id', $intent->id); | ||||
$threshold = intval((float) $payment->wallet->getSetting('mandate_balance') * 100); | $threshold = intval((float) $payment->wallet->getSetting('mandate_balance') * 100); | ||||
// Call credit() so wallet/account state is updated | |||||
$this->creditPayment($payment, $intent); | |||||
// Top-up the wallet if balance is below the threshold | // Top-up the wallet if balance is below the threshold | ||||
if ($payment->wallet->balance < $threshold && $payment->status != Payment::STATUS_PAID) { | if ($payment->wallet->balance < $threshold && $payment->status != Payment::STATUS_PAID) { | ||||
\App\Jobs\WalletCharge::dispatch($payment->wallet); | \App\Jobs\WalletCharge::dispatch($payment->wallet); | ||||
} | } | ||||
} | } | ||||
$payment->status = $status; | $payment->status = $status; | ||||
$payment->save(); | $payment->save(); | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |