@whop/checkout 0.0.21-canary.8 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @whop/checkout - Embed Whop checkout on your page
|
|
2
|
+
|
|
3
|
+
Embedded checkout allows you to embed Whop's checkout flow on your own website in two easy steps. This allows you to offer your users a seamless checkout experience without leaving your website.
|
|
4
|
+
|
|
5
|
+
## Step 1: Add the script tag
|
|
6
|
+
|
|
7
|
+
To embed checkout, you need to add the following script tag into the `<head>` of your page:
|
|
8
|
+
|
|
9
|
+
```md
|
|
10
|
+
<script
|
|
11
|
+
async
|
|
12
|
+
defer
|
|
13
|
+
src="https://cdn.jsdelivr.net/npm/@whop/checkout@0.0.21-canary.8/dist/loader.js"
|
|
14
|
+
></script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Step 2: Add the checkout element
|
|
18
|
+
|
|
19
|
+
To create a checkout element, you need to include the following attribute on an element in your page:
|
|
20
|
+
|
|
21
|
+
```md
|
|
22
|
+
<div data-whop-checkout-plan-id="plan_XXXXXXXXX"></div>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This will now mount an iframe inside of the element with the plan id you provided. Once the checkout is complete, the user will be redirected to the redirect url you specified in the settings on Whop.
|
|
26
|
+
|
|
27
|
+
You can configure the redirect url in your [whop's settings](https://whop.com/dashboard/whops/) or in your [company's settings](https://whop.com/dashboard/settings/checkout/) on the dashboard. If both are specified, the redirect url specified in the whop's settings will take precedence.
|
|
28
|
+
|
|
29
|
+
## Available attributes
|
|
30
|
+
|
|
31
|
+
### **`data-whop-checkout-plan-id`**
|
|
32
|
+
|
|
33
|
+
**Required** - The plan id you want to checkout.
|
|
34
|
+
|
|
35
|
+
> To get your plan id, you need to first create a plan in the **Manage Pricing** section on your whop page.
|
|
36
|
+
|
|
37
|
+
### **`data-whop-checkout-theme`**
|
|
38
|
+
|
|
39
|
+
**Optional** - The theme you want to use for the checkout.
|
|
40
|
+
|
|
41
|
+
Possible values are `light`, `dark` or `system`.
|
|
42
|
+
|
|
43
|
+
```md
|
|
44
|
+
<div data-whop-checkout-theme="light" data-whop-checkout-plan-id="plan_XXXXXXXXX"></div>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### **`data-whop-checkout-session-id`**
|
|
48
|
+
|
|
49
|
+
**Optional** - The session id to use for the checkout.
|
|
50
|
+
|
|
51
|
+
This can be used to attach metadata to a checkout by first creating a session through the API and then passing the session id to the checkout element.
|
|
52
|
+
|
|
53
|
+
```md
|
|
54
|
+
<div data-whop-checkout-session-id="ch_XXXXXXXXX" data-whop-checkout-plan-id="plan_XXXXXXXXX"></div>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Full example
|
|
58
|
+
|
|
59
|
+
```md
|
|
60
|
+
<!DOCTYPE html>
|
|
61
|
+
<html>
|
|
62
|
+
<head>
|
|
63
|
+
<meta charset="utf-8">
|
|
64
|
+
<meta name="viewport" content="width=device-width">
|
|
65
|
+
<script
|
|
66
|
+
async
|
|
67
|
+
defer
|
|
68
|
+
src="https://cdn.jsdelivr.net/npm/@whop/checkout@0.0.21-canary.8/dist/loader.js"
|
|
69
|
+
></script>
|
|
70
|
+
<title>Whop embedded checkout example</title>
|
|
71
|
+
<style>
|
|
72
|
+
div {
|
|
73
|
+
box-sizing: border-box;
|
|
74
|
+
}
|
|
75
|
+
body {
|
|
76
|
+
margin: 0
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
79
|
+
</head>
|
|
80
|
+
<body>
|
|
81
|
+
<div
|
|
82
|
+
data-whop-checkout-plan-id="plan_XXXXXXXXX"
|
|
83
|
+
data-whop-checkout-session-id="ch_XXXXXXXXX"
|
|
84
|
+
data-whop-checkout-theme="light"
|
|
85
|
+
style="height: fit-content; overflow: hidden; max-width: 50%;"
|
|
86
|
+
></div>
|
|
87
|
+
</body>
|
|
88
|
+
</html>
|
|
89
|
+
```
|