UNPKG

modem-pay

Version:

A TypeScript SDK for integrating with the Modem Pay payment gateway, enabling seamless payment processing and financial services in your applications.

169 lines (168 loc) 5.13 kB
import { PaymentGateway, PaymentMethodType } from "./"; import { Customer } from "./customers"; /** * Parameters for creating a payment intent. */ export type PaymentIntentParams = { /** * The amount to be charged for the payment intent. */ amount: number; /** * The currency in which the payment will be processed (e.g., "XOF", "GMD"). */ currency?: string; /** * An array of payment method types to be used for processing the payment (e.g., "card", "bank", "wallet"). */ payment_methods?: PaymentMethodType[]; /** * Title or name of the payment intent. It provides a label or description for the payment. */ title?: string; /** * Detailed description of the payment intent. */ description?: string; /** * The customer associated with the payment intent. Can be a customer ID. */ customer?: string; /** * The name of the customer associated with the payment intent. */ customer_name?: string; /** * The email address of the customer associated with the payment intent. */ customer_email?: string; /** * The phone number of the customer associated with the payment intent. */ customer_phone?: string; /** * Custom metadata associated with the payment intent. */ metadata?: object; /** * URL to redirect the customer after successful payment. */ return_url?: string; /** * URL to redirect the customer if the payment is cancelled. */ cancel_url?: string; /** * The payment method ID selected for processing the payment. */ payment_method?: string; /** * The ID of the coupon code to be applied to the payment intent for discounts or special offers. */ coupon?: string; /** * The URL to which Modem Pay will send a callback or webhook notification after payment processing. */ callback_url?: string; /** * The payment network to be used for the payment intent (e.g., "wave", "afrimoney", etc.). */ network?: string; /** * The account number associated with the payment. */ account_number?: string; /** * The sub-account ID specifying who to split the payment with. */ sub_account?: string; /** * If true, skips validation of the provided URLs in the payment intent creation or update process. */ skip_url_validation?: boolean; }; /** * Representation of a payment intent. */ export interface PaymentIntent extends PaymentIntentParams { /** * Unique identifier for the payment intent. */ id: string; /** * The available payment gateway options for the payment method. */ payment_method_options: PaymentGateway[]; /** * Customer associated with the payment intent. */ Customer?: Customer; /** * Secret key used to authenticate the payment intent. */ intent_secret: string; /** * The current status of the payment intent. Possible values include: * "initialized", "processing", "requires_payment_method", "successful", "failed", and "cancelled". */ status: "initialized" | "processing" | "requires_payment_method" | "successful" | "failed" | "cancelled"; /** * URL link to the payment intent, typically used for redirecting the customer. */ link: string; /** * Custom values associated with the fields of the payment intent. */ custom_fields_values: object; /** * Indicates if the payment intent is part of a session. */ is_session: boolean; } /** * Represents the structure of the response returned after creating a payment intent. */ export type PaymentIntentResponse = { /** * Indicates whether the payment intent creation was successful. * `true` means success, `false` would indicate an error or failure. */ status: boolean; /** * A message providing additional details about the result of the payment intent creation. */ message: string; /** * The data associated with the created payment intent. */ data: { /** * Unique identifier for the payment intent. */ id: string; /** * The secret key for the payment intent used to complete the payment. (Not your API secret key) */ intent_secret: string; /** * The payment link that allows the customer to complete the payment. */ payment_link: string; /** * The amount involved in the payment intent (in the smallest unit of the currency). */ amount: number; /** * The currency used for the payment intent (e.g., "GMD", "XOF"). */ currency: string; /** * The expiration time for the payment intent. The user must complete the payment before this time. */ expires_at: string; /** * The current status of the payment intent (e.g., "initialized", "processing", etc.). */ status: string; }; };