import { AxiosError } from 'axios'; declare type SecretKey = `sk_${string}`; declare type PublicKey = `pk_${string}`; declare type SecretOrPublicKey = SecretKey | PublicKey; declare type IsSecretKey = Key extends SecretKey ? true : false; declare type IsPublicKey = Key extends PublicKey ? true : false; declare type MetadataType = Record | undefined; declare type Currency = 'PHP'; declare type ErrorSubCode = 'card_expired' | 'cvc_invalid' | 'generic_decline' | 'fraudulent' | 'insufficient_funds' | 'processor_blocked' | 'lost_card' | 'stolen_card' | 'processor_unavailable' | 'blocked'; interface ErrorShape { code: string; detail: string; source?: { pointer: string; attribute: string; }; sub_code?: ErrorSubCode; } interface PaymongoError { errors: ErrorShape[]; } declare type PaymongoRequestError = AxiosError; interface Billing { address?: { city?: string; country?: string; line1?: string; line2?: string; postal_code?: string; state?: string; }; email?: string; name?: string; phone?: string; } declare type SourceStatus = 'pending' | 'chargeable' | 'cancelled' | 'expired' | 'paid'; declare type SourceType = 'gcash' | 'grab_pay'; interface SourceRedirect { checkout_url: string; success: string; failed: string; } interface SourceResource { id: string; type: 'source'; attributes: { amount: number; billing?: Billing; currency: Currency; livemode: boolean; redirect: SourceRedirect; status: SourceStatus; type: SourceType; created_at: number; updated_at: number; }; } interface CreateSourceParams { data: { attributes: { type: SourceType; amount: number; currency: Currency; redirect: Omit; billing?: Billing; }; }; } interface RetrieveSourceParams { id: string; } declare type PaymentStatus = 'pending' | 'paid' | 'fail'; declare type PaymentSource = { id: string; type: 'card'; brand: string; country: string; last4: string; } | { id: string; type: SourceType; }; interface PaymentResource { id: string; type: 'payment'; attributes: { access_url?: string; amount: number; balance_transaction_id: string; billing?: Billing; currency: Currency; description?: string; disputed: boolean; external_reference_number?: string; failed_code?: ErrorSubCode; failed_message?: string; fee: number; foreign_fee: number; livemode: boolean; net_amount: number; origin: string; payment_intent_id?: string; payout?: number; source: PaymentSource; statement_descriptor: string; status: PaymentStatus; tax_amount?: number; refunds: any[]; taxes: any[]; available_at: number; created_at: number; paid_at: number; updated_at: number; }; } interface CreatePaymentParams { data: { attributes: { amount: number; description?: string; currency: Currency; statment_descriptor?: string; source: { id: string; type: 'source'; }; }; }; } interface ListAllPaymentsParams { before?: string; after?: string; limit?: string; } interface RetrievePaymentParams { id: string; } declare type PaymentIntentStatus = 'awaiting_payment_method' | 'awaiting_next_action' | 'processing' | 'succeeded'; interface LastPaymentError { payment: string; failed_code: ErrorSubCode; failed_message: string; payment_method: string; } interface NextAction { type: 'redirect'; redirect: { url: string; return_url: string; }; } interface PaymentMethodOptions { card: { request_three_d_secure: 'any' | 'automatic'; }; } interface PaymentIntentResource { id: string; type: 'payment_intent'; attributes: { amount: number; currency: Currency; description?: string; statement_descriptor: string; status: PaymentIntentStatus; livemode: boolean; client_key: string; last_payment_error?: LastPaymentError; next_action?: NextAction; payment_method_allowed: ['card']; payments: PaymentResource[]; payment_method_options: PaymentMethodOptions; metadata: Metadata; }; } interface CreatePaymentIntentParams { data: { attributes: { amount: number; payment_method_allowed: ['card']; payment_method_options?: PaymentMethodOptions; description?: string; statement_descriptor?: string; currency: Currency; metadata?: Metadata; }; }; } interface BaseRetrievePaymentIntentParams { id: string; client_key?: string; } interface RetrievePaymentIntentParamsUsingPublic extends BaseRetrievePaymentIntentParams { client_key: string; } declare type RetrievePaymentIntentParams = UsingPublic extends true ? RetrievePaymentIntentParamsUsingPublic : BaseRetrievePaymentIntentParams; interface BaseAttachPaymentIntentParams { id: string; data: { attributes: { payment_method: string; client_key?: string; return_url?: string; }; }; } interface AttachPaymentIntentParamsUsingPublic extends BaseAttachPaymentIntentParams { data: { attributes: { payment_method: string; client_key: string; return_url?: string; }; }; } declare type AttachPaymentIntentParams = UsingPublic extends true ? AttachPaymentIntentParamsUsingPublic : BaseAttachPaymentIntentParams; interface PaymentMethodResource { id: string; type: 'payment_method'; attributes: { livemode: boolean; type: 'card'; billing?: Billing; details: { last4: string; exp_month: number; exp_year: number; }; metadata: Metadata; }; } interface CreatePaymentMethodParams { data: { attributes: { type: 'card'; details: { card_number: string; exp_month: number; exp_year: number; cvc: string; }; billng?: Billing; metadata?: Metadata; }; }; } interface RetrievePaymentMethodParams { id: string; } declare class Paymongo { private _axiosInstance; private _isSecret; constructor(key: Key); private _getConfig; paymentMethod: { create: (data: CreatePaymentMethodParams) => Promise>; retrieve: (data: RetrievePaymentMethodParams) => Promise | undefined>>; }; paymentIntent: { create: (data: CreatePaymentIntentParams) => Promise>; retrieve: (data: RetrievePaymentIntentParams>) => Promise>; attach: (data: AttachPaymentIntentParams>) => Promise>; }; source: { create: (data: CreateSourceParams) => Promise; retrieve: (data: RetrieveSourceParams) => Promise; }; payment: { create: (data: CreatePaymentParams) => Promise; retrieve: (data: RetrievePaymentParams) => Promise; list: (data: ListAllPaymentsParams) => Promise; }; } export { AttachPaymentIntentParams, AttachPaymentIntentParamsUsingPublic, BaseAttachPaymentIntentParams, BaseRetrievePaymentIntentParams, Billing, CreatePaymentIntentParams, CreatePaymentMethodParams, CreatePaymentParams, CreateSourceParams, Currency, ErrorShape, ErrorSubCode, IsPublicKey, IsSecretKey, LastPaymentError, ListAllPaymentsParams, MetadataType, NextAction, PaymentIntentResource, PaymentIntentStatus, PaymentMethodOptions, PaymentMethodResource, PaymentResource, PaymentSource, PaymentStatus, PaymongoError, PaymongoRequestError, PublicKey, RetrievePaymentIntentParams, RetrievePaymentIntentParamsUsingPublic, RetrievePaymentMethodParams, RetrievePaymentParams, RetrieveSourceParams, SecretKey, SecretOrPublicKey, SourceRedirect, SourceResource, SourceStatus, SourceType, Paymongo as default };