Skip to content

Commit 62e918b

Browse files
authored
Add convenience methods to update stripe objects (#943)
1 parent 92eb7d8 commit 62e918b

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/Subscription.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,19 @@ public function guardAgainstMultiplePlans()
10111011
}
10121012
}
10131013

1014+
/**
1015+
* Update the underlying Stripe subscription information for the model.
1016+
*
1017+
* @param array $options
1018+
* @return \Stripe\Subscription
1019+
*/
1020+
public function updateStripeSubscription(array $options = [])
1021+
{
1022+
return StripeSubscription::update(
1023+
$this->stripe_id, $options, $this->owner->stripeOptions()
1024+
);
1025+
}
1026+
10141027
/**
10151028
* Get the subscription as a Stripe subscription object.
10161029
*
@@ -1020,8 +1033,7 @@ public function guardAgainstMultiplePlans()
10201033
public function asStripeSubscription(array $expand = [])
10211034
{
10221035
return StripeSubscription::retrieve(
1023-
['id' => $this->stripe_id, 'expand' => $expand],
1024-
$this->owner->stripeOptions()
1036+
['id' => $this->stripe_id, 'expand' => $expand], $this->owner->stripeOptions()
10251037
);
10261038
}
10271039
}

src/SubscriptionItem.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ public function swapAndInvoice($plan, $options = [])
180180
return $item;
181181
}
182182

183+
/**
184+
* Update the underlying Stripe subscription item information for the model.
185+
*
186+
* @param array $options
187+
* @return \Stripe\SubscriptionItem
188+
*/
189+
public function updateStripeSubscriptionItem(array $options = [])
190+
{
191+
return StripeSubscriptionItem::update(
192+
$this->stripe_id, $options, $this->subscription->owner->stripeOptions()
193+
);
194+
}
195+
183196
/**
184197
* Get the subscription as a Stripe subscription item object.
185198
*
@@ -188,8 +201,7 @@ public function swapAndInvoice($plan, $options = [])
188201
public function asStripeSubscriptionItem()
189202
{
190203
return StripeSubscriptionItem::retrieve(
191-
$this->stripe_id,
192-
$this->subscription->owner->stripeOptions()
204+
$this->stripe_id, $this->subscription->owner->stripeOptions()
193205
);
194206
}
195207
}

0 commit comments

Comments
 (0)