@dodopayments/tanstack 0.1.2 → 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 +23 -4
- package/dist/checkout/checkout.d.ts.map +1 -1
- package/dist/index.cjs +4172 -1470
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4172 -1470
- package/dist/index.js.map +1 -1
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -36,6 +36,14 @@ export const ServerRoute = createServerFileRoute("/api/checkout").methods({
|
|
|
36
36
|
type: "static", // optional, defaults to 'static'
|
|
37
37
|
})(request);
|
|
38
38
|
},
|
|
39
|
+
POST: async ({ request }) => {
|
|
40
|
+
return Checkout({
|
|
41
|
+
bearerToken: process.env.DODO_PAYMENTS_API_KEY,
|
|
42
|
+
returnUrl: process.env.DODO_PAYMENTS_RETURN_URL,
|
|
43
|
+
environment: process.env.DODO_PAYMENTS_ENVIRONMENT,
|
|
44
|
+
type: "session", // or "dynamic" for dynamic link
|
|
45
|
+
})(request);
|
|
46
|
+
},
|
|
39
47
|
});
|
|
40
48
|
```
|
|
41
49
|
|
|
@@ -146,7 +154,7 @@ export const ServerRoute = createServerFileRoute("/api/checkout")
|
|
|
146
154
|
bearerToken: process.env.DODO_PAYMENTS_API_KEY,
|
|
147
155
|
returnUrl: process.env.DODO_PAYMENTS_RETURN_URL,
|
|
148
156
|
environment: process.env.DODO_PAYMENTS_ENVIRONMENT,
|
|
149
|
-
type: "
|
|
157
|
+
type: "session", // or "dynamic" for dynamic link
|
|
150
158
|
})(request)
|
|
151
159
|
}
|
|
152
160
|
})
|
|
@@ -160,7 +168,7 @@ Configuration & Usage:
|
|
|
160
168
|
|
|
161
169
|
environment: (Optional) Set to "test_mode" for testing, or omit/set to "live_mode" for production.
|
|
162
170
|
|
|
163
|
-
type: (Optional) Set to "static" for GET/static checkout, "dynamic" for POST/dynamic checkout
|
|
171
|
+
type: (Optional) Set to "static" for GET/static checkout, "dynamic" for POST/dynamic checkout, or "session" for POST/checkout sessions.
|
|
164
172
|
|
|
165
173
|
Static Checkout (GET) Query Parameters:
|
|
166
174
|
|
|
@@ -176,12 +184,23 @@ Static Checkout (GET) Query Parameters:
|
|
|
176
184
|
|
|
177
185
|
Metadata (optional): Any query parameter starting with metadata_ (e.g., ?metadata_userId=abc123)
|
|
178
186
|
|
|
179
|
-
|
|
187
|
+
Returns: {"checkout_url": "https://checkout.dodopayments.com/..."}
|
|
188
|
+
|
|
189
|
+
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:
|
|
180
190
|
|
|
181
191
|
Docs - One Time Payment Product: https://docs.dodopayments.com/api-reference/payments/post-payments
|
|
182
192
|
|
|
183
193
|
Docs - Subscription Product: https://docs.dodopayments.com/api-reference/subscriptions/post-subscriptions
|
|
184
194
|
|
|
195
|
+
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:
|
|
196
|
+
|
|
197
|
+
Docs - One Time Payment Product: https://docs.dodopayments.com/api-reference/payments/post-payments
|
|
198
|
+
|
|
199
|
+
Docs - Subscription Product: https://docs.dodopayments.com/api-reference/subscriptions/post-subscriptions
|
|
200
|
+
|
|
201
|
+
Required fields for checkout sessions:
|
|
202
|
+
product_cart (array): Array of products with product_id and quantity
|
|
203
|
+
|
|
185
204
|
Error Handling: If productId is missing or other query parameters are invalid, the handler will return a 400 response.
|
|
186
205
|
|
|
187
206
|
If Customer Portal Route Handler is selected:
|
|
@@ -317,7 +336,7 @@ Example .env file:
|
|
|
317
336
|
DODO_PAYMENTS_API_KEY=your-api-key
|
|
318
337
|
DODO_PAYMENTS_WEBHOOK_KEY=your-webhook-secret
|
|
319
338
|
DODO_PAYMENTS_RETURN_URL=your-return-url
|
|
320
|
-
DODO_PAYMENTS_ENVIRONMENT="
|
|
339
|
+
DODO_PAYMENTS_ENVIRONMENT="test_mode" or "live_mode"
|
|
321
340
|
|
|
322
341
|
Usage in your code:
|
|
323
342
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/checkout/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/checkout/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EAItB,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,IAC7B,SAAS,OAAO,8CAyFxC"}
|