From 2c0e5918c014a8dd45c15bf2a5a24fc25b6bfa7c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 22 Jan 2021 08:40:32 -0600 Subject: [PATCH] formatting --- cashier-paddle.md | 94 +++++++++++++---------------------------------- 1 file changed, 25 insertions(+), 69 deletions(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index 7b31ef301d6..062ef566917 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -186,41 +186,20 @@ For more information on pay links, you may review [the Paddle API documentation > {note} After a subscription state change, the delay for receiving the corresponding webhook is typically minimal but you should account for this in your application by considering that your user's subscription might not be immediately available after completing the checkout. - -#### Pay Links in an SPA + +#### Manually Rendering Pay Links -If you're using Cashier Paddle in an SPA like Vue.js you'll need to write an endpoint that retrieves a pay link URL: +You may also manually render a pay link without using Laravel's built-in Blade components. To get started, generate the pay link URL as demonstrated in previous examples: - use App\Models\User; - use Illuminate\Http\Request; - - Route::get('/user/subscribe-link', function (Request $request) { - $payLink = $request->user()->newSubscription('default', $premium = 34567) - ->returnTo(route('home')) - ->create(); - - return response()->json(['payLink' => $payLink]); - }); - -Make sure you have a place in your HTML where to render the button: - -```html -
-``` - -Then retrieve it through, for example, an axios call and attach it to the DOM: + $payLink = $request->user()->newSubscription('default', $premium = 34567) + ->returnTo(route('home')) + ->create(); -```js -axios.get('/user/subscribe-link') - .then((response) => { - const payLink = response.data.payLink; +Next, simply attach the pay link URL to an `a` element in your HTML: - document.getElementById('subscribeButton').innerHTML = - ` - Paddle Checkout - ` - }); -``` + + Paddle Checkout + ### Inline Checkout @@ -253,47 +232,24 @@ Please consult Paddle's [guide on Inline Checkout](https://developer.paddle.com/ > {note} If you would like to also use the `passthrough` option when specifying custom options, you should provide a key / value array as its value. Cashier will automatically handle converting the array to a JSON string. In addition, the `customer_id` passthrough option is reserved for internal Cashier usage. - -#### Inline Checkout in an SPA + +#### Manually Rendering An Inline Checkout -If you're using Cashier Paddle in an SPA like Vue.js you'll need to write a `PaddleCheckout.vue` component that renders the inline checkout: +You may also manually render an inline checkout without using Laravel's built-in Blade components. To get started, generate the pay link URL [as demonstrated in previous examples](#pay-links). -```js - +Next, you may use Paddle.js to initialize the checkout. To keep this example simple, we will demonstrate this using [Alpine.js](https://github.com/alpinejs/alpine); however, you are free to translate this example to your own frontend stack: - -``` - -Then render the inline checkout like so: - -```js - +```html +
+
```