Skip to content

Collections API

Collection (payin) operations — collect payments from customers. Access via payd.collections.

Methods

mpesa(params)

Collect a payment via Kenya M-Pesa STK Push.

Endpoint: POST /api/v2/payments

typescript
const result = await payd.collections.mpesa(params: MpesaCollectionParams): Promise<MpesaCollectionResponse>;

MpesaCollectionParams

FieldTypeRequiredDescription
usernamestringYes*Payd account username
amountnumberYesAmount in KES (10 – 250,000)
phoneNumberstringYesKenyan phone: 0XXXXXXXXX or +254XXXXXXXXX
narrationstringYesDescription shown to customer
callbackUrlstringYes*Webhook URL

MpesaCollectionResponse

FieldTypeDescription
successbooleanWhether STK push was initiated
messagestringAPI message
statusstringStatus string
paymentMethodstring"MPESA"
transactionReferencestringUnique transaction reference
trackingIdstringTracking identifier
referencestringAdditional reference
resultunknownAdditional result data
_rawRecord<string, unknown>Raw API response

card(params)

Accept a card payment via hosted checkout.

Endpoint: POST /api/v2/payments

typescript
const result = await payd.collections.card(params: CardCollectionParams): Promise<CardCollectionResponse>;

CardCollectionParams

FieldTypeRequiredDescription
usernamestringYes*Payd account username
amountnumberYesAmount in KES (min 100)
phoneNumberstringYesKenyan phone: 0XXXXXXXXX or +254XXXXXXXXX
narrationstringYesPayment description
callbackUrlstringYes*Webhook URL

CardCollectionResponse

FieldTypeDescription
successbooleanWhether checkout was created
messagestringAPI message
statusstringStatus string
paymentMethodstring"card"
checkoutUrlstringHosted checkout URL — redirect customer here
transactionReferencestringUnique transaction reference
trackingIdstringTracking identifier
referencestringAdditional reference
resultunknownAdditional result data
_rawRecord<string, unknown>Raw API response

Throws: PaydAPIError if the response does not contain a checkoutUrl.


panAfrican(params)

Collect via Pan-African mobile money or bank transfer.

Endpoint: POST /api/v3/payments

typescript
const result = await payd.collections.panAfrican(params: PanAfricanCollectionParams): Promise<PanAfricanCollectionResponse>;

PanAfricanCollectionParams

FieldTypeRequiredDescription
usernamestringYes*Payd account username
accountName"bank" | "phone"YesAccount type
amountnumberYesAmount in target currency (> 0)
phoneNumberstringYesPhone with country code (+XXXXXXXXX)
accountNumberstringYesMobile money or bank account number
networkCodestringYesFrom network discovery
channelIdstringYesFrom network discovery
narrationstringYesPayment description
currencystringYesISO currency code (e.g., NGN)
callbackUrlstringYes*Webhook URL
transactionChannel"bank" | "phone"YesMust match network type
redirectUrlstringNoPost-checkout redirect URL

PanAfricanCollectionResponse

FieldTypeDescription
successbooleanWhether request was accepted
messagestringAPI message
statusstringStatus string
paymentMethodstringPayment method used
transactionReferencestringUnique transaction reference
bankAccountBankAccount | undefinedBank details (for bank transfers)
checkoutUrlstring | undefinedHosted checkout URL (some countries)
trackingIdstringTracking identifier
referencestringAdditional reference
resultunknownAdditional result data
_rawRecord<string, unknown>Raw API response

BankAccount

FieldTypeDescription
namestringBank name
branchCodestringBranch code
accountNumberstringAccount number
accountNamestringAccount holder name
accountReferencestringPayment reference

*Fields marked with * fall back to client defaults if empty. See Configuration.

Released under the MIT License.