@@ -70,15 +70,23 @@ const createStripePaymentIntent =
|
|||||||
message: 'Could not create payment intent',
|
message: 'Could not create payment intent',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const priceFormatter = new Intl.NumberFormat(
|
||||||
|
options.currency === 'EUR' ? 'fr-FR' : undefined,
|
||||||
|
{
|
||||||
|
style: 'currency',
|
||||||
|
currency: options.currency,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
paymentIntentSecret: paymentIntent.client_secret,
|
paymentIntentSecret: paymentIntent.client_secret,
|
||||||
publicKey:
|
publicKey:
|
||||||
isPreview && stripeKeys.test?.publicKey
|
isPreview && stripeKeys.test?.publicKey
|
||||||
? stripeKeys.test.publicKey
|
? stripeKeys.test.publicKey
|
||||||
: stripeKeys.live.publicKey,
|
: stripeKeys.live.publicKey,
|
||||||
amountLabel: `${
|
amountLabel: priceFormatter.format(
|
||||||
amount / (isZeroDecimalCurrency(options.currency) ? 1 : 100)
|
amount / (isZeroDecimalCurrency(options.currency) ? 1 : 100)
|
||||||
}${currencySymbols[options.currency] ?? ` ${options.currency}`}`,
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,21 +123,3 @@ const isZeroDecimalCurrency = (currency: string) =>
|
|||||||
'XOF',
|
'XOF',
|
||||||
'XPF',
|
'XPF',
|
||||||
].includes(currency)
|
].includes(currency)
|
||||||
|
|
||||||
const currencySymbols: { [key: string]: string } = {
|
|
||||||
USD: '$',
|
|
||||||
EUR: '€',
|
|
||||||
CRC: '₡',
|
|
||||||
GBP: '£',
|
|
||||||
ILS: '₪',
|
|
||||||
INR: '₹',
|
|
||||||
JPY: '¥',
|
|
||||||
KRW: '₩',
|
|
||||||
NGN: '₦',
|
|
||||||
PHP: '₱',
|
|
||||||
PLN: 'zł',
|
|
||||||
PYG: '₲',
|
|
||||||
THB: '฿',
|
|
||||||
UAH: '₴',
|
|
||||||
VND: '₫',
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user