import type Stripe from 'stripe' ; export const generateResponse = ( intent ) : { clientSecret : string | null ; requiresAction : boolean ; status : string ; } | { clientSecret : string | null ; status : string ; } | { error : string ; } => { switch ( intent . status ) { case 'requires_action' : return { clientSecret : intent . client_secret , requiresAction : true , status : intent . status , } ; case 'requires_payment_method' : return { error : 'Your card was denied, please provide a new payment method' , } ; case 'succeeded' : console . log ( '💰 Payment received!' ) ; return { clientSecret : intent . client_secret , status : intent . status } ; } return { error : 'Failed' , } ; } ;