|
@@ -1,16 +1,14 @@
|
|
|
import { FetchError, postJSON } from '@/infrastructure/fetch-json'
|
|
import { FetchError, postJSON } from '@/infrastructure/fetch-json'
|
|
|
-import getMeta from '../../../utils/meta'
|
|
|
|
|
import { loadStripe } from '@stripe/stripe-js/pure'
|
|
import { loadStripe } from '@stripe/stripe-js/pure'
|
|
|
|
|
|
|
|
export default async function handleStripePaymentAction(
|
|
export default async function handleStripePaymentAction(
|
|
|
error: FetchError
|
|
error: FetchError
|
|
|
): Promise<{ handled: boolean }> {
|
|
): Promise<{ handled: boolean }> {
|
|
|
const clientSecret = error?.data?.clientSecret
|
|
const clientSecret = error?.data?.clientSecret
|
|
|
|
|
+ const publicKey = error?.data?.publicKey
|
|
|
|
|
|
|
|
- if (clientSecret) {
|
|
|
|
|
- // TODO: support both US and UK Stripe accounts
|
|
|
|
|
- const stripeUKPublicKey = getMeta('ol-stripeUKApiKey')
|
|
|
|
|
- const stripe = await loadStripe(stripeUKPublicKey)
|
|
|
|
|
|
|
+ if (clientSecret && publicKey) {
|
|
|
|
|
+ const stripe = await loadStripe(publicKey)
|
|
|
if (stripe) {
|
|
if (stripe) {
|
|
|
const manualConfirmationFlow =
|
|
const manualConfirmationFlow =
|
|
|
await stripe.confirmCardPayment(clientSecret)
|
|
await stripe.confirmCardPayment(clientSecret)
|