laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.39k stars 679 forks source link

Support for creating Tax IDs on the customer #1071

Closed benjamindoe closed 3 years ago

benjamindoe commented 3 years ago

Currently, there's no way of creating Customer Tax IDs from the user object. This must be done using the Stripe SDK directly

\Stripe\Customer::createTaxId($user->stripe_id, [
    'type' => \Stripe\TaxId::TYPE_EU_VAT,
    'value' => 'DE12345678'
], $user->stripeOptions());

Currently, you can get all Tax IDs using the Stripe customer directly, (which isn't so bad)

$user->asStripeCustomer()->tax_ids

It would be nice to have full integration with tax IDs to make things a bit more fluent and Eloquent relationship-like, for example

$user->taxIds()->create([
    'type' => 'eu_vat', // Possibly throw Exception if unknown ENUM?
    'value' => 'DE12345678'
]);

If that's a bit much, simple helpers to the Stripe SDK would also be nice

$user->taxIds(); // Return instance of \Illuminate\Support\Collection
$user->taxId('txi_IzcmyhZukd4oKD'); // Retrieve Tax ID by Stripe ID
$user->createTaxId($type, $value);
$user->deleteTaxId('txi_IzcmyhZukd4oKD'); // delete Tax ID by Stripe ID

There's no fluent way of using the Stripe customer object directly as the createTaxId function on \Stripe\Customer is static, which is unfortunate.

driesvints commented 3 years ago

Thanks @benjamindoe. We'll be looking at adding some nice API's around Tax Id's soon as well as customer billing address details. Appreciating PR's however in the meantime. I like your proposal of making a fluent API but without making that actually Eloquent like of course.

driesvints commented 3 years ago

Here's the PR: https://github.com/laravel/cashier-stripe/pull/1137