Closed peeyush1234 closed 6 years ago
I don't speak for @taylorotwell on these matters, but I feel you could just request and store this data yourself without needing to change cashier.
function whenCardUpdated($billableStripeModel)
{
$card = $billableStripeModel->cards()->first();
echo $card->exp_month;
echo $card->exp_year
//store
}
@mrsimonbennett Thanks for your reply. I am able to support my use case. Closing the issue.
For anyone else needing a way to save the expiration date for various reasons, here's a slightly altered version of the code from @mrsimonbennett that uses Carbon to save the expiry on the desired model:
public function whenCardUpdated()
{
$account = account(); // Account is my billable Stripe model
$card = $account->cards()->first();
$expiresAt = \Carbon\Carbon::createFromDate($card->exp_year, $card->exp_month)->endOfMonth();
$account->card_expires_at = $expiresAt;
$account->save();
}
Be sure to create this new field with whatever name you choose! Laravel Spark and Cashier do not implement this field for you.
Where do I implement this? On billable model [ie: App/User] ?
Or using observer?
As per the documentation https://laravel.com/docs/5.6/billing#introduction, Cashier only lets you store the last 4 digits and card brand in the app. For my team use case, we need to store the expiration month and year.
Are there any plans for adding the support for expiration date?
If I create a pull request to add the expiration date, would it be possible to add it to the cashier? If yes, then I can start working on it.