export type BraintreeConfigurationRequest = {paymentServiceProvider: 'braintree' | 'braintreeSandbox' | 'stripe' | 'stripeTest', paymentProviderState: 'active' | 'inactive', merchantId: string, publicKey: string, privateKey: string}; export type StripeConfigurationRequest = {paymentServiceProvider: 'braintree' | 'braintreeSandbox' | 'stripe' | 'stripeTest', paymentProviderState: 'active' | 'inactive', secretKey: string}; export type PatchApiPaymentExecutionTenantLocatorPaymentProvidersLocatorArgs = {tenantLocator: string, locator: unknown, body: BraintreeConfigurationRequest | StripeConfigurationRequest}; export type PatchApiPaymentExecutionTenantLocatorPaymentProvidersLocatorOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * PATCH /payment-execution/{tenantLocator}/paymentProviders/{locator} */ export const patchApiPaymentExecutionTenantLocatorPaymentProvidersLocator = async (args: PatchApiPaymentExecutionTenantLocatorPaymentProvidersLocatorArgs, options: PatchApiPaymentExecutionTenantLocatorPaymentProvidersLocatorOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/payment-execution/${encodeURIComponent(String(args.tenantLocator))}/paymentProviders/${encodeURIComponent(String(args.locator))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };