From 7e032ca9adc4bfb874f71237d6848d734d7e22c5 Mon Sep 17 00:00:00 2001 From: evanbacon Date: Sat, 14 Sep 2024 14:35:34 +0100 Subject: [PATCH 1/7] Create tsconfig.json --- with-stripe/tsconfig.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 with-stripe/tsconfig.json diff --git a/with-stripe/tsconfig.json b/with-stripe/tsconfig.json new file mode 100644 index 00000000..186ee5f1 --- /dev/null +++ b/with-stripe/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "expo/tsconfig.base", + "compilerOptions": { + "strict": true, + "paths": { + "@/*": ["./*"] + } + }, + "include": ["**/*.ts", "**/*.tsx"] +} From aed5c5bd7d82e670e1953a1edc87a1155bbb07fb Mon Sep 17 00:00:00 2001 From: evanbacon Date: Sat, 14 Sep 2024 14:44:55 +0100 Subject: [PATCH 2/7] fix stripe deployment --- with-stripe/app/api/payment-sheet+api.ts | 11 ++++++++--- with-stripe/utils/stripe-server.ts | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/with-stripe/app/api/payment-sheet+api.ts b/with-stripe/app/api/payment-sheet+api.ts index 8ef474d8..81661645 100644 --- a/with-stripe/app/api/payment-sheet+api.ts +++ b/with-stripe/app/api/payment-sheet+api.ts @@ -6,9 +6,14 @@ import { CURRENCY } from "@/utils/config"; export async function POST(req: Request) { // Use an existing Customer ID if this is a returning customer. const customer = await stripe.customers.create(); - const ephemeralKey = await stripe.ephemeralKeys.create({ - customer: customer.id, - }); + const ephemeralKey = await stripe.ephemeralKeys.create( + { + customer: customer.id, + }, + { + apiVersion: "2024-06-20", + } + ); const paymentIntent = await stripe.paymentIntents.create({ amount: 1256, currency: CURRENCY, diff --git a/with-stripe/utils/stripe-server.ts b/with-stripe/utils/stripe-server.ts index 55342cd4..2a8b5f03 100644 --- a/with-stripe/utils/stripe-server.ts +++ b/with-stripe/utils/stripe-server.ts @@ -1,6 +1,7 @@ import Stripe from "stripe"; export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY as string, { + httpClient: Stripe.createFetchHttpClient(), // https://github.com/stripe/stripe-node#configuration apiVersion: "2024-06-20", appInfo: { From 4616b1509717fe689806c2970149137c696e95f3 Mon Sep 17 00:00:00 2001 From: evanbacon Date: Sat, 14 Sep 2024 14:53:51 +0100 Subject: [PATCH 3/7] remove extras --- with-stripe/app/api/payment-sheet+api.ts | 2 +- with-stripe/components/stripe-provider.web.tsx | 2 +- with-stripe/utils/stripe-server.ts | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/with-stripe/app/api/payment-sheet+api.ts b/with-stripe/app/api/payment-sheet+api.ts index 81661645..27ad3fa9 100644 --- a/with-stripe/app/api/payment-sheet+api.ts +++ b/with-stripe/app/api/payment-sheet+api.ts @@ -3,7 +3,7 @@ import { stripe } from "@/utils/stripe-server"; import { CURRENCY } from "@/utils/config"; -export async function POST(req: Request) { +export async function POST() { // Use an existing Customer ID if this is a returning customer. const customer = await stripe.customers.create(); const ephemeralKey = await stripe.ephemeralKeys.create( diff --git a/with-stripe/components/stripe-provider.web.tsx b/with-stripe/components/stripe-provider.web.tsx index 9cfa04c2..ee93b0af 100644 --- a/with-stripe/components/stripe-provider.web.tsx +++ b/with-stripe/components/stripe-provider.web.tsx @@ -1,3 +1,3 @@ -export default function ExpoStripeProvider(props) { +export default function ExpoStripeProvider(props: any) { return <>{props.children}; } diff --git a/with-stripe/utils/stripe-server.ts b/with-stripe/utils/stripe-server.ts index 2a8b5f03..fad6a0ef 100644 --- a/with-stripe/utils/stripe-server.ts +++ b/with-stripe/utils/stripe-server.ts @@ -2,9 +2,4 @@ import Stripe from "stripe"; export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY as string, { httpClient: Stripe.createFetchHttpClient(), - // https://github.com/stripe/stripe-node#configuration - apiVersion: "2024-06-20", - appInfo: { - name: "expo-router-stripe", - }, }); From 9236bfdb21d094c197371be5e2d7488eb9ff6d97 Mon Sep 17 00:00:00 2001 From: evanbacon Date: Sat, 14 Sep 2024 14:54:35 +0100 Subject: [PATCH 4/7] Update stripe-server.ts --- with-stripe/utils/stripe-server.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/with-stripe/utils/stripe-server.ts b/with-stripe/utils/stripe-server.ts index fad6a0ef..688c9e33 100644 --- a/with-stripe/utils/stripe-server.ts +++ b/with-stripe/utils/stripe-server.ts @@ -1,5 +1,6 @@ import Stripe from "stripe"; export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY as string, { + // This is required for deployment. httpClient: Stripe.createFetchHttpClient(), }); From c5c481e8bab325b86cf4cb2b5372a70322253f16 Mon Sep 17 00:00:00 2001 From: evanbacon Date: Sat, 14 Sep 2024 14:55:27 +0100 Subject: [PATCH 5/7] Update result.tsx --- with-stripe/app/result.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/with-stripe/app/result.tsx b/with-stripe/app/result.tsx index d3747ae5..13a88266 100644 --- a/with-stripe/app/result.tsx +++ b/with-stripe/app/result.tsx @@ -24,21 +24,13 @@ export default function ResultPage() { } const paymentIntent = data.payment_intent as Stripe.PaymentIntent; + const formattedContent = JSON.stringify(data, null, 2); return ( <>

Status: {paymentIntent.status}

Checkout Session response:

- +
{formattedContent}
); } - -function PrintObject({ - content, -}: { - content: Stripe.PaymentIntent | Stripe.Checkout.Session; -}): JSX.Element { - const formattedContent: string = JSON.stringify(content, null, 2); - return
{formattedContent}
; -} From 8e710c10e90b9b3273a426f4678b1f2d1ac7f50b Mon Sep 17 00:00:00 2001 From: evanbacon Date: Sat, 14 Sep 2024 14:58:06 +0100 Subject: [PATCH 6/7] Update index.tsx --- with-stripe/app/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/with-stripe/app/index.tsx b/with-stripe/app/index.tsx index faaaa543..3ce5bbe1 100644 --- a/with-stripe/app/index.tsx +++ b/with-stripe/app/index.tsx @@ -4,7 +4,7 @@ import { Image, ScrollView, Text, View } from "react-native"; export default function DonatePage(): JSX.Element { return ( From 1de8b5fe2e10a2c37f9969fe67785aad02cf7fca Mon Sep 17 00:00:00 2001 From: evanbacon Date: Sat, 14 Sep 2024 14:58:30 +0100 Subject: [PATCH 7/7] Update _layout.tsx --- with-stripe/app/_layout.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/with-stripe/app/_layout.tsx b/with-stripe/app/_layout.tsx index f7881d69..673ad851 100644 --- a/with-stripe/app/_layout.tsx +++ b/with-stripe/app/_layout.tsx @@ -13,6 +13,7 @@ export default function RootLayout() {