import {z} from 'zod' export type OPYMerchantExternalMerchantId = string; export type OPYMerchantTradeName = string; export type OPYMerchantCompanyName = string; export type OPYMerchantLegalFormIndex = string; export type OPYMerchantLanguageIndex = string; export type OPYMerchantMcciso = string; export type OPYMerchantECommerceIndCode = 'TRADITIONAL_ONLY' | 'ECOMMERCE_ONLY' | 'BOTH'; export type OPYMerchantResidentStatusCode = 'NA' | 'RESIDENT' | 'NON_RESIDENT'; export type OPYMerchantAccountOfficerIndex = string; export type OPYMerchantRetailerClassificationCode = string; export type OPYMerchantBranchIndex = string; export type MerchantUpdateDetailsRequiredDetails = {externalMerchantId?: OPYMerchantExternalMerchantId | undefined, tradeName?: OPYMerchantTradeName | undefined, companyName?: OPYMerchantCompanyName | undefined, legalForm?: OPYMerchantLegalFormIndex | undefined, languageIndex?: OPYMerchantLanguageIndex | undefined, mcciso?: OPYMerchantMcciso | undefined, eCommerceIndCode?: OPYMerchantECommerceIndCode | undefined, residentStatusCode?: OPYMerchantResidentStatusCode | undefined, accountOfficerIndex?: OPYMerchantAccountOfficerIndex | undefined, retailerClassificationCode?: OPYMerchantRetailerClassificationCode | undefined, branchIndex?: OPYMerchantBranchIndex | undefined}; export type OPYMerchantRegistrationNo = string; export type OPYMerchantVatRegNo = string; export type OPYMerchantSecondaryTaxId = string; export type OPYMerchantContractReference = string; export type OPYMerchantBankReference = string; export type OPYMerchantDynamicPricing = boolean; export type OPYMerchantMerchantGradeIndex = string; export type OPYMerchantProsaDeterminant = string; export type OPYMerchantProsaBDUNumber = string; export type OPYMerchantSignerDateOfBirth = string; export type OPYMerchantMerchantLongName = string; export type OPYMerchantMcpRateType = string; export type OPYMerchantDomesticMcc1 = string; export type MerchantUpdateDetailsOptionalDetails = {registrationNo?: OPYMerchantRegistrationNo | undefined, vatRegNo?: OPYMerchantVatRegNo | undefined, secondaryTaxId?: OPYMerchantSecondaryTaxId | undefined, contractReference?: OPYMerchantContractReference | undefined, bankReference?: OPYMerchantBankReference | undefined, dynamicPricing?: OPYMerchantDynamicPricing | undefined, merchantGradeIndex?: OPYMerchantMerchantGradeIndex | undefined, prosaDeterminant?: OPYMerchantProsaDeterminant | undefined, prosaBDUNumber?: OPYMerchantProsaBDUNumber | undefined, signerDateOfBirth?: OPYMerchantSignerDateOfBirth | undefined, merchantLongName?: OPYMerchantMerchantLongName | undefined, mcpRateType?: OPYMerchantMcpRateType | undefined, domesticMcc?: OPYMerchantDomesticMcc1 | undefined}; export type OPYMerchantPaymentMethodIndex = string; export type OPYMerchantClientRegionIndex = string; export type OPYMerchantReclassBillbackIndicatorCode = 'NA' | 'NO_BILLBACK' | 'AUT_BILLBACK_DR' | 'AUT_BILLBACK_ALL' | 'MANUAL_BILLBACK'; export type OPYMerchantWithholdIncomeTariffIndex = string; export type OPYMerchantWithholdVatTariffIndex = string; export type OPYMerchantRegionalTaxIndex = string; export type MerchantUpdateContractDetails = {paymentMethodIndex?: OPYMerchantPaymentMethodIndex | undefined, protectAgainstFXChange?: boolean | undefined, clientRegionIndex?: OPYMerchantClientRegionIndex | undefined, reclassBillbackIndicatorCode?: OPYMerchantReclassBillbackIndicatorCode | undefined, withholdIncomeTariffIndex?: OPYMerchantWithholdIncomeTariffIndex | undefined, withholdVatTariffIndex?: OPYMerchantWithholdVatTariffIndex | undefined, regionalTaxIndex?: OPYMerchantRegionalTaxIndex | undefined}; export type OPYMerchantCountryCode = string; export type OPYMerchantState = string; export type OPYMerchantCityUrl = string; export type OPYMerchantTelephone = string; export type OPYMerchantZip = string; export type OPYMerchantStreet = string; export type OPYMerchantServiceTelNo = string; export type OPYMerchantCountyIndex = string; export type OPYMerchantFax = string; export type OPYMerchantSalutation = 'THE_DIRECTOR' | 'THE_OWNER' | 'THE_PROPRIETOR'; export type OPYMerchantRegionOverrideFlag = boolean; export type OPYMerchantMunicipalityIndex = string; export type OPYMerchantUrl = string; export type MerchantUpdateDetailsLocation = {country?: OPYMerchantCountryCode | undefined, state?: OPYMerchantState | undefined, cityUrl?: OPYMerchantCityUrl | undefined, telephone?: OPYMerchantTelephone | undefined, zip?: OPYMerchantZip | undefined, street?: OPYMerchantStreet | undefined, serviceTelNo?: OPYMerchantServiceTelNo | undefined, countyIndex?: OPYMerchantCountyIndex | undefined, fax?: OPYMerchantFax | undefined, salutation?: OPYMerchantSalutation | undefined, regionOverrideFlag?: OPYMerchantRegionOverrideFlag | undefined, municipalityIndex?: OPYMerchantMunicipalityIndex | undefined, url?: OPYMerchantUrl | undefined}; export type OPYMerchantCrossBorderFeeCode = 'NONE' | 'MASTERCARD' | 'VISA' | 'BOTH'; export type OPYMerchantMasterCardIPQualificationCode = 'NA' | 'CHARITY' | 'MASTERCARD_AID' | 'GAMBLING'; export type OPYMerchantMasterCardIPValue = string; export type OPYMerchantVisaIPQualificationCode = 'NA' | 'VAU_VALIDATED' | 'VISA_SPEND_QUALF_IND' | 'VISA_EPS' | 'VISA_MVV_PROGRAM' | 'LOW_VALUE_PAYMENTS' | 'CHARITY' | 'SG_EZ_LINK' | 'SG_STRATGC_SUPERMRKT' | 'SG_STRATGC_GOVERNMNT' | 'BILL_PAY' | 'VISA_INDIAN_FUND_TXN' | 'HK_STRATGC_GOV' | 'SG_STRATGC_ULITITIES' | 'SG_STRATGC_VISA_BPAY' | 'TH_STRATGC_4' | 'TH_STRATGC_5' | 'TH_STRATGC_8' | 'SMALL_MERCHANT' | 'CPS_RETAIL' | 'VISA_MVV_PROGRAM_CLR' | 'INDIA_PM_CARES' | 'VISA_MPP_UK' | 'VISA_IND_BPSP_STRATEGIC' | 'VISA_M2M_UK' | 'VISA_M2M_MPP_UK' | 'TRANCHE_2' | 'TRANCHE_3'; export type OPYMerchantVisaIPValue = string; export type OPYMerchantCbdipVisaSmiCode = string; export type OPYMerchantMcPaymentFacilitatorId = string; export type OPYMerchantVisaPaymentFacilitatorId = string; export type OPYMerchantMcIndependentSalesOrgId = string; export type OPYMerchantVisaCanIasfFee = boolean; export type OPYMerchantViLacFeeCode = 'NA' | 'VISA_LAC_IA_FEE' | 'VISA_LAC_ISA_FEE' | 'BOTH_LAC_FEES'; export type OPYMerchantMcLacFeeCode = 'NA' | 'MC_LAC_CB' | 'MC_LAC_CB_REBATE' | 'MC_LAC_BOTH'; export type OPYMerchantMcAbvFeeInd = boolean; export type OPYMerchantVisaEuFeeIndCode = 'NEITHER' | 'VISA_IA_FEE' | 'VISA_ECOM_FEE' | 'BOTH_VISA_EU_FEES'; export type OPYMerchantMcIntlEcomFee = boolean; export type OPYMerchantViUsApIafFee = string; export type OPYMerchantPagobancomatIndex = string; export type OPYMerchantGlobalTravelB2BFeeInd = string; export type OPYMerchantMcCnpMotoFee = 'NO_FEE' | 'MC_CNP_FEE_ONLY' | 'MC_MOTO_FEE_ONLY' | 'BOTH_MC_CNP_&_MOTO_FEE'; export type OPYMerchantMcPifFeeInd = boolean; export type OPYMerchantDinersIntesCode = string; export type OPYMerchantAmexModelIndex = string; export type OPYMerchantMerchantCountryOfOrigin = string; export type OPYMerchantMerchantSizeIndex = string; export type OPYMerchantMvi = 'NOT_ELIGIBLE' | 'VISA_ELIGIBLE'; export type GlobalFees = {feeIndex: string, feeMode: boolean, cardOrganization: string}; export type OPYMerchantUpiIPQualificationCode = string; export type OPYMerchantMarketPlaceId = string; export type OPYMerchantStagedDigitalWalletId = string; export type OPYMerchantRampProviderId = string; export type OPYMerchantAcquirerBusinessId = string; export type OPYMerchantMcStagedDigitalWalletId = string; export type MerchantUpdateDetailsSchemeDetails = {crossBorderFeeCode?: OPYMerchantCrossBorderFeeCode | undefined, masterCardIPQualificationCode?: OPYMerchantMasterCardIPQualificationCode | undefined, masterCardIPValue?: OPYMerchantMasterCardIPValue | undefined, visaIPQualificationCode?: OPYMerchantVisaIPQualificationCode | undefined, visaIPValue?: OPYMerchantVisaIPValue | undefined, paymentLowValue?: boolean | undefined, cbdipVisaSmiCode?: OPYMerchantCbdipVisaSmiCode | undefined, mcPaymentFacilitatorId?: OPYMerchantMcPaymentFacilitatorId | undefined, visaPaymentFacilitatorId?: OPYMerchantVisaPaymentFacilitatorId | undefined, mcIndependentSalesOrgId?: OPYMerchantMcIndependentSalesOrgId | undefined, visaCanIasfFee?: OPYMerchantVisaCanIasfFee | undefined, viLacFeeCode?: OPYMerchantViLacFeeCode | undefined, mcLacFeeCode?: OPYMerchantMcLacFeeCode | undefined, mcAbvFeeInd?: OPYMerchantMcAbvFeeInd | undefined, visaEuFeeIndCode?: OPYMerchantVisaEuFeeIndCode | undefined, mcIntlEcomFee?: OPYMerchantMcIntlEcomFee | undefined, viUsApIafFee?: OPYMerchantViUsApIafFee | undefined, pagobancomatIndex?: OPYMerchantPagobancomatIndex | undefined, globalTravelB2BFeeInd?: OPYMerchantGlobalTravelB2BFeeInd | undefined, mcCnpMotoFee?: OPYMerchantMcCnpMotoFee | undefined, mcPifFeeInd?: OPYMerchantMcPifFeeInd | undefined, dinersIntesCode?: OPYMerchantDinersIntesCode | undefined, amexModelIndex?: OPYMerchantAmexModelIndex | undefined, merchantCountryOfOrigin?: OPYMerchantMerchantCountryOfOrigin | undefined, merchantSizeIndex?: OPYMerchantMerchantSizeIndex | undefined, mvi?: OPYMerchantMvi | undefined, globalFees?: Array | undefined, upiIPQualificationCode?: OPYMerchantUpiIPQualificationCode | undefined, marketPlaceId?: OPYMerchantMarketPlaceId | undefined, stagedDigitalWalletId?: OPYMerchantStagedDigitalWalletId | undefined, rampProviderId?: OPYMerchantRampProviderId | undefined, acquirerBusinessId?: OPYMerchantAcquirerBusinessId | undefined, mcStagedDigitalWalletId?: OPYMerchantMcStagedDigitalWalletId | undefined}; export type OPYSalesDetailsAccSignedDate = string; export type OPYSalesDetailsAccCreationDate = string; export type OPYSalesDetailsAccApprovalDate = string; export type OPYSalesDetailsSalesAgentId = string; export type OPYSalesDetailsBusinessOwnerId = string; export type OPYSalesDetailsSalesChannelIndex = string; export type OPYSalesDetailsSalesCurrencyCode = string; export type OPYSalesDetailsSignedSalesValue = string; export type OPYSalesDetailsSignedAverageTicketValue = string; export type OPYSalesDetailsSalesLead = string; export type OPYSalesDetailsSignedNumberSales = string; export type OPYMerchantPriorityMemo = string; export type MerchantUpdateDetailsSalesDetails = {accSignedDate?: OPYSalesDetailsAccSignedDate | undefined, accCreationDate?: OPYSalesDetailsAccCreationDate | undefined, accApprovalDate?: OPYSalesDetailsAccApprovalDate | undefined, salesAgentId?: OPYSalesDetailsSalesAgentId | undefined, businessOwnerId?: OPYSalesDetailsBusinessOwnerId | undefined, salesChannel?: OPYSalesDetailsSalesChannelIndex | undefined, salesCurrencyCode?: OPYSalesDetailsSalesCurrencyCode | undefined, signedSalesValue?: OPYSalesDetailsSignedSalesValue | undefined, signedAverageTicketValue?: OPYSalesDetailsSignedAverageTicketValue | undefined, salesLead?: OPYSalesDetailsSalesLead | undefined, signedNumberSales?: OPYSalesDetailsSignedNumberSales | undefined, priorityMemo?: OPYMerchantPriorityMemo | undefined}; export type MerchantUpdateDetails = {requiredDetails?: MerchantUpdateDetailsRequiredDetails | undefined, optionalDetails?: MerchantUpdateDetailsOptionalDetails | undefined, contracts?: MerchantUpdateContractDetails | undefined, location?: MerchantUpdateDetailsLocation | undefined, schemeDetails?: MerchantUpdateDetailsSchemeDetails | undefined, salesDetails?: MerchantUpdateDetailsSalesDetails | undefined}; export type UpdateApiMerchantDetailsArgs = {'Content-Type': 'application/json' | 'application/json;charset=UTF-8', 'FSV-Interaction-Id': string, Environment: string, 'Institution-Number': string, 'Internal-Merchant-Id': string, body: MerchantUpdateDetails}; export type UpdateApiMerchantDetailsOptions = {baseUrl?: string | undefined, AppKey?: string | undefined, JWSSignature?: string | undefined, fetch?: typeof fetch | undefined}; export const pagingMetaType = z.object({count: z.number().int().optional(), totalPages: z.number().int().optional(), currentOffset: z.number().int().optional(), currentNumberOfRetrievedRecords: z.number().int().optional(), maxLimit: z.number().int().optional(), hasMoreRecords: z.boolean().optional(), pageNumber: z.number().int().optional()}); export const sortingMetaType = z.object({sort: z.string().optional()}); export const sourceType = z.object({pointer: z.string().optional(), parameter: z.string().optional(), header: z.string().optional()}); export const errorType = z.object({id: z.string().optional(), code: z.string(), title: z.string(), detail: z.string().optional(), source: sourceType.optional()}); export const metaType = z.object({paging: pagingMetaType.optional(), sorting: sortingMetaType.optional(), messages: z.array(errorType).optional()}); export const linksType = z.object({self: z.string().optional(), first: z.string().optional(), last: z.string().optional(), prev: z.string().optional(), next: z.string().optional()}); export const inlineResponse400 = z.object({meta: metaType.optional(), data: z.array(z.object({})).optional(), errors: z.array(errorType).optional(), links: linksType.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update merchant details information * * PUT /merchant-details */ export const updateApiMerchantDetails = async (args: UpdateApiMerchantDetailsArgs, options?: UpdateApiMerchantDetailsOptions) => { const {baseUrl = "https://prod.emea.api.fiservapps.com/ipp/omnipay/acquirerprofile/v1.0", fetch: fetchFn = fetch, AppKey, JWSSignature} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (args['FSV-Interaction-Id'] != null) headers.set("FSV-Interaction-Id", String(args['FSV-Interaction-Id'])) if (args.Environment != null) headers.set("Environment", String(args.Environment)) if (args['Institution-Number'] != null) headers.set("Institution-Number", String(args['Institution-Number'])) if (args['Internal-Merchant-Id'] != null) headers.set("Internal-Merchant-Id", String(args['Internal-Merchant-Id'])) if (AppKey !== undefined) headers.set("Api-Key", AppKey) if (JWSSignature !== undefined) headers.set("JWS-Signature", JWSSignature) const url = `${baseUrl.replace(/\/+$/, '')}/merchant-details${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 validateResponse(inlineResponse400, await res.json()) };