UNPKG

@bebapps/rapyd-sdk

Version:

An un-official [Rapyd](https://rapyd.net) SDK for Node.js.

151 lines (149 loc) 5.41 kB
import { Discount } from './Discount'; import { InvoiceItem } from './InvoiceItem'; import { Payment } from './Payment'; export interface Invoice { /** * ID of the Invoice object. String starting with **invoice_**. */ id: `invoice_${string}`; /** * Number of payment attempts for this invoice. Integer. After the first attempt, only automatic attempts are included in this count. Response only. */ attempt_count: number; /** * Indicates whether an attempt has been made to pay the invoice automatically. Response only. */ attempted: boolean; /** * Determines the method of collection. Set to **pay_automatically** - Rapyd generates a 'payment' object, then attempts to pay it using the designated payment method. */ billing: string; /** * The reason for billing. One of the following: * * * **subscription_cycle** - A new cycle for the subscription. * * **subscription_create** - A new subscription has been created. * * **manual** - Customer was billed manually. * * **upcoming** - Customer has an upcoming billing invoice. */ billing_reason: 'subscription_cycle' | 'subscription_create' | 'manual' | 'upcoming'; /** * The time the invoice was created, in [*Unix time*](ref:glossary). Response only. */ created_at: number; /** * Three-letter ISO 4217 currency code for the currency used in all fields that refer to a monetary amount. Required when the `subscription` field is not provided. If `subscription` field is provided, then the currency defined in the subscription's plan is used. */ currency: string; /** * ID of the customer that pays this invoice. String starting with **cus_**. * * For more information, see [Customer Object](ref:customer-object). */ customer: `cus_${string}`; /** * Number of days the customer has for paying this invoice. Integer. Relevant when `billing` is **send_invoice**. * Default value is 30 days. */ days_until_due: number; /** * Description of the invoice. */ description: string; /** * Describes the discount that applies to this invoice. The source of the discount is one of the following: * - If the invoice is generated manually, the discount is taken from the Customer object. * - If the invoice is generated automatically from a subscription, the discount is taken from the Subscription object if it is defined there, otherwise it is taken from the Customer object. * * For more information, see [Discount Object](ref:discount-object). */ discount: Partial<Discount>; /** * The date payment is due on this invoice. This value is calculated from the date the invoice is created, plus the number of days specified in the `days_until_due` field. Relevant when `billing` is **send_invoice**. * Format is in [*Unix time*](ref:glossary). */ due_date: number; /** * The individual line items that make up the invoice. These items are added with [Create Invoice](ref:create-invoice) or [Update Invoice](ref:update-invoice). * * For more information, see [Invoice Item Object](ref:invoice-item-object). */ lines: (Partial<InvoiceItem>)[]; /** * A JSON object defined by the client. */ metadata: object; /** * The time at which payment will next be attempted, in [*Unix time*](ref:glossary). Relevant when `billing` is **pay_automatically**. */ next_payment_attempt: number; /** * Invoice number, starting with the `invoice_prefix` specified in the Customer object. Response only. */ number: string; /** * ID of the Payment object that was generated for this invoice. Response only. */ payment: string; /** * Payment fields of `payment` object. For more information, see [Payment Object](ref:payment-object) */ payment_fields: Partial<Payment>; /** * Payment method for the invoice. If not provided then payment method is taken from the subscription. If payment method is not provided in the subscription, then payment method is taken from the customer's default payment method. */ payment_method: string; /** * Reserved. */ payout: string; /** * Reserved. */ payout_fields: object; /** * Last date in the period covered by the invoice. Response only. */ period_end: string; /** * First date in the period covered by the invoice. Response only. */ period_start: string; /** * Description of the invoice for the customer's credit card statement. Limited to 22 characters. */ statement_descriptor: string; /** * An invoice moves through a series of statuses. See status table below. */ status: string; /** * ID of the subscription that generates charges to this customer. */ subscription: string; /** * Total of all line items before discount and before tax. Decimal. Response only. */ subtotal: number; /** * The amount of tax charged. Decimal. * * This is calculated as * **T = R x (S - D)**, where: * * **T** is the tax. * * **R** is the tax rate in `tax_percent`. * * **S** is the subtotal. * * **D** is the discount. */ tax: number; /** * The percentage tax rate that is applied to the subtotal of the invoice, after subtracting all discounts. Decimal, up to four decimal places. * * Range: 0-100 */ tax_percent: number; /** * Total after discount and tax. Decimal. */ total: number; };