Skip to main content

modules

@littleapp/little-pay-api / Exports

@littleapp/little-pay-api

Table of contents

Classes

Interfaces

Type Aliases

Functions

Type Aliases

BillingAddress

Ƭ BillingAddress: Object

Type declaration

NameTypeDescription
address1stringThe primary address line for the billing address.
administrativeAreastringThe administrative area/state for the billing address.
countrystringThe country for the billing address.
emailstringThe email address for the person associated with the billing address.
firstNamestringThe first name of the person associated with the billing address.
lastNamestringThe last name of the person associated with the billing address.
localitystringThe locality/city for the billing address.
phoneNumberstringThe phone number for the person associated with the billing address.
postalCodestringThe postal code for the billing address.

CardDetails

Ƭ CardDetails: Object

Type declaration

NameType
cc_cvvstring
cc_expstring
cc_namestring
cc_numberstring

CreateIntentParams

Ƭ CreateIntentParams: Object

Parameters for creating an intent.

Type declaration

NameTypeDescription
amountnumberThe amount to be paid.
callbackUrlstringA URL to post the results of the payment to. The payload format can be found at https://pay.little.africa/documentation/docs/intro/
currencystringThe currency to be used for the payment. Must be a valid ISO 4217 currency code https://en.wikipedia.org/wiki/ISO_4217. Example: "KES". Currencies are enabled and disabled in the LittlePay dashboard. https://pay.little.africa/
descriptionstringA description of the payment.
expiresAt?numberThe time at which the intent will expire. Must be a Unix timestamp.
keystringA unique key for the intent.
metadata?ProcessorPayload\<any>The metadata for the intent.
payload{ billingAddress: BillingAddress }The payload for the intent. This is used to pass billing information and any other required data.
payload.billingAddressBillingAddressThe billing address for the intent.
returnUrl?stringIf you use the intent checkout page, the user will be redirected to this URL after the payment is completed. If you are not using the intent checkout page but there was a 3DS challenge, the user will be redirected to this URL after the 3DS challenge is completed.

DeviceDetails

Ƭ DeviceDetails: Object

Device details collected from a browser.

Type declaration

NameType
httpBrowserColorDepthnumber
httpBrowserJavaEnabledboolean
httpBrowserJavaScriptEnabledboolean
httpBrowserLanguagestring
httpBrowserScreenHeightnumber
httpBrowserScreenWidthnumber
httpBrowserTimeDifferencenumber

ErrorCode

Ƭ ErrorCode: "INVALID_REQUEST" | "SERVER_ERROR" | "NETWORK_ERROR" | "PAYMENT_FAILED" | "INVALID_DATA" | "UNKNOWN_ERROR"

Possible error codes


LittlePayClientConstructorParams

Ƭ LittlePayClientConstructorParams: Object

Parameters for constructing a LittlePayClient instance. All values are available in the LittlePay dashboard.

https://pay.little.africa/

Type declaration

NameTypeDescription
clientIdstringThe client ID for the LittlePay API.
clientSecretstringThe client secret for the LittlePay API.
tokenIdstringThe token ID for the LittlePay API.

MobilePayload

Ƭ MobilePayload: Object

Type declaration

NameType
mobilestring

PaToken

Ƭ PaToken: Object

Access token and device data collection URL for collecting device details.

Type declaration

NameType
accessTokenstring
deviceDataCollectionUrlstring
referenceIdstring
tokenstring

Payload

Ƭ Payload\<T>: T extends "MPESA" | "MTN" | "AIRTEL" ? MobilePayload : T extends "CARDS" ? CardDetails : never

Details required by the payment provider

Type parameters

NameTypeDescription
Textends PaymentProviderThe payment provider type

PaymentProcessorOptions

Ƭ PaymentProcessorOptions: Object

Type declaration

NameTypeDescription
longPoll?boolean-
stepUpHandler?(url: string, token: string) => any-
stepUpTarget?stringWhere to display the step up page Default ts "_blank"

PaymentProvider

Ƭ PaymentProvider: "MPESA" | "CARDS" | "MTN" | "AIRTEL"


PaymentStatus

Ƭ PaymentStatus: "COMPLETED" | "PENDING" | "FAILED"

The possible payment statuses for a processed payment.


ProcessPaymentResponse

Ƭ ProcessPaymentResponse: Object

Type declaration

NameType
messagestring
meta{ amount: number ; currency: string ; description: string ; provider: string ; providerReference: string ; reference: string }
meta.amountnumber
meta.currencystring
meta.descriptionstring
meta.providerstring
meta.providerReferencestring
meta.referencestring
statusPaymentStatus

Functions

cardValidation

cardValidation(field, value): Verification

Validates the given value based on the specified card field.

Parameters

NameTypeDescription
fieldkeyof CardDetailsThe card field to validate.
valuestringThe value to be validated.

Returns

Verification

  • The validation result.

Throws

LittlePayError If the card field is invalid.


paymentPayloadValidator

paymentPayloadValidator\<T>(payload): ProcessorPayload\<T>

Validates the payment payload based on the specified payment provider.

Type parameters

NameTypeDescription
Textends PaymentProviderThe type of the payment provider.

Parameters

NameTypeDescription
payloadProcessorPayload\<T>The payment payload to be validated.

Returns

ProcessorPayload\<T>

  • The validated payment payload.

Throws

LittlePayError If the payment payload is invalid.