Components

Buy Button

One of the most important components in Conduit is the Buy Button. This is the component that allows users to immediately purchase products or subscriptions.

Example

You can create a Buy Button by passing it a $price prop. This can either by a Price model or the Price's $price->price_id.

1<x-conduit::buy-button:price="\Mergeloop\Conduit\Models\Price::find(1)">
2 Buy Now
3</x-conduit::buy-button>
4 
5{{-- OR --}}
6 
7<x-conduit::buy-button:price="$price->price_id">
8 Buy Now
9</x-conduit::buy-button>
10 
11{{-- OR --}}
12 
13<x-conduit::buy-button:price="$price->price_id"class="px-4 py-2 text-gray-700 hover:text-black">
14 Buy Now
15</x-conduit::buy-button>

Please note that you cannot pass the $price->id property. You must pass the $price->price_id property as that is the actual reference to the Price's Stripe or Paddle ID.

Cart Checkout

The Buy Button can also be used to trigger the a full Cart checkout, which allows users to complete their purchase for all items currently in their Cart.

Instead of passing a $price prop, you can pass the $cartCheckout prop instead.

1<x-conduit::buy-button:cartCheckout="true">
2 Checkout
3</x-conduit::buy-button>
4 
5{{-- OR --}}
6 
7<x-conduit::buy-buttoncartCheckout>
8 Checkout
9</x-conduit::buy-button>

Please note, you cannot create a new Checkout Session for both one-time purchases and subscriptions at the same time. You will need to create separate Buy Buttons for each type of purchase.
Also, Lemon Squeezy does not support checkouts for multiple products.

Return URL

You can specify a return URL for the Buy Button that the user will be redirected to after they successfully complete their purchase.

1<x-conduit::buy-button:price="$price->price_id"returnUrl="/">
2 Buy Now
3</x-conduit::buy-button>
4 
5{{-- OR --}}
6 
7<x-conduit::buy-button:price="$price->price_id":returnUrl="route('checkout.success')">
8 Buy Now
9</x-conduit::buy-button>

Custom Data

You can pass custom data to the Buy Button that will be included in the Checkout Session. This can be useful for tracking purposes or for passing additional information to the Checkout Session.

1<x-conduit::buy-button:customData="['user_id' => auth()->id()]">
2 Buy Now
3</x-conduit::buy-button>

Please note that there may be some instances of custom data attributes that are not allowed by Stripe.

Code highlighting provided by Torchlight