Skip to main content

LittlePayClient

@littleapp/little-pay-api / Exports / LittlePayClient

Class: LittlePayClient

Used to interact with the LittlePay API.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new LittlePayClient(params): LittlePayClient

Constructs a new instance of the LittlePayClient class.

Parameters

NameTypeDescription
paramsLittlePayClientConstructorParamsThe parameters for constructing the LittlePayClient.

Returns

LittlePayClient

Properties

clientId

Private clientId: string


clientSecret

Private clientSecret: string


deviceDetails

Private Optional deviceDetails: DeviceDetails


intent

Private Optional intent: Intent


paymentProcessor

Private Optional paymentProcessor: PaymentProcessor\<any>


tokenId

Private tokenId: string


validated

Private validated: boolean = false

Methods

createIntent

createIntent(params): Promise\<Intent>

Creates a new payment intent.

Parameters

NameTypeDescription
paramsCreateIntentParamsThe parameters for creating the intent.

Returns

Promise\<Intent>

  • A promise that resolves to the created intent.

createPaymentProcessor

createPaymentProcessor\<T>(payload, reference): PaymentProcessor\<T>

Creates a payment processor with the given payload and reference.

Type parameters

NameType
Textends PaymentProvider

Parameters

NameTypeDescription
payloadProcessorPayload\<T>The payload for the payment processor.
referencestringThe reference for the payment processor.

Returns

PaymentProcessor\<T>

  • A promise that resolves to the created PaymentProcessor instance.

processPayment

processPayment(options?): Promise\<ProcessPaymentResponse>

Processes a payment using the configured payment processor.

Parameters

NameTypeDescription
options?PaymentProcessorOptionsOptional payment processor options.

Returns

Promise\<ProcessPaymentResponse>

  • A promise that resolves to the processed payment response.

Throws

LittlePayError If the intent or payment processor is not set, or if the details are not validated.


validateDetails

validateDetails\<T>(intent, paymentProcessor): Promise\<void>

Validates the required details for a given intent and payment processor. Must be called before processing a payment.

Type parameters

NameType
Textends PaymentProvider

Parameters

NameTypeDescription
intentIntentThe intent to validate details for.
paymentProcessorPaymentProcessor\<T>The payment processor to use for validation.

Returns

Promise\<void>