-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable all payments through Stripe. Resolve #587
- Loading branch information
Showing
5 changed files
with
2,005 additions
and
2,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/react-components/src/utils/stripe/retrievePaymentIntent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { loadStripe, type PaymentIntentResult } from '@stripe/stripe-js' | ||
|
||
interface StripePaymentIntentParams { | ||
publicApiKey: string | ||
paymentIntentClientSecret: string | ||
} | ||
|
||
type PaymentIntentResultPromise = Promise< | ||
PaymentIntentResult | undefined | null | ||
> | ||
|
||
export async function retrievePaymentIntent({ | ||
publicApiKey, | ||
paymentIntentClientSecret | ||
}: StripePaymentIntentParams): PaymentIntentResultPromise { | ||
const stripe = await loadStripe(publicApiKey) | ||
try { | ||
const paymentIntent = await stripe?.retrievePaymentIntent( | ||
paymentIntentClientSecret | ||
) | ||
return paymentIntent | ||
} catch (error) { | ||
console.error('Error retrieving payment intent:', error) | ||
return null | ||
} | ||
} |
Oops, something went wrong.