mirror of
https://github.com/anikeen-com/id.git
synced 2026-05-29 16:41:32 +00:00
add set default payment method
Signed-off-by: Maurice Preuß <envoyr@froxlor.org>
This commit is contained in:
@@ -60,6 +60,19 @@ trait ManagesPaymentMethods
|
|||||||
return $this->paymentMethods()->hasDefaultPaymentMethod();
|
return $this->paymentMethods()->hasDefaultPaymentMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the default payment method for the current user.
|
||||||
|
*
|
||||||
|
* @throws Throwable
|
||||||
|
* @see \Anikeen\Id\Resources\PaymentMethods::setDefault()
|
||||||
|
*/
|
||||||
|
public function setDefaultPaymentMethod(string $id): PaymentMethod
|
||||||
|
{
|
||||||
|
unset($this->paymentMethodsCache);
|
||||||
|
|
||||||
|
return $this->paymentMethods()->setDefault($id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get billing portal URL for the current user.
|
* Get billing portal URL for the current user.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -45,6 +45,20 @@ class PaymentMethods extends BaseCollection
|
|||||||
return $this->defaultPaymentMethodCache;
|
return $this->defaultPaymentMethodCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the default payment method for the current user.
|
||||||
|
*
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
public function setDefault(string $id): PaymentMethod
|
||||||
|
{
|
||||||
|
unset($this->defaultPaymentMethodCache);
|
||||||
|
|
||||||
|
return (new PaymentMethod(fn() => $this->billable->anikeenId()
|
||||||
|
->request('PUT', sprintf('v1/payment-methods/%s/default', $id))))
|
||||||
|
->setBillable($this->billable);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user