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
Name | Type | Description |
---|---|---|
params | LittlePayClientConstructorParams | The parameters for constructing the LittlePayClient. |
Returns
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
Name | Type | Description |
---|---|---|
params | CreateIntentParams | The 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
Name | Type |
---|---|
T | extends PaymentProvider |
Parameters
Name | Type | Description |
---|---|---|
payload | ProcessorPayload \<T > | The payload for the payment processor. |
reference | string | The 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
Name | Type | Description |
---|---|---|
options? | PaymentProcessorOptions | Optional 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
Name | Type |
---|---|
T | extends PaymentProvider |
Parameters
Name | Type | Description |
---|---|---|
intent | Intent | The intent to validate details for. |
paymentProcessor | PaymentProcessor \<T > | The payment processor to use for validation. |
Returns
Promise
\<void
>