@dodopayments/tanstack 0.1.1 → 0.1.2
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 +31 -36
- package/dist/checkout/checkout.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/webhooks/webhooks.d.ts.map +1 -1
- package/package.json +54 -55
package/README.md
CHANGED
|
@@ -27,18 +27,16 @@ All the examples below assume you're using Tanstack App Router.
|
|
|
27
27
|
import { Checkout } from "@dodopayments/tanstack";
|
|
28
28
|
import { createServerFileRoute } from "@tanstack/react-start/server";
|
|
29
29
|
|
|
30
|
-
export const ServerRoute = createServerFileRoute("/api/checkout")
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
|
|
30
|
+
export const ServerRoute = createServerFileRoute("/api/checkout").methods({
|
|
31
|
+
GET: async ({ request }) => {
|
|
32
|
+
return Checkout({
|
|
33
|
+
bearerToken: process.env.DODO_PAYMENTS_API_KEY,
|
|
34
|
+
returnUrl: process.env.DODO_PAYMENTS_RETURN_URL,
|
|
35
|
+
environment: process.env.DODO_PAYMENTS_ENVIRONMENT,
|
|
36
|
+
type: "static", // optional, defaults to 'static'
|
|
37
|
+
})(request);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
42
40
|
```
|
|
43
41
|
|
|
44
42
|
---
|
|
@@ -51,16 +49,16 @@ export const ServerRoute = createServerFileRoute("/api/checkout")
|
|
|
51
49
|
import { CustomerPortal } from "@dodopayments/tanstack";
|
|
52
50
|
import { createServerFileRoute } from "@tanstack/react-start/server";
|
|
53
51
|
|
|
54
|
-
export const ServerRoute = createServerFileRoute(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
52
|
+
export const ServerRoute = createServerFileRoute(
|
|
53
|
+
"/api/customer-portal",
|
|
54
|
+
).methods({
|
|
55
|
+
GET: async ({ request }) => {
|
|
56
|
+
return CustomerPortal({
|
|
57
|
+
bearerToken: process.env.DODO_PAYMENTS_API_KEY,
|
|
58
|
+
environment: process.env.DODO_PAYMENTS_ENVIRONMENT,
|
|
59
|
+
})(request);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
64
62
|
```
|
|
65
63
|
|
|
66
64
|
#### Query Parameters
|
|
@@ -79,19 +77,17 @@ Returns 400 if `customer_id` is missing.
|
|
|
79
77
|
import { Webhooks } from "@dodopayments/tanstack";
|
|
80
78
|
import { createServerFileRoute } from "@tanstack/react-start/server";
|
|
81
79
|
|
|
82
|
-
export const ServerRoute = createServerFileRoute(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
|
|
80
|
+
export const ServerRoute = createServerFileRoute("/api/webhook").methods({
|
|
81
|
+
POST: async ({ request }) => {
|
|
82
|
+
return Webhooks({
|
|
83
|
+
webhookKey: process.env.DODO_PAYMENTS_WEBHOOK_KEY,
|
|
84
|
+
onPayload: async (payload) => {
|
|
85
|
+
// Handle Payload here
|
|
86
|
+
console.log(payload);
|
|
87
|
+
},
|
|
88
|
+
})(request);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
95
91
|
```
|
|
96
92
|
|
|
97
93
|
---
|
|
@@ -225,7 +221,6 @@ File Creation: Create a new file at app/api/webhook/dodo-payments/route.ts in yo
|
|
|
225
221
|
Code Snippet:
|
|
226
222
|
|
|
227
223
|
// src/routes/api/webhook.ts
|
|
228
|
-
// routes/api/checkout.ts
|
|
229
224
|
import { Webhooks } from "@dodopayments/tanstack";
|
|
230
225
|
import { createServerFileRoute } from "@tanstack/react-start/server";
|
|
231
226
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/checkout/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EAGtB,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,IAC7B,SAAS,OAAO,
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/checkout/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EAGtB,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,IAC7B,SAAS,OAAO,8CA0DxC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1824,7 +1824,7 @@ var checkoutQuerySchema = zod.z.object({
|
|
|
1824
1824
|
showDiscounts: zod.z.string().optional(),
|
|
1825
1825
|
// Metadata (allow any key starting with metadata_)
|
|
1826
1826
|
// We'll handle metadata separately in the handler
|
|
1827
|
-
});
|
|
1827
|
+
}).catchall(zod.z.unknown());
|
|
1828
1828
|
// Add Zod schema for dynamic checkout body
|
|
1829
1829
|
var dynamicCheckoutBodySchema = zod.z
|
|
1830
1830
|
.object({
|