|
|
@@ -12,9 +12,19 @@ export default async function handleStripePaymentAction(
|
|
|
if (stripe) {
|
|
|
const manualConfirmationFlow =
|
|
|
await stripe.confirmCardPayment(clientSecret)
|
|
|
- if (!manualConfirmationFlow.error) {
|
|
|
+ if (manualConfirmationFlow.error) {
|
|
|
+ const paymentIntentId = manualConfirmationFlow.error.payment_intent?.id
|
|
|
try {
|
|
|
- await postJSON(`/user/subscription/sync`)
|
|
|
+ await postJSON(
|
|
|
+ `/user/subscription/void-change?payment_intent_id=${paymentIntentId}`
|
|
|
+ )
|
|
|
+ } catch (error) {
|
|
|
+ // do nothing
|
|
|
+ }
|
|
|
+ return { handled: false }
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ await postJSON('/user/subscription/sync')
|
|
|
} catch (error) {
|
|
|
// if the sync fails, there may be stale data until the webhook is
|
|
|
// processed but we can't do any special handling for that in here
|