@sergdudko/stripe-js
Version:
Additional methods for working with stripe-js
28 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.deletePaymentMethodFromCustomer = void 0;
const handlers_1 = require("../utils/handlers");
const constants_1 = require("../utils/constants");
/**
* 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
*/
const deletePaymentMethodFromCustomer = async function (paymentMethodId, ephemeralKey) {
const stripeApiKey = this._apiKey;
if (typeof stripeApiKey !== "string")
throw new Error("Initialization failed.");
// make request
return fetch(`${constants_1.stripeApiUrl}/payment_methods/${paymentMethodId}/detach`, {
headers: {
Authorization: `Bearer ${ephemeralKey}`,
"Content-Type": "application/x-www-form-urlencoded",
"Stripe-Version": `${constants_1.stripeApiVersion}`,
},
method: "POST",
}).then(handlers_1.responseHandler);
};
exports.deletePaymentMethodFromCustomer = deletePaymentMethodFromCustomer;
//# sourceMappingURL=deletePaymentMethodFromCustomer.js.map