UNPKG

@sergdudko/stripe-js

Version:

Supercharge Your Stripe Integration with Enhanced Methods for stripe-js: Take Full Control of Customer Card Management Right from Your Frontend! Elevate Your Payment Processing Capabilities with Ease and Efficiency.

24 lines (23 loc) 948 B
import { responseHandler } from "../utils/handlers.js"; import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js"; /** * Delete payment method from customer. * * @param paymentMethodId - payment method id (see: https://stripe.com/docs/api/customers/object#payment_method_object-id) * @param ephemeralKey - customer ephemeral key * @returns */ export const deletePaymentMethodFromCustomer = async function (paymentMethodId, ephemeralKey) { const stripeApiKey = this._apiKey; if (typeof stripeApiKey !== "string") throw new Error("Initialization failed."); // make request return fetch(`${stripeApiUrl}/payment_methods/${paymentMethodId}/detach`, { headers: { Authorization: `Bearer ${ephemeralKey}`, "Content-Type": "application/x-www-form-urlencoded", "Stripe-Version": `${stripeApiVersion}`, }, method: "POST", }).then(responseHandler); };