You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/utils/billing.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,15 @@ To get started, create a Stripe account and grab your API keys. Then, drop them
12
12
13
13
```env:no-line-numbers [Stripe]
14
14
BILLING_PROVIDER=stripe
15
-
STRIPE_SECRET_KEY=sk_test_XXXX
16
-
STRIPE_PUBLIC_KEY=pk_test_XXXX
15
+
STRIPE_API_KEY=sk_test_XXXX
16
+
STRIPE_PUBLISHABLE_KEY=pk_test_XXXX
17
17
STRIPE_WEBHOOK_SECRET=whsec_XXXX # only if you are using webhooks
18
18
```
19
19
20
20
<!-- ```env:no-line-numbers [PayStack]
21
21
BILLING_PROVIDER=paystack
22
-
STRIPE_SECRET_KEY=sk_test_XXXX
23
-
STRIPE_PUBLIC_KEY=pk_test_XXXX
22
+
STRIPE_API_KEY=sk_test_XXXX
23
+
STRIPE_PUBLISHABLE_KEY=pk_test_XXXX
24
24
``` -->
25
25
26
26
:::
@@ -92,7 +92,7 @@ This is a list of the parameters you can pass to the `charge()` method:
92
92
|`currency`| The currency to charge the customer (e.g. USD, EUR) |
93
93
|`description`| A description of the charge (optional) |
94
94
|`metadata`| An array of metadata to attach to the charge. This is useful for tracking the user who made the payment, the items they purchased, and any other relevant information. |
95
-
|`metadata.items`| An array of items to charge the customer, every item should have a name and amount, and optional quantity: `['name' => 'XXX', 'amount' => xxx]`. Optional if you pass `items`|
95
+
|`metadata.items`| An array of items to charge the customer, every item should have a name and amount, and optional quantity: `['item' => 'XXX', 'amount' => xxx]`. Optional if you pass `items`|
96
96
|`items`| Array of stripe formatted items to charge the customer, eg: `['price_data' => ['currency' => 'usd', 'product_data' => ['name' => 'T-shirt'], 'unit_amount' => 2000], 'quantity' => 1]`. You can use `metadata.items` if you want leaf to format your data for you |
97
97
|`customer`| The customer email to charge (optional) |
98
98
|`urls`| An array of URLs to redirect the customer to. Accepts `success` and `cancel` keys. If you don't pass this, Leaf will use the default URLs. |
@@ -553,7 +553,7 @@ class User extends Model {
553
553
554
554
This way, you can easily check the user's subscription status, plan, and other billing information directly from the user model or any other model you add the `HasBilling` trait to. -->
555
555
556
-
<!--## Billing Middleware
556
+
## Billing Middleware
557
557
558
558
Leaf billing comes with a middleware that you can use to protect your routes based on specific conditions. This is a list of the billing middleware available:
559
559
@@ -580,7 +580,15 @@ app()->get('/protected', [
580
580
'middleware' => 'billing.unsubscribed',
581
581
'SubscriptionController@subscribe'
582
582
]);
583
-
``` -->
583
+
```
584
+
585
+
If you want to customize what the middleware does if the user is not allowed to access the route, you can do that by calling the `billing()->middleware()` method in your `app/routes/index.php` file. This method accepts a callback that will be called if the user is not allowed to access the route.
586
+
587
+
```php:no-line-numbers [index.php]
588
+
billing()->middleware('billing.subscribed', function () {
0 commit comments