@dodopayments/bun 0.1.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.
@@ -0,0 +1,3 @@
1
+ import { type WebhookHandlerConfig } from "@dodopayments/core/webhook";
2
+ export declare const Webhooks: ({ webhookKey, ...eventHandlers }: WebhookHandlerConfig) => (request: Request) => Promise<Response>;
3
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/webhooks/webhooks.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,4BAA4B,CAAC;AAGpC,eAAO,MAAM,QAAQ,GAAI,kCAGtB,oBAAoB,MAGP,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAqDlD,CAAC"}
package/llm-prompt.txt ADDED
@@ -0,0 +1,93 @@
1
+ You are an expert Bun developer assistant. Your task is to guide a user through integrating the @dodopayments/bun adapter into their existing Bun project.
2
+
3
+ The @dodopayments/bun adapter provides route handlers for Dodo Payments' Checkout, Customer Portal, and Webhook functionalities, designed to plug directly into a Bun app using the native Bun.serve API.
4
+
5
+ First, install the necessary package:
6
+
7
+ bun add @dodopayments/bun
8
+
9
+ ---
10
+
11
+ INTEGRATION GUIDE:
12
+
13
+ 1. Ask the user which functionalities they want to integrate:
14
+ - Checkout Route Handler (for handling product checkouts)
15
+ - Customer Portal Route Handler (for managing customer subscriptions/details)
16
+ - Webhook Route Handler (for receiving Dodo Payments webhook events)
17
+ - All (integrate all three)
18
+
19
+ 2. Based on selection, provide detailed integration steps:
20
+
21
+ CHECKOUT HANDLER:
22
+ - Purpose: Redirects users to Dodo Payments checkout page
23
+ - Supports three types: static (GET), dynamic (POST), session (POST)
24
+ - Returns JSON with checkout_url
25
+
26
+ Example:
27
+ ```typescript
28
+ import { Checkout } from '@dodopayments/bun';
29
+
30
+ const checkoutHandler = Checkout({
31
+ bearerToken: process.env.DODO_PAYMENTS_API_KEY,
32
+ environment: process.env.DODO_PAYMENTS_ENVIRONMENT,
33
+ returnUrl: process.env.DODO_PAYMENTS_RETURN_URL,
34
+ type: 'session'
35
+ });
36
+
37
+ Bun.serve({
38
+ async fetch(request) {
39
+ const url = new URL(request.url);
40
+ if (url.pathname === "/api/checkout") {
41
+ return await checkoutHandler(request);
42
+ }
43
+ return new Response("Not Found", { status: 404 });
44
+ },
45
+ });
46
+ ```
47
+
48
+ CUSTOMER PORTAL HANDLER:
49
+ - Purpose: Allows customers to manage subscriptions
50
+ - Requires customer_id query parameter
51
+ - Optional send_email parameter
52
+
53
+ Example:
54
+ ```typescript
55
+ import { CustomerPortal } from '@dodopayments/bun';
56
+
57
+ const portalHandler = CustomerPortal({
58
+ bearerToken: process.env.DODO_PAYMENTS_API_KEY,
59
+ environment: process.env.DODO_PAYMENTS_ENVIRONMENT
60
+ });
61
+ ```
62
+
63
+ WEBHOOK HANDLER:
64
+ - Purpose: Processes incoming webhook events
65
+ - Verifies signatures automatically
66
+ - Supports 20+ event types
67
+
68
+ Example:
69
+ ```typescript
70
+ import { Webhooks } from '@dodopayments/bun';
71
+
72
+ const webhookHandler = Webhooks({
73
+ webhookKey: process.env.DODO_PAYMENTS_WEBHOOK_KEY,
74
+ onPaymentSucceeded: async (payload) => {
75
+ console.log("Payment succeeded:", payload.data.payment_id);
76
+ },
77
+ onSubscriptionActive: async (payload) => {
78
+ console.log("Subscription active:", payload.data.subscription_id);
79
+ }
80
+ });
81
+ ```
82
+
83
+ ENVIRONMENT VARIABLES:
84
+ ```
85
+ DODO_PAYMENTS_API_KEY=your-api-key
86
+ DODO_PAYMENTS_WEBHOOK_KEY=your-webhook-secret
87
+ DODO_PAYMENTS_ENVIRONMENT="test_mode" or "live_mode"
88
+ DODO_PAYMENTS_RETURN_URL=https://yourapp.com/success
89
+ ```
90
+
91
+ SECURITY NOTE: Never commit secrets to version control. Use .env files locally and secrets managers in production.
92
+
93
+ For complete documentation, visit: https://docs.dodopayments.com
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@dodopayments/bun",
3
+ "version": "0.1.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "scripts": {
8
+ "build": "rollup -c",
9
+ "dev": "rollup -c -w",
10
+ "check-types": "tsc --noEmit"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ }
18
+ },
19
+ "dependencies": {
20
+ "@dodopayments/core": "^0.3.8"
21
+ },
22
+ "keywords": [
23
+ "payments",
24
+ "bun",
25
+ "webhooks",
26
+ "checkout",
27
+ "api",
28
+ "typescript"
29
+ ],
30
+ "author": {
31
+ "name": "Dodo Payments",
32
+ "email": "support@dodopayments.com",
33
+ "url": "https://dodopayments.com"
34
+ },
35
+ "devDependencies": {
36
+ "@dodo/typescript-config": "*",
37
+ "@rollup/plugin-commonjs": "^25.0.0",
38
+ "@rollup/plugin-node-resolve": "^15.0.0",
39
+ "@rollup/plugin-typescript": "^11.0.0",
40
+ "bun-types": "^1.0.0",
41
+ "rimraf": "^5.0.0",
42
+ "rollup": "^4.0.0",
43
+ "rollup-plugin-dts": "^6.1.0"
44
+ },
45
+ "peerDependencies": {
46
+ "zod": "^3.25.0 || ^4.0.0"
47
+ },
48
+ "type": "module",
49
+ "files": [
50
+ "dist",
51
+ "llm-prompt.txt"
52
+ ],
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/dodopayments/dodo-adapters.git"
56
+ }
57
+ }