Skip to content

Commit 1508ca3

Browse files
committed
feat: update billing docs
1 parent e089099 commit 1508ca3

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/docs/utils/billing.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ To get started, create a Stripe account and grab your API keys. Then, drop them
1212

1313
```env:no-line-numbers [Stripe]
1414
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
1717
STRIPE_WEBHOOK_SECRET=whsec_XXXX # only if you are using webhooks
1818
```
1919

2020
<!-- ```env:no-line-numbers [PayStack]
2121
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
2424
``` -->
2525

2626
:::
@@ -92,7 +92,7 @@ This is a list of the parameters you can pass to the `charge()` method:
9292
| `currency` | The currency to charge the customer (e.g. USD, EUR) |
9393
| `description` | A description of the charge (optional) |
9494
| `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` |
9696
| `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 |
9797
| `customer` | The customer email to charge (optional) |
9898
| `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 {
553553
554554
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. -->
555555

556-
<!-- ## Billing Middleware
556+
## Billing Middleware
557557

558558
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:
559559

@@ -580,7 +580,15 @@ app()->get('/protected', [
580580
'middleware' => 'billing.unsubscribed',
581581
'SubscriptionController@subscribe'
582582
]);
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 () {
589+
response()->redirect('/billing/subscribe');
590+
});
591+
```
584592

585593
<!-- ## Billing Currency
586594

0 commit comments

Comments
 (0)