Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Concerns/ManagesCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ protected function assertCustomerExists()
* Create a Stripe customer for the given model.
*
* @param array $options
* @param array|null $requestOptions
* @return \Stripe\Customer
*
* @throws \Laravel\Cashier\Exceptions\CustomerAlreadyCreated
*/
public function createAsStripeCustomer(array $options = [])
public function createAsStripeCustomer(array $options = [], array $requestOptions = null)
{
if ($this->hasStripeId()) {
throw CustomerAlreadyCreated::exists($this);
Expand Down Expand Up @@ -90,7 +91,7 @@ public function createAsStripeCustomer(array $options = [])
// Here we will create the customer instance on Stripe and store the ID of the
// user from Stripe. This ID will correspond with the Stripe user instances
// and allow us to retrieve users from Stripe later when we need to work.
$customer = static::stripe()->customers->create($options);
$customer = static::stripe()->customers->create($options, $requestOptions);

$this->stripe_id = $customer->id;

Expand All @@ -116,15 +117,16 @@ public function updateStripeCustomer(array $options = [])
* Get the Stripe customer instance for the current user or create one.
*
* @param array $options
* @param array|null $requestOptions
* @return \Stripe\Customer
*/
public function createOrGetStripeCustomer(array $options = [])
public function createOrGetStripeCustomer(array $options = [], array $requestOptions = null)
{
if ($this->hasStripeId()) {
return $this->asStripeCustomer($options['expand'] ?? []);
}

return $this->createAsStripeCustomer($options);
return $this->createAsStripeCustomer($options, $requestOptions);
}

/**
Expand Down