Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/Payment/Mollie.php
Show First 20 Lines • Show All 464 Lines • ▼ Show 20 Lines | protected static function mollieCustomerId(Wallet $wallet, bool $create = false): ?string | ||||
return $customer_id; | return $customer_id; | ||||
} | } | ||||
/** | /** | ||||
* Get the active Mollie auto-payment mandate | * Get the active Mollie auto-payment mandate | ||||
*/ | */ | ||||
protected static function mollieMandate(Wallet $wallet) | protected static function mollieMandate(Wallet $wallet) | ||||
{ | { | ||||
$customer_id = $wallet->getSetting('mollie_id'); | $settings = $wallet->getSettings(['mollie_id', 'mollie_mandate_id']); | ||||
$mandate_id = $wallet->getSetting('mollie_mandate_id'); | |||||
// Get the manadate reference we already have | // Get the manadate reference we already have | ||||
if ($customer_id && $mandate_id) { | if ($settings['mollie_id'] && $settings['mollie_mandate_id']) { | ||||
try { | try { | ||||
return mollie()->mandates()->getForId($customer_id, $mandate_id); | return mollie()->mandates()->getForId($settings['mollie_id'], $settings['mollie_mandate_id']); | ||||
} catch (ApiException $e) { | } catch (ApiException $e) { | ||||
// FIXME: What about 404? | // FIXME: What about 404? | ||||
if ($e->getCode() == 410) { | if ($e->getCode() == 410) { | ||||
// The mandate is gone, remove the reference | // The mandate is gone, remove the reference | ||||
$wallet->setSetting('mollie_mandate_id', null); | $wallet->setSetting('mollie_mandate_id', null); | ||||
return null; | return null; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |