modules
@littleapp/little-pay-api / Exports
@littleapp/little-pay-api
Table of contents
Classes
Interfaces
Type Aliases
- BillingAddress
- CardDetails
- CreateIntentParams
- DeviceDetails
- ErrorCode
- LittlePayClientConstructorParams
- MobilePayload
- PaToken
- Payload
- PaymentProcessorOptions
- PaymentProvider
- PaymentStatus
- ProcessPaymentResponse
Functions
Type Aliases
BillingAddress
Ƭ BillingAddress: Object
Type declaration
Name | Type | Description |
---|---|---|
address1 | string | The primary address line for the billing address. |
administrativeArea | string | The administrative area/state for the billing address. |
country | string | The country for the billing address. |
email | string | The email address for the person associated with the billing address. |
firstName | string | The first name of the person associated with the billing address. |
lastName | string | The last name of the person associated with the billing address. |
locality | string | The locality/city for the billing address. |
phoneNumber | string | The phone number for the person associated with the billing address. |
postalCode | string | The postal code for the billing address. |
CardDetails
Ƭ CardDetails: Object
Type declaration
Name | Type |
---|---|
cc_cvv | string |
cc_exp | string |
cc_name | string |
cc_number | string |
CreateIntentParams
Ƭ CreateIntentParams: Object
Parameters for creating an intent.
Type declaration
Name | Type | Description |
---|---|---|
amount | number | The amount to be paid. |
callbackUrl | string | A URL to post the results of the payment to. The payload format can be found at https://pay.little.africa/documentation/docs/intro/ |
currency | string | The 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/ |
description | string | A description of the payment. |
expiresAt? | number | The time at which the intent will expire. Must be a Unix timestamp. |
key | string | A 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.billingAddress | BillingAddress | The billing address for the intent. |
returnUrl? | string | If 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
Name | Type |
---|---|
httpBrowserColorDepth | number |
httpBrowserJavaEnabled | boolean |
httpBrowserJavaScriptEnabled | boolean |
httpBrowserLanguage | string |
httpBrowserScreenHeight | number |
httpBrowserScreenWidth | number |
httpBrowserTimeDifference | number |
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.
Type declaration
Name | Type | Description |
---|---|---|
clientId | string | The client ID for the LittlePay API. |
clientSecret | string | The client secret for the LittlePay API. |
tokenId | string | The token ID for the LittlePay API. |
MobilePayload
Ƭ MobilePayload: Object
Type declaration
Name | Type |
---|---|
mobile | string |
PaToken
Ƭ PaToken: Object
Access token and device data collection URL for collecting device details.
Type declaration
Name | Type |
---|---|
accessToken | string |
deviceDataCollectionUrl | string |
referenceId | string |
token | string |
Payload
Ƭ Payload\<T
>: T
extends "MPESA"
| "MTN"
| "AIRTEL"
? MobilePayload
: T
extends "CARDS"
? CardDetails
: never
Details required by the payment provider
Type parameters
Name | Type | Description |
---|---|---|
T | extends PaymentProvider | The payment provider type |
PaymentProcessorOptions
Ƭ PaymentProcessorOptions: Object
Type declaration
Name | Type | Description |
---|---|---|
longPoll? | boolean | - |
stepUpHandler? | (url : string , token : string ) => any | - |
stepUpTarget? | string | Where 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
Name | Type |
---|---|
message | string |
meta | { amount : number ; currency : string ; description : string ; provider : string ; providerReference : string ; reference : string } |
meta.amount | number |
meta.currency | string |
meta.description | string |
meta.provider | string |
meta.providerReference | string |
meta.reference | string |
status | PaymentStatus |
Functions
cardValidation
▸ cardValidation(field
, value
): Verification
Validates the given value based on the specified card field.
Parameters
Name | Type | Description |
---|---|---|
field | keyof CardDetails | The card field to validate. |
value | string | The 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
Name | Type | Description |
---|---|---|
T | extends PaymentProvider | The type of the payment provider. |
Parameters
Name | Type | Description |
---|---|---|
payload | ProcessorPayload \<T > | The payment payload to be validated. |
Returns
ProcessorPayload
\<T
>
- The validated payment payload.
Throws
LittlePayError If the payment payload is invalid.