Skip to content

Commit 95b1d49

Browse files
Alexander GaalAlexander Gaaltaylorotwelldriesvints
authored
[9.x] add guest checkout docs (#8252)
* add guest checkout docs * remove idea directory from repo * add guest checkout docs * add promotion code example * remove idea dir * Update billing.md * Update billing.md * improve guest checkout docs * improve guest checkout docs * Update billing.md * foramtting Co-authored-by: Alexander Gaal <alexander.gaal@live.at> Co-authored-by: Taylor Otwell <taylor@laravel.com> Co-authored-by: Dries Vints <dries@vints.io>
1 parent 24dadff commit 95b1d49

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

billing.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- [Single Charge Checkouts](#single-charge-checkouts)
5555
- [Subscription Checkouts](#subscription-checkouts)
5656
- [Collecting Tax IDs](#collecting-tax-ids)
57+
- [Guest Checkouts](#guest-checkouts)
5758
- [Invoices](#invoices)
5859
- [Retrieving Invoices](#retrieving-invoices)
5960
- [Upcoming Invoices](#upcoming-invoices)
@@ -746,7 +747,7 @@ If you would like to add a subscription to a customer who already has a default
746747
<a name="creating-subscriptions-from-the-stripe-dashboard"></a>
747748
#### Creating Subscriptions From The Stripe Dashboard
748749

749-
You may also create subscriptions from the Stripe dashboard itself. When doing so, Cashier will sync newly added subscriptions and assign them a name of `default`. To customize the subscription name that is assigned to dashboard created subscriptions, [extend the `WebhookController`](/docs/{{version}}/billing#defining-webhook-event-handlers) and overwrite the `newSubscriptionName` method.
750+
You may also create subscriptions from the Stripe dashboard itself. When doing so, Cashier will sync newly added subscriptions and assign them a name of `default`. To customize the subscription name that is assigned to dashboard created subscriptions, [extend the `WebhookController`](#defining-webhook-event-handlers) and overwrite the `newSubscriptionName` method.
750751

751752
In addition, you may only create one type of subscription via the Stripe dashboard. If your application offers multiple subscriptions that use different names, only one type of subscription may be added through the Stripe dashboard.
752753

@@ -1922,6 +1923,37 @@ When this method is invoked, a new checkbox will be available to the customer th
19221923
> **Warning**
19231924
> If you have already configured [automatic tax collection](#tax-configuration) in your application's service provider then this feature will be enabled automatically and there is no need to invoke the `collectTaxIds` method.
19241925
1926+
<a name="guest-checkouts"></a>
1927+
### Guest Checkouts
1928+
1929+
Using the `Checkout::guest` method, you may initiate checkout sessions for guests of your application that do not have an "account":
1930+
1931+
use Illuminate\Http\Request;
1932+
use Laravel\Cashier\Checkout;
1933+
1934+
Route::get('/product-checkout', function (Request $request) {
1935+
return Checkout::guest()->create('price_tshirt', [
1936+
'success_url' => route('your-success-route'),
1937+
'cancel_url' => route('your-cancel-route'),
1938+
]);
1939+
});
1940+
1941+
Similarly to when creating checkout sessions for existing users, you may utilize additional methods available on the `Laravel\Cashier\CheckoutBuilder` instance to customize the guest checkout session:
1942+
1943+
use Illuminate\Http\Request;
1944+
use Laravel\Cashier\Checkout;
1945+
1946+
Route::get('/product-checkout', function (Request $request) {
1947+
return Checkout::guest()
1948+
->withPromotionCode('promo-code')
1949+
->create('price_tshirt', [
1950+
'success_url' => route('your-success-route'),
1951+
'cancel_url' => route('your-cancel-route'),
1952+
]);
1953+
});
1954+
1955+
After a guest checkout has been completed, Stripe can dispatch a `checkout.session.completed` webhook event, so make sure to [configure your Stripe webhook](https://dashboard.stripe.com/webhooks) to actually send this event to your application. Once the webhook has been enabled within the Stripe dashboard, you may [handle the webhook with Cashier](#handling-stripe-webhooks). The object contained in the webhook payload will be a [`checkout` object](https://stripe.com/docs/api/checkout/sessions/object) that you may inspect in order to fulfill your customer's order.
1956+
19251957
<a name="handling-failed-payments"></a>
19261958
## Handling Failed Payments
19271959

0 commit comments

Comments
 (0)