{"version":3,"file":"index.cjs","sources":["../src/client.ts","../src/types.ts","../src/provisioning/client.ts","../src/provisioning/fetchAPIUser.ts","../src/provisioning/createAPIUser.ts","../src/provisioning/createAPIKey.ts","../src/tokens/client.ts","../src/tokens/createAccessToken.ts","../src/tokens/createOrRefreshAccessToken.ts","../src/products/common/createValidateAccountHolderStatus.ts","../src/products/common/client.ts","../src/products/common/withAuthorization.ts","../src/products/common/createAccountBalanceFetcher.ts","../src/products/common/createGetBasicUserInfo.ts","../src/products/common/createRequestToPayDeliveryNotification.ts","../src/products/common/utils.ts","../src/products/common/createTransactionInitiator.ts","../src/products/common/createTransactionStatusFetcher.ts","../src/products/common/types.ts","../src/provisioning/provision.ts","../src/products/collection.ts","../src/products/disbursement.ts","../src/products/remittance.ts"],"sourcesContent":["import axios from 'axios';\nimport path from 'path';\n\nimport type { APIVersion } from './types';\n\nconst V2_PATH = 'v2_0';\n\nconst V1_PATH = 'v1_0';\n\nconst DEFAULT_CONTENT_TYPE = 'application/json';\n\nconst API_VERSION_PATH: Record<APIVersion, string> = {\n  v1: V1_PATH,\n  v2: V2_PATH,\n};\n\nconst urlPathFrom = (paths: string[]): string => path.join(...paths);\n\nconst BASE_URL = 'https://sandbox.momodeveloper.mtn.com/';\n\ntype HeaderOverrides = {\n  'Content-Type'?: string;\n  'X-Target-Environment'?: string;\n  Authorization?: string;\n};\n\ntype ClientOptions = {\n  subscriptionKey: string;\n\n  baseURL?: string;\n  headerOverrides?: HeaderOverrides;\n};\n\nconst createClient = ({\n  subscriptionKey,\n  baseURL = BASE_URL,\n  headerOverrides,\n}: ClientOptions) =>\n  axios.create({\n    headers: {\n      'Content-Type': 'application/json',\n      'Ocp-Apim-Subscription-Key': subscriptionKey,\n      ...headerOverrides,\n    },\n    baseURL,\n  });\n\nexport {\n  API_VERSION_PATH,\n  BASE_URL,\n  DEFAULT_CONTENT_TYPE,\n  createClient,\n  urlPathFrom,\n};\n","enum TargetEnvironment {\n  Sandbox = 'sandbox',\n  Production = 'production',\n}\n\nenum Product {\n  Collection = 'collection',\n  Disbursement = 'disbursement',\n  Remittance = 'remittance',\n}\n\ntype APIVersion = 'v1' | 'v2';\n\nexport { TargetEnvironment, Product };\nexport type { APIVersion };\n","import type { AxiosInstance } from 'axios';\n\nimport {\n  API_VERSION_PATH,\n  BASE_URL,\n  createClient,\n  urlPathFrom,\n} from '../client';\nimport type { APIVersion } from '../types';\n\nlet client: AxiosInstance | null;\n\ntype CreateProvisioningClientOptions = {\n  /**\n   * The primary key for any of the subscriptions you want to access. Can be found in your momo developer profile under subscriptions\n   * Check out https://momodeveloper.mtn.com/products to subscribe to a product and obtain a subscription key\n   */\n  subscriptionKey: string;\n\n  /** The version of the api we are accessing. Defaults to v1. At the time of writing of this user provisions only has one version */\n  apiVersion?: APIVersion;\n};\n\n/**\n * Creates a client to use when creating api requests for provisioning a user\n * @param {CreateProvisioningClientOptions} options properties to use when creating the client\n * @returns {AxiosInstance} the client to use when making requests to create the user. Its pre configured with the baseURL and common headers needed for these operations.\n */\nconst createProvisioningClient = ({\n  subscriptionKey,\n  apiVersion = 'v1',\n}: CreateProvisioningClientOptions): AxiosInstance => {\n  if (client) return client;\n\n  const baseURL =\n    BASE_URL + urlPathFrom([API_VERSION_PATH[apiVersion], 'apiuser']);\n\n  return createClient({ subscriptionKey, baseURL });\n};\n\nexport { createProvisioningClient };\n","import { AxiosInstance } from 'axios';\nimport type { TargetEnvironment } from '../types';\n\ntype FetchAPIUserOptions = {\n  /** A uuid corresponding to the id of the user whose details we have to fetch */\n  userId: string;\n\n  /** The instance to fetch the user details */\n  client: AxiosInstance;\n};\n\ntype FetchAPIUserResult = {\n  /** The environment which we are accessing. Its always sandbox when in the sandbox environment */\n  targetEnvironment: TargetEnvironment;\n\n  /** The host to redirect to after some actions that require redirection */\n  providerCallbackHost: string;\n};\n\n/**\n * Fetches the details of the api user\n * @param {FetchAPIUserOptions} options properties to use when fetching an API user\n * @returns {Promise<FetchAPIUserResult>} an object containing the targetEnvironment and providerCallbackHost of the api user\n */\nconst fetchAPIUser = async ({\n  userId,\n  client,\n}: FetchAPIUserOptions): Promise<FetchAPIUserResult> => {\n  const { data } = await client.get<FetchAPIUserResult>(`/${userId}`);\n\n  return data;\n};\n\nexport { fetchAPIUser };\n","import { AxiosInstance } from 'axios';\nimport { v4 } from 'uuid';\n\ntype CreateAPIUserOptions = {\n  /** The link you want some payment operations to redirect to. */\n  providerCallbackHost: string;\n\n  /** The client to make the api request */\n  client: AxiosInstance;\n};\n\ntype CreateAPIUserResult = {\n  /** A uuid which corresponds to the id of the created user in the sandbox */\n  userId: string;\n};\n\n/**\n * Creates a user and returns the userId of the created user in the sandbox\n * @param {CreateAPIUserOptions} options properties needed to create a user id\n * @returns {Promise<CreateAPIUserResult>} An object containing the userId of the created user\n */\nconst createAPIUser = async ({\n  client,\n  providerCallbackHost,\n}: CreateAPIUserOptions): Promise<CreateAPIUserResult> => {\n  const userId = v4();\n\n  await client.post(\n    '',\n    { providerCallbackHost },\n    { headers: { 'X-Reference-Id': userId } }\n  );\n\n  return { userId };\n};\n\nexport { createAPIUser };\n","import { AxiosInstance } from 'axios';\nimport { urlPathFrom } from '../client';\n\ntype CreateAPIKeyOptions = {\n  /** A uuid which corresponds to the id of the user whose api key is to be created */\n  userId: string;\n\n  /** The instance to use while making the api request */\n  client: AxiosInstance;\n};\n\ntype CreateAPIKeyResult = {\n  /** The key to be used in the authentication header when requesting for an access token */\n  apiKey: string;\n};\n\n/**\n * Create a key to use in the authentication header when requesting for an access token\n * @param {CreateAPIKeyOptions} options properties needed to create an api key\n * @returns {Promise<CreateAPIKeyResult>} An object containing the created apiKey\n */\nconst createAPIKey = async ({\n  userId,\n  client,\n}: CreateAPIKeyOptions): Promise<CreateAPIKeyResult> => {\n  const path = urlPathFrom([userId, 'apikey']);\n\n  const { data } = await client.post<CreateAPIKeyResult>(path);\n\n  return data;\n};\n\nexport { createAPIKey };\n","import { AxiosInstance } from 'axios';\n\nimport { BASE_URL, createClient } from '../client';\nimport { Product, TargetEnvironment } from '../types';\n\ntype CreateTokenClientOptions = {\n  /** The product you want to generate an authentication token for */\n  targetProduct: Product;\n\n  /** Subscription key which provides access to a target product API. Its is the primary key of each product */\n  subscriptionKey: string;\n\n  /** The environment we are targeting. Can either be 'sandbox or production' */\n  targetEnvironment: TargetEnvironment;\n\n  /** The id of the api user */\n  userId: string;\n\n  /** The apiKey of the user */\n  apiKey: string;\n};\n\nconst clientCache: Partial<Record<Product, AxiosInstance>> = {};\n\n/**\n * Creates a client to use when generating authentication tokens. Ensures a single client is created for the same product.\n * @param {CreateTokenClientOptions} options options to use when creating a token generating client\n * @returns {AxiosInstance} the client you can use to talk to token generation endpoints\n */\nconst createTokenClient = ({\n  subscriptionKey,\n  targetEnvironment,\n  targetProduct,\n  userId,\n  apiKey,\n}: CreateTokenClientOptions): AxiosInstance => {\n  let client = clientCache[targetProduct];\n\n  if (client) return client;\n\n  const baseURL = BASE_URL + targetProduct;\n  const authToken = Buffer.from(`${userId}:${apiKey}`).toString('base64');\n\n  client = createClient({\n    subscriptionKey,\n    headerOverrides: {\n      'X-Target-Environment': targetEnvironment,\n      Authorization: `Basic ${authToken}`,\n    },\n    baseURL,\n  });\n\n  clientCache[targetProduct] = client;\n  return client;\n};\n\nexport { createTokenClient };\nexport type { CreateTokenClientOptions };\n","import { CreateTokenClientOptions, createTokenClient } from './client';\n\nconst EXPIRY_OFFSET = 30000; // 30 seconds\n\nconst expiresInToExpiresAt = (expiresIn: number): number =>\n  Date.now() + expiresIn * 1000 - EXPIRY_OFFSET;\n\ntype CreateAccessTokenOptions = CreateTokenClientOptions;\n\ntype CreateAccessTokenRequestResponse = {\n  access_token: string;\n  token_type: string;\n  expires_in: number;\n};\n\ntype CreateAccessTokenResult = {\n  /** The authentication token you will use to access other endpoints */\n  accessToken: string;\n\n  /** The  token type */\n  tokenType: string;\n\n  /** The validity time in seconds of the token. */\n  expiresIn: number;\n\n  /** The timestamp in milliseconds at which the token will expiry offset by 30 secs */\n  expiresAt: number;\n};\n\n/**\n * Create an access token which can then be used to authorize and authenticate towards the other end-points of the API. Throws errors from the API when request is not successful\n * @param {CreateAccessTokenOptions} options the properties you need to create an access token\n * @returns {Promise<CreateAccessTokenResult>} the access token details\n */\nconst createAccessToken = async (\n  options: CreateAccessTokenOptions\n): Promise<CreateAccessTokenResult> => {\n  const client = createTokenClient(options);\n  const { data } = await client.post<CreateAccessTokenRequestResponse>(\n    '/token/'\n  );\n  const expiresAt = expiresInToExpiresAt(data.expires_in);\n  return {\n    expiresAt,\n    accessToken: data.access_token,\n    tokenType: data.token_type,\n    expiresIn: data.expires_in,\n  };\n};\n\nexport { createAccessToken, expiresInToExpiresAt };\nexport type { CreateAccessTokenResult, CreateAccessTokenOptions };\n","import { Product } from '../types';\nimport {\n  createAccessToken,\n  CreateAccessTokenOptions,\n  CreateAccessTokenResult,\n} from './createAccessToken';\n\ntype TokenDetails = CreateAccessTokenResult;\n\ntype TokenDetailsVariant = Product;\n\nconst tokenCache: Partial<Record<TokenDetailsVariant, TokenDetails>> = {};\n\nconst createOrRefreshAccessToken = async (\n  options: CreateAccessTokenOptions\n): Promise<TokenDetails> => {\n  let tokenDetails = tokenCache[options.targetProduct];\n  const isExpired = Date.now() > (tokenDetails?.expiresAt || 0);\n\n  if (!tokenDetails || isExpired) {\n    tokenDetails = await createAccessToken(options);\n    tokenCache[options.targetProduct] = tokenDetails;\n  }\n\n  return tokenDetails;\n};\n\nexport { createOrRefreshAccessToken };\n","import { AxiosInstance } from 'axios';\nimport { urlPathFrom } from '../../client';\n\nenum AccountHolderIdVariant {\n  msisdn = 'msisdn',\n  email = 'email',\n  partyCode = 'party_code',\n}\n\ntype ValidateAccountHolderStatusOptions = {\n  /**\n   * Specifies the type of the party ID. Allowed values [msisdn, email, party_code].\n   * accountHolderId should explicitly be in small letters.\n   */\n  accountHolderIdType: AccountHolderIdVariant;\n\n  /**\n   * The party number. Validated according to the party ID type (case Sensitive).\n   * msisdn - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN\n   * email - Validated to be a valid e-mail format. Validated with IsEmail\n   * party_code - UUID of the party. Validated with IsUuid\n   */\n  accountHolderId: string;\n};\n\ntype ValidateAccountHolderStatus = (\n  options: ValidateAccountHolderStatusOptions\n) => Promise<boolean>;\n\nconst createValidateAccountHolderStatus =\n  ({ client }: { client: AxiosInstance }) =>\n  async ({\n    accountHolderIdType,\n    accountHolderId,\n  }: ValidateAccountHolderStatusOptions): Promise<boolean> => {\n    const path = urlPathFrom([\n      '/accountholder/',\n      accountHolderIdType,\n      accountHolderId,\n      '/active',\n    ]);\n    const { data } = await client.get<{ result: boolean }>(path);\n    return data.result;\n  };\n\nexport { createValidateAccountHolderStatus, AccountHolderIdVariant };\nexport type { ValidateAccountHolderStatus };\n","import { AxiosInstance } from 'axios';\n\nimport {\n  API_VERSION_PATH,\n  BASE_URL,\n  createClient,\n  urlPathFrom,\n} from '../../client';\nimport { APIVersion, Product, TargetEnvironment } from '../../types';\n\nimport { withAuthorization } from './withAuthorization';\n\ntype CreateProductClientOptions = {\n  subscriptionKey: string;\n  targetEnvironment: TargetEnvironment;\n  targetProduct: Product;\n  apiKey: string;\n  userId: string;\n  apiVersion?: APIVersion;\n};\n\ntype Client = `${Product}-${APIVersion}`;\n\nconst clientCache: Partial<Record<Client, AxiosInstance>> = {};\n\nconst createProductClient = ({\n  subscriptionKey,\n  targetEnvironment,\n  apiVersion = 'v1',\n  targetProduct,\n  userId,\n  apiKey,\n}: CreateProductClientOptions): AxiosInstance => {\n  const clientKey: Client = `${targetProduct}-${apiVersion}`;\n  let client = clientCache[clientKey];\n\n  if (client) return client;\n\n  const baseURL =\n    BASE_URL + urlPathFrom([targetProduct, API_VERSION_PATH[apiVersion]]);\n\n  client = createClient({\n    subscriptionKey,\n    headerOverrides: {\n      'X-Target-Environment': targetEnvironment,\n    },\n    baseURL,\n  });\n\n  withAuthorization({\n    client,\n    config: {\n      apiKey,\n      userId,\n      targetProduct,\n      subscriptionKey,\n      targetEnvironment,\n    },\n  });\n\n  clientCache[clientKey] = client;\n  return client;\n};\n\nexport { createProductClient };\nexport type { CreateProductClientOptions };\n","import { AxiosInstance, AxiosRequestHeaders } from 'axios';\n\nimport { createOrRefreshAccessToken } from '../../tokens/createOrRefreshAccessToken';\nimport { CreateAccessTokenOptions } from '../../tokens';\n\nconst withAuthorization = ({\n  client,\n  config,\n}: {\n  client: AxiosInstance;\n  config: CreateAccessTokenOptions;\n}): void => {\n  client.interceptors.request.use(async (request) => {\n    // we don't want this to run at client creation time but at the time a request is made\n    const { accessToken } = await createOrRefreshAccessToken(config);\n    return {\n      ...request,\n      headers: {\n        ...request.headers,\n        Authorization: `Bearer ${accessToken}`,\n      } as AxiosRequestHeaders,\n    };\n  });\n};\n\nexport { withAuthorization };\n","import { AxiosInstance } from 'axios';\n\ntype CreateAccountBalanceFetcherOptions = {\n  /** The client to fetch the account balance */\n  client: AxiosInstance;\n};\n\ntype AccountBalance = {\n  /**  The available balance of the account */\n  availableBalance: string;\n\n  /** ISO4217 Currency */\n  currency: string;\n};\n\ntype FetchAccountBalance = () => Promise<AccountBalance>;\n\nconst createAccountBalanceFetcher =\n  ({ client }: CreateAccountBalanceFetcherOptions) =>\n  async () => {\n    const { data } = await client.get<AccountBalance>('/account/balance');\n    return data;\n  };\n\nexport { createAccountBalanceFetcher };\nexport type { FetchAccountBalance };\n","import { AxiosInstance } from 'axios';\n\ntype BasicUserInfoResult = {\n  updated_at: number;\n  given_name: string;\n  family_name: string;\n  birthdate: string;\n  locale: string;\n  gender: string;\n  status: string;\n  name: string;\n  sub: string;\n};\n\ntype BasicUserInfo = {\n  /**\n   * Given name(s) or first name(s) of the End-User.\n   * Note that in some cultures, people can have multiple given names; all can be present,\n   * with the names being separated by space characters.\n   */\n  givenName: string;\n\n  /** Surname(s) or last name(s) of the End-User.\n   * Note that in some cultures, people can have multiple family names or no family name;\n   * all can be present, with the names being separated by space characters.\n   */\n  familyName: string;\n\n  /** Combined givenName and familyName */\n  name: string;\n\n  /** Account holder birth date. */\n  birthDate: string;\n\n  /**\n   * End-User's locale, represented as a  BCP47 [RFC5646] language tag.\n   * This is typically an  ISO 639-1 Alpha-2 [ISO639�|�1] language code in lowercase\n   * and an  ISO 3166-1 Alpha-2 [ISO3166�|�1] country code in uppercase, separated by a dash.\n   * For example,  en-US or  fr-CA. As a compatibility note, some implementations have used an\n   * underscore as the separator rather than a dash, for example,  en_US; Relying Parties may\n   * choose to accept this locale syntax as well.\n   */\n  locale: string;\n\n  /**\n   * End-User's gender. Values defined by this specification are female and male.\n   *  Other values may be used when neither of the defined values are applicable\n   */\n  gender: string;\n\n  /** Account holder status. */\n  status: string;\n\n  /** Timestamp in seconds indicating when user was last updated */\n  updatedAt: number;\n\n  sub: string;\n};\n\ntype FetchBasicUserInfoOptions = {\n  /** The phone number of the user whose info we are fetching */\n  accountHolderMSISDN: string;\n};\n\ntype FetchBasicUserInfo = (\n  options: FetchBasicUserInfoOptions\n) => Promise<BasicUserInfo>;\n\nconst createBasicUserInfoFetcher =\n  ({ client }: { client: AxiosInstance }) =>\n  async ({\n    accountHolderMSISDN,\n  }: FetchBasicUserInfoOptions): Promise<BasicUserInfo> => {\n    const { data } = await client.get<BasicUserInfoResult>(\n      `accountholder/msisdn/${accountHolderMSISDN}/basicuserinfo`\n    );\n    const { sub, status, gender, name, locale } = data;\n    return {\n      sub,\n      status,\n      gender,\n      name,\n      locale,\n      birthDate: data.birthdate,\n      givenName: data.given_name,\n      familyName: data.family_name,\n      updatedAt: data.updated_at,\n    };\n  };\n\nexport { createBasicUserInfoFetcher };\nexport type { FetchBasicUserInfo };\n","import { AxiosInstance } from 'axios';\nimport { urlPathFrom } from '../../client';\n\ntype RequestToPayDeliveryNotificationOptions = {\n  /** The referenceId of the transaction  */\n  referenceId: string;\n\n  /** The message to send in the delivery notification. Max length 160. */\n  notificationMessage: string;\n\n  /**\n   * An ISO 639-1 or ISO 639-3 language code. The language is used to select\n   * the best matching notification template when sending the delivery\n   * notification to the end-user. A default value is used if not specified.\n   */\n  language?: string;\n};\n\ntype RequestToPayDeliveryNotificationResult = Pick<\n  RequestToPayDeliveryNotificationOptions,\n  'notificationMessage'\n>;\n\ntype RequestToPayDeliveryNotification = (\n  options: RequestToPayDeliveryNotificationOptions\n) => Promise<RequestToPayDeliveryNotificationResult>;\n\ntype CreateRequestToPayDeliveryNotificationOptions = { client: AxiosInstance };\n\ntype CreateRequestToPayDeliveryNotification = (\n  options: CreateRequestToPayDeliveryNotificationOptions\n) => RequestToPayDeliveryNotification;\n\nconst createRequestToPayDeliveryNotification: CreateRequestToPayDeliveryNotification =\n\n    ({ client }) =>\n    async ({ referenceId, notificationMessage, language: Language }) => {\n      const path = urlPathFrom([\n        '/requesttopay/',\n        referenceId,\n        '/deliverynotification',\n      ]);\n      await client.post(\n        path,\n        {\n          notificationMessage,\n        },\n        { headers: { Language } }\n      );\n      return { notificationMessage };\n    };\n\nexport { createRequestToPayDeliveryNotification };\nexport type { RequestToPayDeliveryNotification };\n","import { Product } from '../../types';\n\nconst TRANSACTION_URL_PATHS: Record<Product, string> = {\n  collection: '/requesttopay',\n  disbursement: '/transfer',\n  remittance: '/transfer',\n};\n\nexport { TRANSACTION_URL_PATHS };\n","import { AxiosInstance } from 'axios';\nimport { v4 } from 'uuid';\n\nimport { Product } from '../../types';\n\nimport { TRANSACTION_URL_PATHS } from './utils';\nimport { TransactionParty } from './types';\n\ntype RequestToPayResult = {\n  /**\n   * Resource ID of the created request to pay transaction.\n   * This ID is used, for example, validating the status of the request.\n   * ‘Universal Unique ID’ for the transaction generated using UUID version 4.\n   */\n  referenceId: string;\n};\n\ntype RequestToPayOptions<T extends Product> = {\n  /** Amount that will be debited from the payer account. */\n  amount: string;\n\n  /** ISO4217 Currency */\n  currency: string;\n\n  /**\n   * External id is used as a reference to the transaction.\n   * External id is used for reconciliation.\n   * The external id will be included in transaction history report.\n   * External id is not required to be unique.\n   */\n  externalId: string;\n\n  /** Message that will be written in the payer transaction history message field. */\n  payerMessage: string;\n\n  /** Message that will be written in the payee transaction history note field. */\n  payeeNote: string;\n\n  /**  URL to the server where the callback should be sent. */\n  callbackURL?: string;\n} & TransactionParty<T>;\n\ntype CreateTransactionInitiatorOptions<T extends Product> = {\n  /**\n   * The client to use when initiating a payment.\n   * Its different for different product endpoint and different for different versions of the same product endpoints\n   */\n  client: AxiosInstance;\n\n  /** The target product */\n  targetProduct: T;\n};\n\ntype InitiateTransaction<T extends Product> = (\n  options: RequestToPayOptions<T>\n) => Promise<RequestToPayResult>;\n\ntype TransactionInitiatorCreator = <T extends Product>(\n  options: CreateTransactionInitiatorOptions<T>\n) => InitiateTransaction<T>;\n\n/**\n * Creates a function to initiate an payment.\n * @param options Options to use when creating a function to initiate a payment.\n * @returns A function that is used to initiate a payment.  The payer will be asked to authorize the payment.\n * The transaction will be executed once the payer has authorized the payment.\n * The payment request will be in status PENDING until the transaction is authorized or declined by the payer or it is timed out by the system.\n */\nconst createTransactionInitiator: TransactionInitiatorCreator =\n  ({ client, targetProduct }) =>\n  async ({ callbackURL, ...body }) => {\n    const referenceId = v4();\n    const path = TRANSACTION_URL_PATHS[targetProduct];\n    await client.post(path, body, {\n      headers: { 'X-Callback-Url': callbackURL, 'X-Reference-Id': referenceId },\n    });\n    return { referenceId };\n  };\n\nexport { createTransactionInitiator };\nexport type { InitiateTransaction };\n","import { AxiosInstance } from 'axios';\n\nimport { urlPathFrom } from '../../client';\nimport { Product } from '../../types';\n\nimport { TransactionParty } from './types';\nimport { TRANSACTION_URL_PATHS } from './utils';\n\nconst TransactionStatusReasonCodes = [\n  'PAYEE_NOT_FOUND',\n  'PAYER_NOT_FOUND',\n  'NOT_ALLOWED',\n  'NOT_ALLOWED_TARGET_ENVIRONMENT',\n  'INVALID_CALLBACK_URL_HOST',\n  'INVALID_CURRENCY',\n  'SERVICE_UNAVAILABLE',\n  'INTERNAL_PROCESSING_ERROR',\n  'NOT_ENOUGH_FUNDS',\n  'PAYER_LIMIT_REACHED',\n  'PAYEE_NOT_ALLOWED_TO_RECEIVE',\n  'PAYMENT_NOT_APPROVED',\n  'RESOURCE_NOT_FOUND',\n  'APPROVAL_REJECTED',\n  'EXPIRED',\n  'TRANSACTION_CANCELED',\n  'RESOURCE_ALREADY_EXIST',\n] as const;\n\ntype TransactionStatusReasonCode =\n  (typeof TransactionStatusReasonCodes)[number];\n\ntype TransactionStatus =\n  | 'PENDING'\n  | 'SUCCESSFUL'\n  | 'FAILED'\n  | 'TIMEOUT'\n  | 'REJECTED';\n\ntype Transaction<TargetProduct extends Product> = {\n  /** Amount that will be debited from the payer account */\n  amount: number;\n\n  /** ISO4217 Currency */\n  currency: string;\n\n  /** Financial transactionId from a mobile money manager. Used to connect to the specific financial transaction made in the account */\n  financialTransactionId: string;\n\n  /**\n   * External id is used as a reference to the transaction. External id is used for reconciliation.\n   * The external id will be included in transaction history report.\n   * External id is not required to be unique.\n   */\n  externalId: string;\n\n  /**  */\n  status: TransactionStatus;\n  reason?: {\n    code: TransactionStatusReasonCode;\n    message: string;\n  };\n\n  /** Message that will be written in the payer transaction history message field. */\n  payerMessage?: string;\n\n  /** Message that will be written in the payee transaction history note field. */\n  payeeNote?: string;\n} & TransactionParty<TargetProduct>;\n\ntype CreateTransactionStatusFetcherOptions<T extends Product> = {\n  /**\n   * The client to use when fetching the payment status.\n   * Its different for different product endpoint and different for different versions of the same product endpoints\n   */\n  client: AxiosInstance;\n\n  /** The target product */\n  targetProduct: T;\n};\n\ntype TransactionStatusFetcherOptions = {\n  /**\n   * UUID of transaction to get result.\n   *  Reference id used when creating the request to pay for a collection or the transfer for disbursement and remittance.\n   */\n  referenceId: string;\n};\n\ntype FetchTransactionStatus<T extends Product> = (\n  options: TransactionStatusFetcherOptions\n) => Promise<Transaction<T>>;\n\ntype CreateTransactionStatusFetcher = <T extends Product>(\n  options: CreateTransactionStatusFetcherOptions<T>\n) => FetchTransactionStatus<T>;\n\nconst createTransactionStatusFetcher: CreateTransactionStatusFetcher =\n  ({ client, targetProduct }) =>\n  async ({ referenceId }) => {\n    const path = urlPathFrom([\n      TRANSACTION_URL_PATHS[targetProduct],\n      referenceId,\n    ]);\n    const response = await client.get(path);\n    return response.data;\n  };\n\nexport { createTransactionStatusFetcher };\nexport type { FetchTransactionStatus };\n","import { Product } from '../../types';\n\nenum PartyIDVariant {\n  MSISDN = 'MSISDN',\n  EMAIL = 'EMAIL',\n  PARTY_CODE = 'PARTY_CODE',\n}\n\ntype Party = {\n  /**\n   * The type of the party ID indicating how the partyId is validated. Can be one of:\n   * - EMAIL - Validated to be a valid e-mail format. Validated with IsEmail\n   * - MSISDN - Mobile Number validated according to ITU-T E.164. Validated with IsMSISDN\n   * - PARTY_CODE - UUID of the party. Validated with IsUuid\n   */\n  partyIdType: PartyIDVariant;\n\n  /** The id of the party. Should be of the party Id type i.e if partyId type is MSISDN, partyId should be a MSISDN */\n  partyId: string;\n};\n\ntype TransactionParty<TargetProduct extends Product> =\n  TargetProduct extends Product.Collection\n    ? {\n        /** The paying party in the wallet platform */\n        payer: Party;\n      }\n    : {\n        /** The party being paid in the wallet platform */\n        payee: Party;\n      };\n\nexport type { Party };\nexport { PartyIDVariant, TransactionParty };\n","import { TargetEnvironment } from '../types';\nimport { createProvisioningClient } from './client';\nimport { createAPIKey } from './createAPIKey';\nimport { createAPIUser } from './createAPIUser';\nimport { fetchAPIUser } from './fetchAPIUser';\n\ntype CreateAPIUserResult = {\n  /** The environment which we are accessing. Its always 'sandbox' when in the sandbox environment */\n  targetEnvironment: TargetEnvironment;\n\n  /** The key to be used in the authentication header when requesting for an access token */\n  apiKey: string;\n\n  /** A uuid which corresponds to the id of the user to be created */\n  userId: string;\n\n  /**\n   * The primary key for any of the subscriptions you want to access. Can be found in your momo developer profile under subscriptions\n   * Check out https://momodeveloper.mtn.com/products to subscribe to a product and obtain a subscription key\n   */\n  subscriptionKey: string;\n\n  /** The host to redirect to after some actions that require redirection */\n  providerCallbackHost: string;\n};\n\ntype CreateAPIUserAndKeyOptions = Pick<\n  CreateAPIUserResult,\n  'subscriptionKey' | 'providerCallbackHost'\n>;\n\nconst createAPIUserAndKey = async ({\n  subscriptionKey,\n  providerCallbackHost,\n}: CreateAPIUserAndKeyOptions): Promise<CreateAPIUserResult> => {\n  const client = createProvisioningClient({\n    subscriptionKey,\n  });\n  const { userId } = await createAPIUser({ client, providerCallbackHost });\n  const { apiKey } = await createAPIKey({ userId, client });\n  const { targetEnvironment } = await fetchAPIUser({\n    userId,\n    client,\n  });\n\n  return {\n    userId,\n    apiKey,\n    targetEnvironment,\n    subscriptionKey,\n    providerCallbackHost,\n  };\n};\n\nexport { createAPIUserAndKey };\n","import { Product } from '../types';\n\nimport { createProductClient } from './common/client';\nimport type { CreateProductClientOptions } from './common/client';\nimport { createAccountBalanceFetcher } from './common/createAccountBalanceFetcher';\nimport type { FetchAccountBalance } from './common/createAccountBalanceFetcher';\nimport { createBasicUserInfoFetcher } from './common/createGetBasicUserInfo';\nimport type { FetchBasicUserInfo } from './common/createGetBasicUserInfo';\nimport { createRequestToPayDeliveryNotification } from './common/createRequestToPayDeliveryNotification';\nimport type { RequestToPayDeliveryNotification } from './common/createRequestToPayDeliveryNotification';\nimport { createTransactionInitiator } from './common/createTransactionInitiator';\nimport type { InitiateTransaction } from './common/createTransactionInitiator';\nimport { createTransactionStatusFetcher } from './common/createTransactionStatusFetcher';\nimport type { FetchTransactionStatus } from './common/createTransactionStatusFetcher';\nimport { createValidateAccountHolderStatus } from './common/createValidateAccountHolderStatus';\nimport type { ValidateAccountHolderStatus } from './common/createValidateAccountHolderStatus';\n\ntype CreateCollectionAPIOptions = Omit<\n  CreateProductClientOptions,\n  'targetProduct'\n>;\n\ntype CreateCollectionAPIResult = {\n  /**\n   * This operation is used to request a payment from a consumer (Payer). The payer will be asked to authorize the payment.\n   * The transaction will be executed once the payer has authorized the payment.\n   * The requesttopay will be in status PENDING until the transaction is authorized or declined by the payer or it is timed out by the system.\n   * Status of the transaction can be validated by using the requestToPayTransactionStatus method\n   */\n  requestToPay: InitiateTransaction<Product.Collection>;\n\n  /**\n   * This operation is used to get the status of a request to pay\n   */\n  requestToPayTransactionStatus: FetchTransactionStatus<Product.Collection>;\n\n  /** Get the balance of the account */\n  getAccountBalance: FetchAccountBalance;\n\n  /** This operation returns personal information of the account holder. The operation does not need any consent by the account holder. */\n  getBasicUserInfo: FetchBasicUserInfo;\n\n  /** This operation is used to check if an account holder is registered and active in the system. */\n  validateAccountHolderStatus: ValidateAccountHolderStatus;\n\n  /** This operation is used to send additional Notification to an End User. */\n  requestToPayDeliveryNotification: RequestToPayDeliveryNotification;\n};\n\n/**\n * Creates methods to access the collections API\n * @param options Properties to use when creating functions to access the collections API\n * @returns {CreateCollectionAPIResult} Methods to access the collections API\n */\nconst createCollectionAPI = (\n  options: CreateCollectionAPIOptions\n): CreateCollectionAPIResult => {\n  const client = createProductClient({\n    ...options,\n    targetProduct: Product.Collection,\n  });\n\n  const requestToPay = createTransactionInitiator({\n    client,\n    targetProduct: Product.Collection,\n  });\n\n  const requestToPayTransactionStatus = createTransactionStatusFetcher({\n    client,\n    targetProduct: Product.Collection,\n  });\n\n  const getAccountBalance = createAccountBalanceFetcher({ client });\n\n  const getBasicUserInfo = createBasicUserInfoFetcher({ client });\n\n  const validateAccountHolderStatus = createValidateAccountHolderStatus({\n    client,\n  });\n\n  const requestToPayDeliveryNotification =\n    createRequestToPayDeliveryNotification({ client });\n\n  return {\n    requestToPay,\n    requestToPayTransactionStatus,\n    getAccountBalance,\n    getBasicUserInfo,\n    validateAccountHolderStatus,\n    requestToPayDeliveryNotification,\n  };\n};\n\nexport { createCollectionAPI };\n","import { Product } from '../types';\n\nimport { createProductClient } from './common/client';\nimport type { CreateProductClientOptions } from './common/client';\nimport { createAccountBalanceFetcher } from './common/createAccountBalanceFetcher';\nimport type { FetchAccountBalance } from './common/createAccountBalanceFetcher';\nimport { createBasicUserInfoFetcher } from './common/createGetBasicUserInfo';\nimport type { FetchBasicUserInfo } from './common/createGetBasicUserInfo';\nimport { createRequestToPayDeliveryNotification } from './common/createRequestToPayDeliveryNotification';\nimport type { RequestToPayDeliveryNotification } from './common/createRequestToPayDeliveryNotification';\nimport { createTransactionInitiator } from './common/createTransactionInitiator';\nimport type { InitiateTransaction } from './common/createTransactionInitiator';\nimport { createTransactionStatusFetcher } from './common/createTransactionStatusFetcher';\nimport type { FetchTransactionStatus } from './common/createTransactionStatusFetcher';\nimport { createValidateAccountHolderStatus } from './common/createValidateAccountHolderStatus';\nimport type { ValidateAccountHolderStatus } from './common/createValidateAccountHolderStatus';\n\ntype CreateDisbursementAPIResult = {\n  /**\n   * Transfer operation is used to transfer an amount from the own account to a payee account.\n   */\n  transfer: InitiateTransaction<Product.Disbursement>;\n\n  /**\n   * This operation is used to get the status of a transfer.\n   */\n  getTransferStatus: FetchTransactionStatus<Product.Disbursement>;\n\n  /** Get the balance of the account */\n  getAccountBalance: FetchAccountBalance;\n\n  /** This operation returns personal information of the account holder. The operation does not need any consent by the account holder. */\n  getBasicUserInfo: FetchBasicUserInfo;\n\n  /** This operation is used to check if an account holder is registered and active in the system. */\n  validateAccountHolderStatus: ValidateAccountHolderStatus;\n\n  /** This operation is used to send additional Notification to an End User. */\n  requestToPayDeliveryNotification: RequestToPayDeliveryNotification;\n};\n\ntype CreateDisbursementAPIOptions = Omit<\n  CreateProductClientOptions,\n  'targetProduct'\n>;\n\nconst createDisbursementAPI = (\n  options: CreateDisbursementAPIOptions\n): CreateDisbursementAPIResult => {\n  const client = createProductClient({\n    ...options,\n    targetProduct: Product.Disbursement,\n  });\n\n  const transfer = createTransactionInitiator({\n    client,\n    targetProduct: Product.Disbursement,\n  });\n\n  const getTransferStatus = createTransactionStatusFetcher({\n    client,\n    targetProduct: Product.Disbursement,\n  });\n\n  const getAccountBalance = createAccountBalanceFetcher({ client });\n\n  const getBasicUserInfo = createBasicUserInfoFetcher({ client });\n\n  const validateAccountHolderStatus = createValidateAccountHolderStatus({\n    client,\n  });\n\n  const requestToPayDeliveryNotification =\n    createRequestToPayDeliveryNotification({ client });\n\n  return {\n    transfer,\n    getTransferStatus,\n    getAccountBalance,\n    getBasicUserInfo,\n    validateAccountHolderStatus,\n    requestToPayDeliveryNotification,\n  };\n};\n\nexport { createDisbursementAPI };\n","import { Product } from '../types';\n\nimport { createProductClient } from './common/client';\nimport type { CreateProductClientOptions } from './common/client';\nimport { createAccountBalanceFetcher } from './common/createAccountBalanceFetcher';\nimport type { FetchAccountBalance } from './common/createAccountBalanceFetcher';\nimport { createBasicUserInfoFetcher } from './common/createGetBasicUserInfo';\nimport type { FetchBasicUserInfo } from './common/createGetBasicUserInfo';\nimport { createRequestToPayDeliveryNotification } from './common/createRequestToPayDeliveryNotification';\nimport type { RequestToPayDeliveryNotification } from './common/createRequestToPayDeliveryNotification';\nimport { createTransactionInitiator } from './common/createTransactionInitiator';\nimport type { InitiateTransaction } from './common/createTransactionInitiator';\nimport { createTransactionStatusFetcher } from './common/createTransactionStatusFetcher';\nimport type { FetchTransactionStatus } from './common/createTransactionStatusFetcher';\nimport { createValidateAccountHolderStatus } from './common/createValidateAccountHolderStatus';\nimport type { ValidateAccountHolderStatus } from './common/createValidateAccountHolderStatus';\n\ntype CreateRemittanceAPIOptions = Omit<\n  CreateProductClientOptions,\n  'targetProduct'\n>;\n\ntype CreateRemittanceAPIResult = {\n  /**\n   * Transfer operation is used to transfer an amount from the own account to a payee account.\n   */\n  transfer: InitiateTransaction<Product.Remittance>;\n\n  /**\n   * This operation is used to get the status of a transfer.\n   */\n  getTransferStatus: FetchTransactionStatus<Product.Remittance>;\n\n  /** Get the balance of the account */\n  getAccountBalance: FetchAccountBalance;\n\n  /** This operation returns personal information of the account holder. The operation does not need any consent by the account holder. */\n  getBasicUserInfo: FetchBasicUserInfo;\n\n  /** This operation is used to check if an account holder is registered and active in the system. */\n  validateAccountHolderStatus: ValidateAccountHolderStatus;\n\n  /** This operation is used to send additional Notification to an End User. */\n  requestToPayDeliveryNotification: RequestToPayDeliveryNotification;\n};\n\nconst createRemittanceAPI = (\n  options: CreateRemittanceAPIOptions\n): CreateRemittanceAPIResult => {\n  const client = createProductClient({\n    ...options,\n    targetProduct: Product.Remittance,\n  });\n\n  const transfer = createTransactionInitiator({\n    client,\n    targetProduct: Product.Remittance,\n  });\n\n  const getTransferStatus = createTransactionStatusFetcher({\n    client,\n    targetProduct: Product.Remittance,\n  });\n\n  const getAccountBalance = createAccountBalanceFetcher({ client });\n\n  const getBasicUserInfo = createBasicUserInfoFetcher({ client });\n\n  const validateAccountHolderStatus = createValidateAccountHolderStatus({\n    client,\n  });\n\n  const requestToPayDeliveryNotification =\n    createRequestToPayDeliveryNotification({ client });\n\n  return {\n    transfer,\n    getTransferStatus,\n    getAccountBalance,\n    getBasicUserInfo,\n    validateAccountHolderStatus,\n    requestToPayDeliveryNotification,\n  };\n};\n\nexport { createRemittanceAPI };\n"],"names":["TargetEnvironment","Product","API_VERSION_PATH","v1","v2","urlPathFrom","paths","path","join","apply","BASE_URL","createClient","_ref","_ref$baseURL","baseURL","axios","create","headers","_extends","subscriptionKey","headerOverrides","createProvisioningClient","_ref$apiVersion","apiVersion","fetchAPIUser","userId","client","Promise","resolve","get","then","_ref2","data","e","reject","createAPIUser","providerCallbackHost","v4","post","createAPIKey","clientCache","expiresInToExpiresAt","expiresIn","Date","now","createAccessToken","options","targetEnvironment","targetProduct","authToken","Buffer","from","apiKey","toString","Authorization","createTokenClient","expiresAt","expires_in","accessToken","access_token","tokenType","token_type","AccountHolderIdVariant","tokenCache","createProductClient","clientKey","config","interceptors","request","use","_tokenDetails","tokenDetails","isExpired","_temp","_createAccessToken","createOrRefreshAccessToken","withAuthorization","createAccountBalanceFetcher","createBasicUserInfoFetcher","accountHolderMSISDN","_ref3","sub","status","gender","name","locale","birthDate","birthdate","givenName","given_name","familyName","family_name","updatedAt","updated_at","createRequestToPayDeliveryNotification","referenceId","notificationMessage","Language","language","TRANSACTION_URL_PATHS","collection","disbursement","remittance","createTransactionInitiator","callbackURL","body","_objectWithoutPropertiesLoose","_excluded","createTransactionStatusFetcher","response","PartyIDVariant","createValidateAccountHolderStatus","accountHolderIdType","accountHolderId","result","_ref4","Collection","requestToPay","requestToPayTransactionStatus","getAccountBalance","getBasicUserInfo","validateAccountHolderStatus","requestToPayDeliveryNotification","Disbursement","transfer","getTransferStatus","Remittance"],"mappings":"mZAKA,ICLKA,EAKAC,EDMCC,EAA+C,CACnDC,GALc,OAMdC,GARc,QAWVC,EAAc,SAACC,GAAe,OAAaC,EAAI,QAACC,KAAIC,MAATF,EAAI,QAASD,EAAM,EAE9DI,EAAW,yCAeXC,EAAe,SAAHC,GAAA,IACDC,EAAAD,EACfE,QAAAA,OAAUJ,IAAHG,EAAGH,EAAQG,EAGlB,OAAAE,EAAAA,QAAMC,OAAO,CACXC,QAAOC,EAAA,CACL,eAAgB,mBAChB,4BAPWN,EAAfO,iBAEeP,EAAfQ,iBAQEN,QAAAA,GACA,EEjBEO,EAA2B,SAAHT,GAC5B,IAAAO,EAAeP,EAAfO,gBAAeG,EAAAV,EACfW,WAIMT,EACJJ,EAAWL,EAAY,CAACH,WALhBoB,EAAG,KAAIA,GAKuC,YAExD,OAAOX,EAAa,CAAEQ,gBAAAA,EAAiBL,QAAAA,GACzC,ECdMU,EAAY,SAAAZ,GAChB,IAAAa,EAAMb,EAANa,OACAC,EAAMd,EAANc,OAAM,IAC+CC,OAAAA,QAAAC,QAC9BF,EAAOG,IAA4BJ,IAAAA,IAASK,KAAA,SAAAC,GAEnE,OAFYA,EAAJC,IAEI,EACd,CAAC,MAAAC,GAAAN,OAAAA,QAAAO,OAAAD,EAED,CAAA,ECZME,EAAa,SAAAvB,GAAA,IACjBc,EAAMd,EAANc,OACAU,EAAoBxB,EAApBwB,qBACuD,IACvD,IAAMX,EAASY,EAAAA,KAAK,OAAAV,QAAAC,QAEdF,EAAOY,KACX,GACA,CAAEF,qBAAAA,GACF,CAAEnB,QAAS,CAAE,iBAAkBQ,MAChCK,KAAA,WAED,MAAO,CAAEL,OAAAA,EAAS,EACpB,CAAC,MA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