Nick: revert trailing comma
This commit is contained in:
@@ -5,7 +5,7 @@ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? "");
|
||||
|
||||
async function getCustomerDefaultPaymentMethod(customerId: string) {
|
||||
const paymentMethods = await stripe.customers.listPaymentMethods(customerId, {
|
||||
limit: 3
|
||||
limit: 3,
|
||||
});
|
||||
return paymentMethods.data[0] ?? null;
|
||||
}
|
||||
@@ -13,14 +13,14 @@ async function getCustomerDefaultPaymentMethod(customerId: string) {
|
||||
type ReturnStatus = "succeeded" | "requires_action" | "failed";
|
||||
export async function createPaymentIntent(
|
||||
team_id: string,
|
||||
customer_id: string
|
||||
customer_id: string,
|
||||
): Promise<{ return_status: ReturnStatus; charge_id: string }> {
|
||||
try {
|
||||
const defaultPaymentMethod =
|
||||
await getCustomerDefaultPaymentMethod(customer_id);
|
||||
if (!defaultPaymentMethod) {
|
||||
logger.error(
|
||||
`No default payment method found for customer: ${customer_id}`
|
||||
`No default payment method found for customer: ${customer_id}`,
|
||||
);
|
||||
return { return_status: "failed", charge_id: "" };
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export async function createPaymentIntent(
|
||||
payment_method_types: [defaultPaymentMethod?.type ?? "card"],
|
||||
payment_method: defaultPaymentMethod?.id,
|
||||
off_session: true,
|
||||
confirm: true
|
||||
confirm: true,
|
||||
});
|
||||
|
||||
if (paymentIntent.status === "succeeded") {
|
||||
@@ -51,7 +51,7 @@ export async function createPaymentIntent(
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Failed to create or confirm PaymentIntent for team: ${team_id}`
|
||||
`Failed to create or confirm PaymentIntent for team: ${team_id}`,
|
||||
);
|
||||
console.error(error);
|
||||
return { return_status: "failed", charge_id: "" };
|
||||
|
||||
Reference in New Issue
Block a user