@dodopayments/astro 0.1.2 → 0.1.4
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 +29 -4
- package/dist/checkout/checkout.d.ts.map +1 -1
- package/dist/index.cjs +384 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +384 -59
- package/dist/index.js.map +1 -1
- package/dist/webhooks/webhooks.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,6 @@ export const GET = Checkout({
|
|
|
35
35
|
type: "static", // optional, defaults to 'static'
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
export const POST = Checkout({
|
|
40
39
|
bearerToken: import.meta.env.DODO_PAYMENTS_API_KEY,
|
|
41
40
|
returnUrl: import.meta.env.DODO_PAYMENTS_RETURN_URL,
|
|
@@ -43,6 +42,12 @@ export const POST = Checkout({
|
|
|
43
42
|
type: "dynamic", // for dynamic checkout
|
|
44
43
|
});
|
|
45
44
|
|
|
45
|
+
export const POST = Checkout({
|
|
46
|
+
bearerToken: import.meta.env.DODO_PAYMENTS_API_KEY,
|
|
47
|
+
returnUrl: import.meta.env.DODO_PAYMENTS_RETURN_URL,
|
|
48
|
+
environment: import.meta.env.DODO_PAYMENTS_ENVIRONMENT,
|
|
49
|
+
type: "session", // for checkout sessions
|
|
50
|
+
});
|
|
46
51
|
```
|
|
47
52
|
|
|
48
53
|
---
|
|
@@ -140,6 +145,13 @@ export const POST = Checkout({
|
|
|
140
145
|
type: "dynamic", // for dynamic checkout
|
|
141
146
|
});
|
|
142
147
|
|
|
148
|
+
export const POST = Checkout({
|
|
149
|
+
bearerToken: import.meta.env.DODO_PAYMENTS_API_KEY,
|
|
150
|
+
returnUrl: import.meta.env.DODO_PAYMENTS_RETURN_URL,
|
|
151
|
+
environment: import.meta.env.DODO_PAYMENTS_ENVIRONMENT,
|
|
152
|
+
type: "session", // for checkout sessions
|
|
153
|
+
});
|
|
154
|
+
|
|
143
155
|
Configuration & Usage:
|
|
144
156
|
|
|
145
157
|
bearerToken: Your Dodo Payments API key. It's recommended to set this via the DODO_PAYMENTS_API_KEY environment variable.
|
|
@@ -148,7 +160,7 @@ Configuration & Usage:
|
|
|
148
160
|
|
|
149
161
|
environment: (Optional) Set to "test_mode" for testing, or omit/set to "live_mode" for production.
|
|
150
162
|
|
|
151
|
-
type: (Optional) Set to "static" for GET/static checkout, "dynamic" for POST/dynamic checkout
|
|
163
|
+
type: (Optional) Set to "static" for GET/static checkout, "dynamic" for POST/dynamic checkout, or "session" for POST/checkout sessions.
|
|
152
164
|
|
|
153
165
|
Static Checkout (GET) Query Parameters:
|
|
154
166
|
|
|
@@ -164,12 +176,23 @@ Static Checkout (GET) Query Parameters:
|
|
|
164
176
|
|
|
165
177
|
Metadata (optional): Any query parameter starting with metadata_ (e.g., ?metadata_userId=abc123)
|
|
166
178
|
|
|
167
|
-
|
|
179
|
+
Returns: {"checkout_url": "https://checkout.dodopayments.com/..."}
|
|
180
|
+
|
|
181
|
+
Dynamic Checkout (POST) - Returns JSON with checkout_url: Parameters are sent as a JSON body. Supports both one-time and recurring payments. Returns: {"checkout_url": "https://checkout.dodopayments.com/..."}. For a complete list of supported POST body fields, refer to:
|
|
182
|
+
|
|
183
|
+
Docs - One Time Payment Product: https://docs.dodopayments.com/api-reference/payments/post-payments
|
|
184
|
+
|
|
185
|
+
Docs - Subscription Product: https://docs.dodopayments.com/api-reference/subscriptions/post-subscriptions
|
|
186
|
+
|
|
187
|
+
Checkout Sessions (POST) - (Recommended) A more customizable checkout experience. Returns JSON with checkout_url: Parameters are sent as a JSON body. Supports both one-time and recurring payments. Returns: {"checkout_url": "https://checkout.dodopayments.com/session/..."}. For a complete list of supported POST body fields, refer to:
|
|
168
188
|
|
|
169
189
|
Docs - One Time Payment Product: https://docs.dodopayments.com/api-reference/payments/post-payments
|
|
170
190
|
|
|
171
191
|
Docs - Subscription Product: https://docs.dodopayments.com/api-reference/subscriptions/post-subscriptions
|
|
172
192
|
|
|
193
|
+
Required fields for checkout sessions:
|
|
194
|
+
product_cart (array): Array of products with product_id and quantity
|
|
195
|
+
|
|
173
196
|
Error Handling: If productId is missing or other query parameters are invalid, the handler will return a 400 response.
|
|
174
197
|
|
|
175
198
|
If Customer Portal Route Handler is selected:
|
|
@@ -267,7 +290,7 @@ Supported Webhook Event Handlers:
|
|
|
267
290
|
|
|
268
291
|
onSubscriptionRenewed?: (payload: WebhookPayload) => Promise<void>
|
|
269
292
|
|
|
270
|
-
|
|
293
|
+
|
|
271
294
|
|
|
272
295
|
onSubscriptionPlanChanged?: (payload: WebhookPayload) => Promise<void>
|
|
273
296
|
|
|
@@ -293,6 +316,8 @@ Example .env file:
|
|
|
293
316
|
|
|
294
317
|
DODO_PAYMENTS_API_KEY=your-api-key
|
|
295
318
|
DODO_PAYMENTS_WEBHOOK_KEY=your-webhook-secret
|
|
319
|
+
DODO_PAYMENTS_ENVIRONMENT="test_mode" or "live_mode"
|
|
320
|
+
DODO_PAYMENTS_RETURN_URL=your-return-url
|
|
296
321
|
|
|
297
322
|
Usage in your code:
|
|
298
323
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/checkout/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,qBAAqB,
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/checkout/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,qBAAqB,EAItB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,QAAQ,GAAI,QAAQ,qBAAqB,KAAG,QAmGxD,CAAC"}
|