Skip to content

Commit 9dce4bb

Browse files
committed
doc
1 parent f900ec6 commit 9dce4bb

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ php artisan vendor:publish --provider="Code4mk\LaraStripe\LaraStripeServiceProvi
2323
* [Charge doc](https://github.com/code4mk/lara-stripe/blob/master/doc/charge.md)
2424
* [Checkout doc](https://github.com/code4mk/lara-stripe/blob/master/doc/payment-checkout.md)
2525
* [Customer doc](https://github.com/code4mk/lara-stripe/blob/master/doc/customer.md)
26+
* [Product doc](https://github.com/code4mk/lara-stripe/blob/master/doc/product.md)
2627
* [Prices doc](https://github.com/code4mk/lara-stripe/blob/master/doc/prices.md)
2728
* [Subscription doc](https://github.com/code4mk/lara-stripe/blob/master/doc/subscription.md)
2829
* [Coupon doc](https://github.com/code4mk/lara-stripe/blob/master/doc/coupon.md)

doc/subscription-flow.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Sure, here's a step-by-step guide on setting up a subscription in Stripe using the `StripeProducts` and `StripeSubscription` classes:
2+
3+
**1. Create a Product**
4+
5+
Use the `StripeProducts` class to create a product:
6+
7+
```php
8+
use Code4mk\LaraStripe\Lib\StripeProducts;
9+
10+
$stripeProducts = new StripeProducts();
11+
12+
$productName = 'Your Product Name';
13+
14+
$product = $stripeProducts->name($productName)
15+
->create();
16+
```
17+
18+
**2. Set Price (Plan) with Product ID**
19+
20+
Now that you have a product, you can set a price for that product. Use the product's ID when creating the price:
21+
22+
```php
23+
use Code4mk\LaraStripe\Lib\StripePrices; // Assuming you have a StripePrices class
24+
$pricesInstance = new StripePrices();
25+
$price = $stripePrices->description('gqa plan 1 - 10usd')
26+
->amount(10)
27+
->currency('usd')
28+
->product($product->id)
29+
->interval('day')
30+
->createPrice();
31+
```
32+
33+
**3. Create a Customer**
34+
35+
Use the `StripeCustomer` class to create a customer. Make sure to collect the necessary customer information:
36+
37+
```php
38+
use Code4mk\LaraStripe\Lib\StripeCustomer; // Assuming you have a StripeCustomer class
39+
40+
$stripeCustomer = new StripeCustomer();
41+
42+
$customer = $stripeCustomer->name('Customer Name')
43+
->email('[email protected]')
44+
->create()
45+
```
46+
47+
**4. Add a Subscription**
48+
49+
Finally, add a subscription for the customer using the `StripeSubscription` class:
50+
51+
```php
52+
use Code4mk\LaraStripe\Lib\StripeSubscription;
53+
54+
$stripeSubscription = new StripeSubscription();
55+
56+
$customerId = $customer->id; // Use the customer's ID
57+
$priceId = $price->id; // Use the price's ID
58+
59+
$subscription = $stripeSubscription->customer($customerId)
60+
->priceId($priceId)
61+
->create();
62+
```
63+
64+
Now you have set up a subscription for a customer, starting with the creation of a product, setting a price (plan) for that product, creating a customer, and finally adding a subscription to the customer.

0 commit comments

Comments
 (0)