@dodopayments/astro 0.1.3 → 0.2.0
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 +30 -3
- package/dist/checkout/checkout.d.ts.map +1 -1
- package/dist/index.cjs +4169 -1467
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4169 -1467
- package/dist/index.js.map +1 -1
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -41,6 +41,13 @@ export const POST = Checkout({
|
|
|
41
41
|
environment: import.meta.env.DODO_PAYMENTS_ENVIRONMENT,
|
|
42
42
|
type: "dynamic", // for dynamic checkout
|
|
43
43
|
});
|
|
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
|
+
});
|
|
44
51
|
```
|
|
45
52
|
|
|
46
53
|
---
|
|
@@ -138,6 +145,13 @@ export const POST = Checkout({
|
|
|
138
145
|
type: "dynamic", // for dynamic checkout
|
|
139
146
|
});
|
|
140
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
|
+
|
|
141
155
|
Configuration & Usage:
|
|
142
156
|
|
|
143
157
|
bearerToken: Your Dodo Payments API key. It's recommended to set this via the DODO_PAYMENTS_API_KEY environment variable.
|
|
@@ -146,7 +160,7 @@ Configuration & Usage:
|
|
|
146
160
|
|
|
147
161
|
environment: (Optional) Set to "test_mode" for testing, or omit/set to "live_mode" for production.
|
|
148
162
|
|
|
149
|
-
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.
|
|
150
164
|
|
|
151
165
|
Static Checkout (GET) Query Parameters:
|
|
152
166
|
|
|
@@ -162,12 +176,23 @@ Static Checkout (GET) Query Parameters:
|
|
|
162
176
|
|
|
163
177
|
Metadata (optional): Any query parameter starting with metadata_ (e.g., ?metadata_userId=abc123)
|
|
164
178
|
|
|
165
|
-
|
|
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:
|
|
166
188
|
|
|
167
189
|
Docs - One Time Payment Product: https://docs.dodopayments.com/api-reference/payments/post-payments
|
|
168
190
|
|
|
169
191
|
Docs - Subscription Product: https://docs.dodopayments.com/api-reference/subscriptions/post-subscriptions
|
|
170
192
|
|
|
193
|
+
Required fields for checkout sessions:
|
|
194
|
+
product_cart (array): Array of products with product_id and quantity
|
|
195
|
+
|
|
171
196
|
Error Handling: If productId is missing or other query parameters are invalid, the handler will return a 400 response.
|
|
172
197
|
|
|
173
198
|
If Customer Portal Route Handler is selected:
|
|
@@ -265,7 +290,7 @@ Supported Webhook Event Handlers:
|
|
|
265
290
|
|
|
266
291
|
onSubscriptionRenewed?: (payload: WebhookPayload) => Promise<void>
|
|
267
292
|
|
|
268
|
-
|
|
293
|
+
|
|
269
294
|
|
|
270
295
|
onSubscriptionPlanChanged?: (payload: WebhookPayload) => Promise<void>
|
|
271
296
|
|
|
@@ -291,6 +316,8 @@ Example .env file:
|
|
|
291
316
|
|
|
292
317
|
DODO_PAYMENTS_API_KEY=your-api-key
|
|
293
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
|
|
294
321
|
|
|
295
322
|
Usage in your code:
|
|
296
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"}
|