Skip to content

Commit 2d63056

Browse files
committed
Add endTrial method and document billing anchor
1 parent 1ab019f commit 2d63056

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,18 @@ $user = User::find(1);
543543
$user->subscription()->noProrate()->swap('product-id', 'variant-id');
544544
```
545545

546+
### Changing The Billing Date
547+
548+
To change the date of the month on which your customer gets billed for their subscription, you may use the `anchorBillingCycleOn` method:
549+
550+
```php
551+
$user = User::find(1);
552+
553+
$user->subscription()->anchorBillingCycleOn(21);
554+
```
555+
556+
In the above example, the customer will now get billed on the 21st of each month going forward. For more info, see [the Lemon Squeezy docs](https://docs.lemonsqueezy.com/guides/developer-guide/managing-subscriptions#changing-the-billing-date).
557+
546558
### Multiple Subscriptions
547559

548560
In some situation you may find yourself wanting to allow your customer to subscribe to multiple subscription types. For example, a gym may offer a swimming and weight lifting subscription. You can allow your customer to subscribe to either or both.
@@ -732,6 +744,18 @@ if ($user->subscription()->hasExpiredTrial()) {
732744
}
733745
```
734746

747+
##### Ending Trials Early
748+
749+
To end a trial with payment upfront early you may use the `endTrial` method on a subscription:
750+
751+
```php
752+
$user = User::find(1);
753+
754+
$user->subscription()->endTrial();
755+
```
756+
757+
This method will move the billing achor to the current day and thus ending any trial period the customer had.
758+
735759
## Handling Webhooks
736760

737761
Lemon Squeezy can send your app webhooks which you can react on. By default, this package alread does the bulk of the work for you. [If you've properly set up webhooks](#webhooks), it'll listen to any incoming events and update your database accordingly. We recommend enabling all event types so it's easy for you to upgrade in the future.

src/Subscription.php

+8
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ public function anchorBillingCycleOn(?int $date): self
254254
return $this;
255255
}
256256

257+
/**
258+
* End the current trial by resetting the billing anchor to today.
259+
*/
260+
public function endTrial(): self
261+
{
262+
return $this->anchorBillingCycleOn(0);
263+
}
264+
257265
/**
258266
* Swap the subscription to a new product plan.
259267
*/

0 commit comments

Comments
 (0)