Skip to content

Commit 3e3fb3d

Browse files
committed
promotion
1 parent c3c351c commit 3e3fb3d

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

doc/promotion.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
## Usage
2+
3+
Here are some common operations you can perform using the `StripePromotion` library:
4+
5+
### Creating a Promotion
6+
7+
```php
8+
use Code4mk\LaraStripe\Lib\StripePromotion;
9+
10+
$stripePromotion = new StripePromotion();
11+
12+
$couponId = 'coupon_id_here';
13+
14+
$stripePromotion->couponId($couponId) // Set the coupon ID
15+
->create(); // Create the promotion
16+
```
17+
18+
### Retrieving a Promotion
19+
20+
```php
21+
use Code4mk\LaraStripe\Lib\StripePromotion;
22+
23+
$stripePromotion = new StripePromotion();
24+
25+
$promotionId = 'promotion_id_here';
26+
27+
$stripePromotion->retrieve($promotionId); // Retrieve the promotion by ID
28+
```
29+
30+
### Deactivating a Promotion
31+
32+
```php
33+
use Code4mk\LaraStripe\Lib\StripePromotion;
34+
35+
$stripePromotion = new StripePromotion();
36+
37+
$promotionId = 'promotion_id_here';
38+
39+
$stripePromotion->deactivate($promotionId); // Deactivate the promotion by ID
40+
```
41+
42+
### Activating a Promotion
43+
44+
```php
45+
use Code4mk\LaraStripe\Lib\StripePromotion;
46+
47+
$stripePromotion = new StripePromotion();
48+
49+
$promotionId = 'promotion_id_here';
50+
51+
$stripePromotion->activate($promotionId); // Activate the promotion by ID
52+
```
53+
54+
### Listing Promotions
55+
56+
```php
57+
use Code4mk\LaraStripe\Lib\StripePromotion;
58+
59+
$stripePromotion = new StripePromotion();
60+
61+
$stripePromotion->lists(); // Retrieve a list of all promotions
62+
```
63+
64+
For more details on available methods and parameters, refer to the inline code comments and the [Stripe API documentation](https://stripe.com/docs/api/promotion_codes).
65+
66+
## Error Handling
67+
68+
The library provides basic error handling. If an error occurs during an operation, it returns an object with an `isError` property set to `true`, along with an error message and the Stripe error details.
69+
70+
```php
71+
$result = $stripePromotion->create();
72+
73+
if ($result->isError === true) {
74+
// Handle the error
75+
echo "Error: " . $result->message;
76+
echo "Stripe Error: " . $result->stripe['message'];
77+
}
78+
```

0 commit comments

Comments
 (0)