const require_fetcher = require('../fetcher.cjs');
const require_built = require('../config/dist/esm/built.cjs');

//#region ../@intlayer/cli/dist/esm/api/dist/esm/getIntlayerAPI/stripe.mjs
const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
	const backendURL = intlayerConfig?.editor?.backendURL ?? require_built.built_default?.editor?.backendURL;
	if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
	const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;
	/**
	* Get a pricing plan calculated for a given promotion code.
	* @param body - Pricing plan body.
	*/
	const getPricing = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/pricing`, authAPIOptions, otherOptions, {
		method: "POST",
		body
	});
	/**
	* Retrieves a checkout session.
	* @param body - Checkout session body.
	*/
	const getSubscription = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/create-subscription`, authAPIOptions, otherOptions, {
		method: "POST",
		body
	});
	/**
	* Cancels a subscription.
	* @param body - Checkout session body.
	*/
	const cancelSubscription = async (otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/cancel-subscription`, authAPIOptions, otherOptions, { method: "POST" });
	return {
		getPricing,
		getSubscription,
		cancelSubscription
	};
};

//#endregion
exports.getStripeAPI = getStripeAPI;
//# sourceMappingURL=stripe.cjs.map