We're excited to announce the immediate availability of Cashier v13. This Cashier release introduces support for more payment methods and numerous other small improvements. We'll highlight some of the most significant improvements below.
New Payment Methods
Cashier's payment methods API's have been updated with support for specifying a payment method type, including the SEPA Debit payment method:
// Retrieve card payment methods on a user...
$paymentMethods = $user->paymentMethods();
// Retrieve all SEPA Debit payment methods on a user...
$paymentMethods = $user->paymentMethods('sepa_debit');
// Check if a user has any SEPA Debit payment methods...
if ($user->hasPaymentMethod('sepa_debit')) {
// ...
}
// Delete all SEPA Debit payment methods on a user...
$user->deletePaymentMethods('sepa_debit');
Of course, you should consult the Stripe Payment Method documentation to know how and which payment methods you can use in your own application.
A New Payment Page
The hosted payment page that ships with Cashier has been greatly revamped to provide support for more payment methods. This page is displayed when a payment failure occurs or extra confirmation is required to verify a payment.
The new payment page now supports the following payment methods:
- Credit Cards
- Alipay
- Bancontact
- BECS Direct Debit
- EPS
- Giropay
- iDEAL
- SEPA Direct Debit
Additionally, the page now supports saving a customer's payment method in Stripe so that it may be used for future payments.
Syncing Customer Data
To make it easier for applications to sync their customer details with Stripe own copy of those same details, Cashier is introducing a syncStripeCustomerDetails
method. For example, you might choose to add this method as an event listener to your billable model's updated
event to automatically sync the customer's name, email address, phone number, and address with Stripe:
/**
* The "booted" method of the model.
*
* @return void
*/
protected static function booted()
{
static::updated(queueable(function ($customer) {
$customer->syncStripeCustomerDetails();
}));
}
You can even customize the attributes that are used to provide this data to Stripe by overriding the corresponding Stripe method:
/**
* Get the customer name that should be synced to Stripe.
*
* @return string|null
*/
public function stripeName()
{
return $this->company_name;
}
Checking Product Identifiers
To accommodate for Stripe's new "Product" concept, we've introduced a new stripe_product
column on the subscription_items
table. This will allow Cashier to check if a customer is subscribed to a specific product:
if ($user->subscribedToProduct('prod_premium', 'default')) {
//
}
Using this feature allows you to organize specific prices that belong to a given "tier" under a single product. Then, you may easily introduce new prices for a given tier without having to change any code.
You may also check if the customer is subscribed to one of multiple products:
if ($user->subscribedToProduct(['product_basic', 'prod_premium'], 'default')) {
//
}
Multiple Discounts On Receipts
Cashier's downloadable receipts will now properly display multiple discounts. These discounts will be displayed just as they would on Stripe's own receipts:
Previewing Invoices
You may now preview the invoice for any price change via the previewInvoice
method:
$previewInvoice = $subscription->previewInvoice('price_to_swap');
Additionally, you may now also specifically inspect the upcoming invoice of a specific subscription if a customer has multiple subscriptions:
$upcomingInvoice = $user->subscription('default')->upcomingInvoice();
More Data On Receipts
Cashier receipts now include additional information. Most of this information is the same information that is displayed on Stripe's own receipt, together with all of the receipt's VAT related information. Here's a before / after comparison of these changes:
Conclusion
In addition to the new features discussed above, Cashier v13 also includes additional internal refactoring, bug fixes, and improvements.
To upgrade to this latest version of Cashier, please check out the full changelog and upgrade guide.
We hope you enjoy this new Cashier Stripe release!