A payment cycle

Hierarchy (view full)

Constructors

Properties

accountingFrom: undefined | Date

The starting date of the accounting period of the payment cycle

accountingTo: undefined | Date

The ending date of the accounting period of the payment cycle

amount: undefined | Amount

The total amount of money that will be paid out by the payment cycle.

feeDirection: undefined | FeeDirection

A fee direction indicating who will pay the fees on a transaction.

default = Use the setting defined in the paying user's account settings

payer = The paying user also pays the fees

payee = The receiving user pays the fees

split = The payer and the receiver will split the fees equally

fees: undefined | Amount

The total amount of fees that will be paid on the payment cycle.

invoiceId: undefined | null | string

The ID of the invoice. This will only be present after the payment cycle has been finalized.

memo: undefined | null | string

The payer can specify a free-text string to help describe the reason for the payment

name: string

The name of the payment cycle

paymentCycleEntryCount: undefined | number

The number of payment cycle entries attached to the payment cycle.

paymentCycleId: string

The long ID of the payment cycle. This can be used to retrieve a payment cycle.

rawObject: PaymentCycle

The underlying raw object returned from the API

shortId: undefined | null | string

The short ID of the payment cycle. Use this for a human readable version of the Payment Cycle ID. This can also be used to retrieve a payment cycle.

status: undefined | PaymentCycleStatus

The current status of the payment cycle.

Methods

  • Adds a payment cycle entry to the current payment cycle. The payment cycle entry pays the given user the specified amount.

    Parameters

    • name: string

      The first and last name of the user to pay.

    • email: string

      The email address of the user to pay. If the user has not already joined Mozaic, they will be sent an email invite to join.

    • amount: number

      The amount of money to be paid to the user.

    • currency: string

      The currency that the amount will be paid in. Foreign exchange rates may apply to cross-boarder payments.

    Returns Promise<PaymentCycleEntry>

  • A helper function to ensure that API calls are successful and return a valid status code.

    Type Parameters

    • T

    Parameters

    • call: (() => Promise<AxiosResponse<T, any>>)

      The API call to guard for exceptions and bad return codes.

        • (): Promise<AxiosResponse<T, any>>
        • Returns Promise<AxiosResponse<T, any>>

    Returns Promise<T>

    A promise of the type returned by Axios in the data field.

  • Completes the payment cycle by withdrawing money from your specified wallet item and then distributing it to recipients on the payment cycle.

    Parameters

    • walletItem: WalletItem

      The source of funding for the payment cycle. This must be a Payment wallet item and not a Payout wallet item.

    Returns Promise<PaymentCycle>

  • Retrieves an invoice for this payment cycle. Note that an invoice is not generated for a payment cycle until it has been finalized.

    Returns Promise<ArrayBuffer>

    an ArrayBuffer containing the bytes of an Invoice PDF. It can be saved using:

    fs.writeFileSync(fileName, Buffer.from(arrayBuffer));

  • A helper function that will either return the variable's value or throw an exception if the value is null or undefined. Unit testing is simplified by avoiding ??

    Type Parameters

    • T

    Parameters

    • name: string

      The name of the variable being checked

    • value: undefined | null | T

      The value of the variable being checked

    Returns T

    The value of the variable if it is available, otherwise an exception is thrown.