export type Currency = 'EUR'; export type PaymentAmount = number; export type MerchantAcknowledge = {currency: Currency, amount: PaymentAmount, reference?: string | undefined}; export type CreateApiV3PaymentsIdAcknowledgeArgs = {id: string, body: MerchantAcknowledge}; export type CreateApiV3PaymentsIdAcknowledgeOptions = {baseUrl?: string | undefined, apiKeyPaymentProfile?: string | undefined, fetch?: typeof fetch | undefined}; /** * Merchant acknowledges payment status callback was received * * POST /v3/payments/{id}/acknowledge * * Also accepts auth: JWS-Request-Signature-Payment */ export const createApiV3PaymentsIdAcknowledge = async (args: CreateApiV3PaymentsIdAcknowledgeArgs, options?: CreateApiV3PaymentsIdAcknowledgeOptions) => { const {baseUrl = "https://merchant.api.preprod.bancontact.net", fetch: fetchFn = fetch, apiKeyPaymentProfile} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKeyPaymentProfile !== undefined) headers.set("Authorization", apiKeyPaymentProfile) const url = `${baseUrl.replace(/\/+$/, '')}/v3/payments/${encodeURIComponent(String(args.id))}/acknowledge${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 undefined };