Skip to main content
Glama
stripe.ts1.89 kB
import configuration from '@intlayer/config/built'; import type { IntlayerConfig } from '@intlayer/types'; import { type FetcherOptions, fetcher } from '../fetcher'; import type { GetCheckoutSessionBody, GetCheckoutSessionResult, GetPricingBody, GetPricingResult, } from '../types'; export const getStripeAPI = ( authAPIOptions: FetcherOptions = {}, intlayerConfig?: IntlayerConfig ) => { const backendURL = intlayerConfig?.editor?.backendURL ?? configuration?.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?: GetPricingBody, otherOptions: FetcherOptions = {} ) => await fetcher<GetPricingResult>( `${STRIPE_API_ROUTE}/pricing`, authAPIOptions, otherOptions, { method: 'POST', body, } ); /** * Retrieves a checkout session. * @param body - Checkout session body. */ const getSubscription = async ( body?: GetCheckoutSessionBody, otherOptions: FetcherOptions = {} ) => await fetcher<GetCheckoutSessionResult>( `${STRIPE_API_ROUTE}/create-subscription`, authAPIOptions, otherOptions, { method: 'POST', body, } ); /** * Cancels a subscription. * @param body - Checkout session body. */ const cancelSubscription = async (otherOptions: FetcherOptions = {}) => await fetcher<GetCheckoutSessionResult>( `${STRIPE_API_ROUTE}/cancel-subscription`, authAPIOptions, otherOptions, { method: 'POST', } ); return { getPricing, getSubscription, cancelSubscription, }; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server