Skip to content

Commit 2519485

Browse files
committed
checkout documentation
1 parent 07872f2 commit 2519485

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

doc/payment-checkout.md

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ LaraStripe has payment checkout (session) alias `LaraStripeCheckout`.
44

55
# Usage
66

7+
## env
8+
9+
```
10+
STRIPE_PUBLIC_KEY="public key"
11+
STRIPE_SECRET_KEY="secret key"
12+
STRIPE_SUCCESS_URL="http://127.0.0.1:8000/checkout/success"
13+
STRIPE_CANCEL_URL="http://127.0.0.1:8000/checkout/cancel"
14+
15+
```
16+
17+
## checkout
18+
719
```php
820
$checkout = LaraStripeCheckout::tnx('tnx-1212134')
921
->amount(233)
@@ -18,7 +30,7 @@ $checkout = LaraStripeCheckout::tnx('tnx-1212134')
1830
}
1931
```
2032

21-
# stripe.js
33+
### stripe.js
2234

2335
* include `<script src="https://js.stripe.com/v3/"></script>`
2436

@@ -29,9 +41,6 @@ $checkout = LaraStripeCheckout::tnx('tnx-1212134')
2941
var stripe = Stripe('your_stripe_public_key');
3042

3143
stripe.redirectToCheckout({
32-
// Make the id field from the Checkout Session creation API response
33-
// available to this file, so you can provide it as parameter here
34-
// instead of the {{CHECKOUT_SESSION_ID}} placeholder.
3544
sessionId: '{{CHECKOUT_SESSION_ID}}'
3645
}).then(function (result) {
3746
// If `redirectToCheckout` fails due to a browser or network
@@ -40,7 +49,7 @@ stripe.redirectToCheckout({
4049
});
4150
```
4251

43-
* blade view
52+
### blade view
4453

4554
~ javascript
4655

@@ -58,37 +67,37 @@ stripe.redirectToCheckout({
5867
});
5968
```
6069

61-
* sessionId will be that code which generate `getSession method`
6270

63-
# retrive data `success route`
71+
## success
6472

6573
After success payment stripe redirect to success_url . retrive session data in success_url.
6674

6775
```php
68-
Route::get('success',function(Request $request){
69-
$data = LaraStripeCheckout::setup([
70-
'secret' => '******',
71-
'public_key' => '******',
72-
'currency' => 'usd'
73-
])
74-
->retrieve($request->session_id);
76+
Route::get('checkout/success',function(Request $request){
77+
$data = LaraStripeCheckout::status(request('session_id'));
78+
return response()->json($data);
79+
80+
// status (succeeded, .....)
81+
$data->status;
82+
83+
// tnx id
7584
$data->ref_id;
76-
// return `customer ID` `cart ID`, or `similar`
77-
})
85+
86+
// additional data (metada)
87+
$data->sessions->metadata;
88+
89+
// payment status
90+
$data->sessions->payment_status;
91+
});
7892
```
7993

80-
# refund
94+
## refund
8195

8296
* Store payment_intent in db when checkout success. ('retrieve method')
8397

8498
```php
85-
$re = LaraStripeCheckout::setup(['secret' => '******'])
86-
->refund('payment_intent')
87-
return response()->json($re);
99+
Route::get('checkout/refund',function(){
100+
$charge = LaraStripeCheckout::refund('payment_intent');
101+
return response()->json($charge);
102+
});
88103
```
89-
90-
# reference
91-
92-
* [session stripe](https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-id)
93-
* [stripe official doc](https://stripe.com/payments/checkout)
94-
* [stripe payment](https://stripe.com/docs/terminal/payments)

0 commit comments

Comments
 (0)