laravel / cashier-stripe

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

[16.x] Add requestOption when creating customers #1692

Closed mbarreiro85 closed 1 month ago

mbarreiro85 commented 1 month ago

This allows users to use idempotency keys when creating new customers

https://docs.stripe.com/api/idempotent_requests

u01jmg3 commented 1 month ago

Curious, is there a reason the default value for $requestOptions has been set as null rather than [] to follow suit with $options?

driesvints commented 1 month ago

@u01jmg3 to match the stripe default

u01jmg3 commented 1 month ago

In that case, should $options (referred to as $params in Stripe) also have a default value of null because that's what Stripe uses?

https://github.com/laravel/cashier-stripe/blob/5512f24d3ff3e5f8b7aa362981bed0a75395b868/src/Concerns/ManagesCustomer.php#L61


/**
 * Creates a new customer object.
 *
 * @param null|array $params
 * @param null|array|string $options
 *
 * @throws \Stripe\Exception\ApiErrorException if the request fails
 *
 * @return \Stripe\Customer the created resource
 */
public static function create($params = null, $options = null)
{
    // ...
}
driesvints commented 1 month ago

@u01jmg3 yeah I guess you're right. Can you make that PR?

u01jmg3 commented 1 month ago

There are actually multiple places and that's just in ManagesCustomer.php. How would you like to proceed?

See: b8ababd

driesvints commented 1 month ago

ah I actually meant the other way around and making the new param from here with a [] default.