Skip to content

Commit

Permalink
add requestOption when creating customers (#1692)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarreiro85 authored Jul 8, 2024
1 parent 98fa78e commit 5512f24
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit 5512f24

Please sign in to comment.