@shipindays/shipindays 0.1.18 → 0.1.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipindays/shipindays",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Open source CLI to scaffold a Next.js SaaS. Pick your auth, email, and payments wired up and ready to ship.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,14 @@
1
+ import { DodoPayments } from "dodopayments";
2
+
3
+ const dodo = new DodoPayments({
4
+ apiKey: process.env.DODO_PAYMENTS_API_KEY,
5
+ });
6
+
7
+ export async function createCheckout(priceId: string, customerEmail: string) {
8
+ return await dodo.checkouts.create({
9
+ product_id: priceId,
10
+ customer: { email: customerEmail },
11
+ billing_address: { country: "US" }, // Or handle dynamically
12
+ return_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard`,
13
+ });
14
+ }
@@ -0,0 +1,31 @@
1
+ import Stripe from "stripe";
2
+
3
+ export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
4
+ apiVersion: "2023-10-16", // Use the latest stable version
5
+ typescript: true,
6
+ });
7
+
8
+ export async function createCheckoutSession({
9
+ customerId,
10
+ priceId,
11
+ mode = "subscription", // "subscription" or "payment" (one-time)
12
+ successUrl,
13
+ cancelUrl,
14
+ }: {
15
+ customerId?: string;
16
+ priceId: string;
17
+ mode?: "subscription" | "payment";
18
+ successUrl: string;
19
+ cancelUrl: string;
20
+ }) {
21
+ return await stripe.checkout.sessions.create({
22
+ customer: customerId,
23
+ line_items: [{ price: priceId, quantity: 1 }],
24
+ mode: mode,
25
+ success_url: successUrl,
26
+ cancel_url: cancelUrl,
27
+ subscription_data: mode === "subscription" ? {
28
+ metadata: { /* add user info here */ },
29
+ } : undefined,
30
+ });
31
+ }