Collection API
Base URL: https://api.nextgate.com/co.tz/api/v1
Short Description: The Payment MethodsCollection API enableshandles wallet top-up flows for NextGate users. It allows users to managedeposit money into their paymentNextGate instrumentswallet including credit/debit cards,via mobile money (M-Pesa,USSD Airtelpush) Money),or bank transfers, PayPal, cryptocurrencies, wallets, gift cards, and cash on delivery options. This API provides secure storage, retrieval, updating, and deletion ofcard payment methodsthrough withSelcom. built-inAll validationsubsequent andplatform duplicatepayments detection.(events, products) are made from the wallet balance.
Hints:
AllAlwaysendpointsproviderequireaauthenticationuniqueviaidempotencyKeyBearerpertokenrequestinto prevent duplicate charges- For USSD channels the
Authorizationuserheaderreceives a PIN prompt on their phone — poll/status/{id}to track completion SensitiveFordataCARD(cardchannelnumbers,theaccountresponsenumbers,containsPINs)aarepaymentUrl— redirect the user to complete payment- Selcom webhooks automatically
tokenized and masked in responses Only one payment method can be set as default at a time; setting a new default automatically unsetscredit thepreviouswalletoneon Paymentconfirmationmethods—supportnosoftmanualverificationstepstatus tracking (isVerified, isActive flags)The API uses ISO 8601 format for timestamps (YYYY-MM-DDTHH:mm:ss)Metadata fields accept custom JSON objects for storing gateway-specific informationDuplicate payment methods (same card number, email, phone number, etc.) are automatically detected and rejectedneeded
Standard Response Format
All API responses follow a consistent structure using our Globe Response Builder pattern:
Success Response Structure
{
"success": true,
"httpStatus": "OK",
"message": "Operation completed successfully",
"action_time": "2025-10-27T10:2026-03-06T10:30:45",
"data": {
// Actual response data goes here
}
}
Error Response Structure
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "Error description",
"action_time": "2025-10-27T10:2026-03-06T10:30:45",
"data": "Error description"
}
Standard Response Fields
| Field | Type | Description |
|---|---|---|
success |
boolean | true for false for errors |
httpStatus |
string | HTTP status name |
message |
string | Human-readable |
action_time |
string | ISO 8601 timestamp |
data |
object/string | Response payload |
HTTPFlow Method Badge StandardsDiagram
For
User
better|
visual|--- clarity,POST all endpoints use colored badges for HTTP methods with the following standard colors:
GET/collection/initiate --------> GETCollectionController
| (channel, amount, msisdn) |
| Validate request
| Check idempotency
| Save CollectionRequest (PENDING)
| |
| .----------------.
| | |
| USSD CARD
| | |
| Push USSD to Create Selcom
| Selcom API Checkout Order
| | |
| Status: AWAITING Status: AWAITING
| CUSTOMER_ACTION CUSTOMER_ACTION
| | |
|<-- Response (requestId) ------'----------------'
Green|
| [USSD: User enters PIN on phone]
| [CARD: User pays on paymentUrl ]
|
| Selcom Webhook ---------> /api/selcom/webhook
| (Safe,payment read-onlyconfirmed) operations) |
POST| creditWallet()
| Status: COMPLETED
|
|--- GET /collection/status/{id} -------> POSTStatus: COMPLETED
|<-- Blue{ (Createstatus, newtransactionRef, resources) ... PUT}
- PUT - Yellow (Update/replace entire resource)
PATCH - PATCH - Orange (Partial updates)
DELETE - DELETE - Red (Remove resources)
Available Enums
Payment Method Types
Use these exact values for the paymentMethodType field:
Enum Value
Description
Common Use Cases
CREDIT_CARD
Credit card payments
Visa, Mastercard, Amex, Discover
DEBIT_CARD
Debit card payments
Visa Debit, Mastercard Debit
PAYPAL
PayPal account payments
PayPal email-based payments
BANK_TRANSFER
Direct bank account transfers
ACH, Wire transfers, local bank payments
CRYPTOCURRENCY
Crypto wallet payments
Bitcoin, Ethereum, USDT, etc.
MOBILE_PAYMENT
Mobile payment services
Apple Pay, Google Pay, Samsung Pay
MNO_PAYMENT
Mobile Network Operator payments
M-Pesa, Airtel Money, Tigo Pesa
WALLET
Digital wallet services
Skrill, Neteller, PayTM
GIFT_CARD
Gift card payments
Store gift cards, prepaid cards
CASH_ON_DELIVERY
Cash payment upon delivery
COD orders
Mobile Network Operators (Tanzania)
Use these exact values for the mccMnc field when paymentMethodType is MNO_PAYMENT:
Enum Value
Operator Name
Network
M_PESA
M-Pesa
Vodacom Tanzania
AIRTEL_MONEY
Airtel Money
Airtel Tanzania
TIGO_PESA
Tigo Pesa
Tigo Tanzania
HALO_PESA
Halo Pesa
Halotel Tanzania
AZAM_PESA
Azam Pesa
Azam Telecom
EZY_PESA
Ezy Pesa
Zantel
Banks (Tanzania)
Use these exact values for the bankName field when paymentMethodType is BANK_TRANSFER:
Enum Value
Bank Name
CRDB_BANK
CRDB Bank PLC
NMB_BANK
National Microfinance Bank
EXIM_BANK
EXIM Bank Tanzania
KCB_BANK
Kenya Commercial Bank
NBC_BANK
National Bank of Commerce
STANBIC_BANK
Stanbic Bank Tanzania
DIAMOND_BANK
Diamond Trust Bank
ACCESS_BANK
Access Bank Tanzania
AZANIA_BANK
Azania Bank
EQUITY_BANK
Equity Bank Tanzania
FNB_BANK
First National Bank
Note: While these enum values are available, you can also use free-text bank names if your bank is not listed.
Card Types
Common values for the cardType field (free-text, not strictly enforced):
Value
Description
Visa
Visa credit/debit cards
Mastercard
Mastercard credit/debit cards
American Express
American Express cards
Discover
Discover cards
Diners Club
Diners Club cards
JCB
JCB cards
UnionPay
China UnionPay cards
Cryptocurrency Types
Common values for the cryptoType field (free-text, not strictly enforced):
Value
Description
Bitcoin
Bitcoin (BTC)
Ethereum
Ethereum (ETH)
Tether
Tether USDT
USD Coin
USDC stablecoin
Binance Coin
BNB
Cardano
ADA
Solana
SOL
Polkadot
DOT
Account Types
Common values for the accountType field in bank transfers (free-text):
Value
Description
Checking
Checking/Current account
Savings
Savings account
Business
Business account
Money Market
Money market account
Mobile Payment Providers
Common values for the provider field (free-text, not strictly enforced):
Value
Description
Apple Pay
Apple Pay mobile payments
Google Pay
Google Pay mobile payments
Samsung Pay
Samsung Pay mobile payments
WeChat Pay
WeChat Pay
Alipay
Alipay
Wallet Types
Common values for the walletType field (free-text, not strictly enforced):
Value
Description
Skrill
Skrill digital wallet
Neteller
Neteller e-wallet
PayTM
PayTM wallet
PayU
PayU wallet
Payoneer
Payoneer account
Currency Codes
Use ISO 4217 3-letter currency codes for the currency field:
Code
Currency
USD
US Dollar
EUR
Euro
GBP
British Pound
TZS
Tanzanian Shilling
KES
Kenyan Shilling
UGX
Ugandan Shilling
ZAR
South African Rand
NGN
Nigerian Naira
Endpoints
1. CreateInitiate Payment MethodCollection
Purpose: CreateInitiates a newwallet paymenttop-up methodrequest forvia themobile authenticatedmoney user(USSD) withor supportcard for multiple payment typespayment.
Endpoint: POST {base_url}/payment-methodscollection/initiate
Access Level: 🔒 Protected (— Requires Bearer Token Authentication)
Authentication: Bearer Token
Quick Reference - Required Fields by Payment Type:
| |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
|
Request Headers:
Request JSON Sample - Credit/Debit Card:
{
"paymentMethodType": "CREDIT_CARD",
"methodDetails": {
"cardType": "Visa",
"cardNumber": "4532015112830366",
"expiry": "12/2027",
"cardholderName": "John Doe"
},
"billingAddress": {
"street": "123 Main Street",
"city": "Dar es Salaam",
"state": "Dar es Salaam",
"postalCode": "12345",
"country": "Tanzania"
},
"metadata": {
"preferred": true,
"notes": "Primary business card"
},
"isDefault": true
}
Request JSON Sample - Mobile Money (M-Pesa):
{
"paymentMethodType": "MNO_PAYMENT",
"methodDetails": {
"phoneNumber": "+255712345678",
"mccMnc": "M-PESA"
},
"isDefault": true
}
Request JSON Sample - PayPal:
{
"paymentMethodType": "PAYPAL",
"methodDetails": {
"email": "john.doe@example.com",
"paypalId": "johndoe123"
},
"isDefault": false
}
Request JSON Sample - Bank Transfer:
{
"paymentMethodType": "BANK_TRANSFER",
"methodDetails": {
"bankName": "CRDB Bank",
"accountNumber": "1234567890",
"routingNumber": "021000021",
"accountType": "Checking",
"accountHolderName": "John Doe"
},
"billingAddress": {
"street": "456 Bank Avenue",
"city": "Dar es Salaam",
"country": "Tanzania"
},
"isDefault": false
}
Request JSON Sample - Cryptocurrency:
{
"paymentMethodType": "CRYPTOCURRENCY",
"methodDetails": {
"cryptoType": "Bitcoin",
"walletAddress": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"network": "BTC Mainnet"
},
"isDefault": false
}
Request JSON Sample - Mobile Payment (Apple Pay/Google Pay):
{
"paymentMethodType": "MOBILE_PAYMENT",
"methodDetails": {
"provider": "Apple Pay",
"deviceId": "iPhone-12-Pro-XYZ123"
},
"isDefault": false
}
Request JSON Sample - Digital Wallet:
{
"paymentMethodType": "WALLET",
"methodDetails": {
"walletType": "Skrill",
"walletId": "john.doe@example.com"
},
"isDefault": false
}
Request JSON Sample - Gift Card:
{
"paymentMethodType": "GIFT_CARD",
"methodDetails": {
"pin": "1234567890123456",
"balance": 50.00,
"currency": "USD"
},
"isDefault": false
}
Request JSON Sample - Cash on Delivery:
{
"paymentMethodType": "CASH_ON_DELIVERY",
"methodDetails": {
"instructions": "Please call 30 minutes before delivery"
},
"isDefault": false
}
Request Body Parameters:
| ||||
| ||||
Success Response JSON Sample:
{
"success": true,
"httpStatus": "OK",
"message": "Payment method created successfully",
"action_time": "2025-10-27T10:30:45",
"data": {
"paymentMethodId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"ownerId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
"ownerUserName": "johndoe",
"paymentMethodType": "CREDIT_CARD",
"methodDetails": {
"cardType": "Visa",
"maskedCardNumber": "**** **** **** 0366",
"expiry": "12/2027",
"cardholderName": "John Doe"
},
"billingAddress": {
"street": "123 Main Street",
"city": "Dar es Salaam",
"state": "Dar es Salaam",
"postalCode": "12345",
"country": "Tanzania"
},
"metadata": {
"preferred": true,
"notes": "Primary business card"
},
"isDefault": true,
"isActive": true,
"isVerified": false,
"createdAt": "2025-10-27T10:30:45",
"updatedAt": "2025-10-27T10:30:45"
}
}
Success Response Fields:
Error Response JSON Sample:
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "Payment method with similar details already exists for your account",
"action_time": "2025-10-27T10:30:45",
"data": "Payment method with similar details already exists for your account"
}
Standard Error Types:
Application-Level Exceptions (400-499)
400 BAD_REQUEST: Invalid payment details, duplicate payment method, or missing required fields401 UNAUTHORIZED: Missing, invalid, or expired authentication token404 NOT_FOUND: Authenticated user account not found422 UNPROCESSABLE_ENTITY: Validation errors with detailed field information
Server-Level Exceptions (500+)
500 INTERNAL_SERVER_ERROR: Unexpected server errors
Error Response Examples:
Bad Request - Missing Required Fields (400):
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "Card number is required",
"action_time": "2025-10-27T10:30:45",
"data": "Card number is required"
}
Bad Request - Duplicate Payment Method (400):
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "Payment method with similar details already exists for your account",
"action_time": "2025-10-27T10:30:45",
"data": "Payment method with similar details already exists for your account"
}
{
"success": false,
"httpStatus": "UNAUTHORIZED",
"message": "Invalid or expired authentication token",
"action_time": "2025-10-27T10:30:45",
"data": "Invalid or expired authentication token"
}
Not Found - User Not Found (404):
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "User not found",
"action_time": "2025-10-27T10:30:45",
"data": "User not found"
}
Validation Error (422):
{
"success": false,
"httpStatus": "UNPROCESSABLE_ENTITY",
"message": "Validation failed",
"action_time": "2025-10-27T10:30:45",
"data": {
"cardNumber": "Invalid card number",
"expiry": "Invalid expiry format (MM/YY)",
"email": "must be a well-formed email address"
}
}
2. Get Payment Method by ID
Purpose: Retrieve detailed information about a specific payment method
Endpoint: GET {base_url}/payment-methods/{paymentMethodId}
Access Level: 🔒 Protected (RequiresAuthorization: Bearer Token, Owner only)
Authentication: Bearer Token<token>
Request Headers:
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer |
Path Parameters:
Success Response JSON Sample:
{
"success": true,
"httpStatus": "OK",
"message": "Payment method retrieved successfully",
"action_time": "2025-10-27T10:30:45",
"data": {
"paymentMethodId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"ownerId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
"ownerUserName": "johndoe",
"paymentMethodType": "MNO_PAYMENT",
"methodDetails": {
"maskedPhoneNumber": "+255****5678",
"mccMnc": "M-PESA"
},
"isDefault": true,
"isActive": true,
"isVerified": true,
"createdAt": "2025-10-20T08:15:30",
"updatedAt": "2025-10-27T10:30:45"
}
}
Success Response Fields:
Error Response JSON Sample:
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "Payment method not found, or you do not have access to it",
"action_time": "2025-10-27T10:30:45",
"data": "Payment method not found, or you do not have access to it"
}
Error Response Examples:
Not Found (404):
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "Payment method not found, or you do not have access to it",
"action_time": "2025-10-27T10:30:45",
"data": "Payment method not found, or you do not have access to it"
}
{
"success": false,
"httpStatus": "UNAUTHORIZED",
"message": "Authentication required",
"action_time": "2025-10-27T10:30:45",
"data": "Authentication required"
}
3. Get My Payment Methods
Purpose: Retrieve all payment methods belonging to the authenticated user with summary statistics
Endpoint: GET {base_url}/payment-methods/my-payment-methods
Access Level: 🔒 Protected (Requires Bearer Token)
Authentication: Bearer Token
Request Headers:
Success Response JSON Sample:
{
"success": true,
"httpStatus": "OK",
"message": "Payment methods retrieved successfully",
"action_time": "2025-10-27T10:30:45",
"data": {
"paymentMethods": [
{
"paymentMethodId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"paymentMethodType": "CREDIT_CARD",
"displayName": "Visa ****0366",
"isDefault": true,
"isActive": true,
"isVerified": true,
"createdAt": "2025-10-15T09:20:15",
"details": {
"cardType": "Visa",
"lastFourDigits": "0366",
"status": "Active"
}
},
{
"paymentMethodId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
"paymentMethodType": "MNO_PAYMENT",
"displayName": "M-Pesa +255****5678",
"isDefault": false,
"isActive": true,
"isVerified": true,
"createdAt": "2025-10-20T14:45:30",
"details": {
"maskedPhoneNumber": "+255****5678",
"status": "Active"
}
},
{
"paymentMethodId": "c3d4e5f6-a7b8-9012-cdef-123456789012",
"paymentMethodType": "PAYPAL",
"displayName": "PayPal (john.doe@example.com)",
"isDefault": false,
"isActive": true,
"isVerified": false,
"createdAt": "2025-10-22T11:30:00",
"details": {
"email": "john.doe@example.com",
"status": "Pending"
}
}
],
"totalCount": 3,
"activeCount": 3,
"defaultPaymentMethod": {
"paymentMethodId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"paymentMethodType": "CREDIT_CARD",
"displayName": "Visa ****0366",
"isDefault": true,
"isActive": true,
"isVerified": true,
"createdAt": "2025-10-15T09:20:15",
"details": {
"cardType": "Visa",
"lastFourDigits": "0366",
"status": "Active"
}
}
}
}
Success Response Fields:
Error Response JSON Sample:
{
"success": false,
"httpStatus": "UNAUTHORIZED",
"message": "User not authenticated",
"action_time": "2025-10-27T10:30:45",
"data": "User not authenticated"
}
Error Response Examples:
{
"success": false,
"httpStatus": "UNAUTHORIZED",
"message": "User not authenticated",
"action_time": "2025-10-27T10:30:45",
"data": "User not authenticated"
}
Not Found - User Not Found (404):
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "User not found",
"action_time": "2025-10-27T10:30:45",
"data": "User not found"
}
4. Update Payment Method
Purpose: Update an existing payment method with partial or complete changes
Endpoint: PUT {base_url}/payment-methods/{paymentMethodId}
Access Level: 🔒 Protected (Requires Bearer Token, Owner only)
Authentication: Bearer Token
Request Headers:
| Content-Type | string | Yes | application/ |
Path Parameters:
Request JSON Sample - Update Card Expiry(USSD):
{
"paymentMethodType"channel": "CREDIT_CARD"MPESA",
"methodDetails"amount": {50000,
"expiry"msisdn": "06/2028"255712345678",
}"idempotencyKey": "usr-123-topup-1741234567"
}
Request JSON Sample - Update Mobile Money Number(CARD):
{
"paymentMethodType"channel": "MNO_PAYMENT"CARD",
"methodDetails"amount": {50000,
"phoneNumber"idempotencyKey": "+255723456789"
}
}
Request JSON Sample - Update Billing Address:
{
"paymentMethodType": "CREDIT_CARD",
"billingAddress": {
"street": "789 New Avenue",
"city": "Arusha",
"country": "Tanzania"
}
}
Request JSON Sample - Set as Default:
{
"paymentMethodType": "CREDIT_CARD",
"isDefault": trueusr-123-topup-1741234568"
}
Request Body Parameters:
| Parameter | Type | Required | Description | Validation |
|---|---|---|---|---|
channel |
string |
MPESA, AIRTEL, TIGO, HALOPESA, SELCOM_PESA, CARD |
||
amount |
||||
msisdn |
255XXXXXXXXX (12 digits) |
|||
idempotencyKey |
||||
Note: All nested fields from the Create endpoint are supported. Only provided fields will be updated; null or missing fields retain their existing values.
Success Response JSON Sample (USSD):
{
"success": true,
"httpStatus": "OK",
"message": "PaymentCollection method updatedinitiated successfully",
"action_time": "2025-10-27T10:2026-03-06T10:30:45",
"data": {
"paymentMethodId"collectionRequestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"ownerId"channel": "b2c3d4e5-f6a7-8901-bcde-f12345678901"MPESA",
"ownerUserName"amount": 50000,
"currency": "johndoe"TZS",
"paymentMethodType"status": "CREDIT_CARD"AWAITING_CUSTOMER_ACTION",
"methodDetails"msisdnDisplay": "2557****678",
"paymentUrl": null,
"message": "Please enter your PIN on your phone to complete payment."
}
}
Success Response JSON Sample (CARD):
{
"success": true,
"httpStatus": "OK",
"message": "Collection initiated successfully",
"action_time": "2026-03-06T10:30:45",
"data": {
"cardType"collectionRequestId": "Visa"a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"maskedCardNumber"channel": "**** **** **** 0366"CARD",
"expiry"amount": 50000,
"currency": "06/2028"TZS",
"cardholderName"status": "John Doe"
}AWAITING_CUSTOMER_ACTION",
"billingAddress"msisdnDisplay": {null,
"street"paymentUrl": "123 Main Street"https://checkout.selcom.net/pay/abc123",
"city"message": "DarRedirect esuser Salaam",to payment URL."state": "Dar es Salaam",
"postalCode": "12345",
"country": "Tanzania"
},
"isDefault": true,
"isActive": true,
"isVerified": false,
"createdAt": "2025-10-15T09:20:15",
"updatedAt": "2025-10-27T10:30:45"
}
}
Success Response Fields:
| Field | Description |
|---|---|
collectionRequestId |
/status/{id} |
channel |
|
amount |
|
currency |
TZS |
status |
|
msisdnDisplay |
2557****678 |
paymentUrl |
|
message |
Collection Status Values:
| Status | Description |
|---|---|
PENDING |
Request created, not yet sent to Selcom |
AWAITING_CUSTOMER_ACTION |
|
COMPLETED |
|
FAILED |
|
EXPIRED |
Error Response JSON Sample:
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "Payment method not found",
"action_time": "2025-10-27T10:30:45",
"data": "Payment method not found"
}
Error Response ExamplesResponses:
NotMissing Foundphone (404):
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "Payment method not found",
"action_time": "2025-10-27T10:30:45",
"data": "Payment method not found"
}
Bad Request - DuplicateUSSD (400):
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "ThisPhone paymentnumber methodis already existsrequired for yourMPESA account"payments.",
"action_time": "2025-10-27T10:2026-03-06T10:30:45",
"data": "ThisPhone paymentnumber methodis already existsrequired for yourMPESA account"payments."
}
ValidationInvalid Errorphone format (422)400):
{
"success": false,
"httpStatus": "UNPROCESSABLE_ENTITY"BAD_REQUEST",
"message": "ValidationInvalid failed"phone number format.",
"action_time": "2025-10-27T10:2026-03-06T10:30:45",
"data": {
"phoneNumber": "Invalid phone number"number format."
}
Selcom rejection (400):
{
"success": false,
"httpStatus": "BAD_REQUEST",
"expiry"message": "InvalidPayment expiryinitiation formatfailed: (MM/YY)Subscriber not found",
"action_time": }"2026-03-06T10:30:45",
"data": "Payment initiation failed: Subscriber not found"
}
5.2. DeleteGet PaymentCollection MethodStatus
Purpose: PermanentlyReturns deletethe current status of a paymentcollection methodrequest. fromPoll this after initiating to know when the systemwallet has been credited.
Endpoint: DELETEGET /collection/status/{base_url}/payment-methods/{paymentMethodId}collectionRequestId}
Access Level: 🔒 Protected (— Requires Bearer Token, Owner only)Token
Authentication: Authorization: Bearer Token<token>
Request Headers:
Path Parameters:
| Parameter | Type | Required | Description | |
|---|---|---|---|---|
collectionRequestId |
UUID | Yes | /initiate |
Success Response JSON Sample:
{
"success": true,
"httpStatus": "OK",
"message": "PaymentCollection methodstatus deleted successfully"retrieved",
"action_time": "2025-10-27T10:30:45",
"data": null
}
Success Response Fields:
Error Response JSON Sample:
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "Payment method not found",
"action_time": "2025-10-27T10:30:45",
"data": "Payment method not found"
}
Error Response Examples:
Not Found (404):
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "Payment method not found",
"action_time": "2025-10-27T10:30:45",
"data": "Payment method not found"
}
{
"success": false,
"httpStatus": "UNAUTHORIZED",
"message": "Authentication required",
"action_time": "2025-10-27T10:30:45",
"data": "Authentication required"
}
6. Set Payment Method as Default
Purpose: Set a specific payment method as the default for the authenticated user
Endpoint: PATCH {base_url}/payment-methods/{paymentMethodId}/set-default
Access Level: 🔒 Protected (Requires Bearer Token, Owner only)
Authentication: Bearer Token
Request Headers:
Path Parameters:
Success Response JSON Sample:
{
"success": true,
"httpStatus": "OK",
"message": "Payment method set as default successfully",
"action_time": "2025-10-27T10:2026-03-06T10:30:45",
"data": {
"paymentMethodId"collectionRequestId": "b2c3d4e5-f6a7-8901-bcde-f12345678901"a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"ownerId"channel": "b2c3d4e5-f6a7-8901-bcde-f12345678901"MPESA",
"ownerUserName"amount": 50000,
"currency": "johndoe"TZS",
"paymentMethodType"status": "MNO_PAYMENT"COMPLETED",
"methodDetails": {
"maskedPhoneNumber"msisdnDisplay": "+255*2557****5678"678",
"mccMnc"failureReason": null,
"transactionRef": "M-PESA"
}NXT-TXN-20260306-ABCD1234",
"isDefault": true,
"isActive": true,
"isVerified": true,
"createdAt": "2025-10-20T08:15:30"2026-03-06T10:30:00",
"updatedAt"completedAt": "2025-10-27T10:30:2026-03-06T10:31:45"
}
}
Success Response Fields:
| Field | Description |
|---|---|
collectionRequestId |
|
channel |
|
amount |
|
currency |
Always TZS |
status |
Current status — see status table above |
msisdnDisplay |
Masked phone number |
failureReason |
Populated if status is FAILED |
transactionRef |
Wallet transaction reference — available when COMPLETED |
createdAt |
When the request was created |
completedAt |
When the wallet was credited — null if not yet completed |
Note: All previously default payment methods are automatically set to isDefault: false.
Error Response JSON Sample:
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "Cannot set inactive payment method as default",
"action_time": "2025-10-27T10:30:45",
"data": "Cannot set inactive payment method as default"
}
Error Response ExamplesResponses:
BadNot Requestfound -or Inactivenot Paymentowned Methodby user (400):
{
"success": false,
"httpStatus": "BAD_REQUEST",
"message": "CannotCollection set inactive payment method as default",
"action_time": "2025-10-27T10:30:45",
"data": "Cannot set inactive payment method as default"
}
Not Found (404):
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "Payment methodrequest not found",
"action_time": "2025-10-27T10:2026-03-06T10:30:45",
"data": "PaymentCollection methodrequest not found"
}
{
"success": false,
"httpStatus": "UNAUTHORIZED",
"message": "Authentication required",
"action_time": "2025-10-27T10:30:45",
"data": "Authentication required"
}
Quick Reference Guide
HTTP
| Method | Endpoint | Description |
|---|---|---|
| POST | |
Start
|
| GET | |
Check |
404 Not Found422 Unprocessable Entity500 Internal Server ErrorAuthentication Types
Bearer Token: IncludeAuthorization: Bearer your_tokenin headers
Data Format Standards
Dates: Use ISO 8601 format (2025-10-27T14:30:00)Currency: Use standard 3-letter codes (USD, EUR, TZS)Phone Numbers: Use E.164 format (+[country code][number])Card Numbers: 13-19 digits (automatically tokenized and masked)UUIDs: Standard UUID v4 format (8-4-4-4-12 hexadecimal)
Payment Method Types
CREDIT_CARD: Credit card paymentsDEBIT_CARD: Debit card paymentsPAYPAL: PayPal account paymentsBANK_TRANSFER: Direct bank account transfersCRYPTOCURRENCY: Crypto wallet payments (Bitcoin, Ethereum, etc.)MOBILE_PAYMENT: Mobile payment services (Apple Pay, Google Pay)MNO_PAYMENT: Mobile Network Operator payments (M-Pesa, Airtel Money, Tigo Pesa, etc.)WALLET: Digital wallet services (Skrill, Neteller, etc.)GIFT_CARD: Gift card paymentsCASH_ON_DELIVERY: Cash payment upon delivery
Supported Mobile Network Operators (Tanzania)
M-Pesa (Vodacom)Airtel MoneyTigo PesaHalo PesaAzam PesaEzy Pesa
Supported Banks (Tanzania)
CRDB BankNMB BankEXIM BankKCB BankNBC BankStanbic BankDiamond BankAccess BankAzania BankEquity BankFNB Bank
Data Masking Rules
Card Numbers: Shows only last 4 digits (e.g., "**** **** **** 1234")Account Numbers: Shows only last 4 digits (e.g., "****1234")Phone Numbers: Masks middle digits (e.g., "+255****5678")Wallet Addresses: Shows first and last 4 characters (e.g., "1A1z...fNa")PINs: Completely masked (e.g., "****")
Security Notes
Sensitive data (card numbers, account numbers, PINs) should be tokenized before storageAll responses mask sensitive informationDuplicate detection prevents storing multiple identical payment methodsOnly payment method owners can view, update, or delete their payment methodsSetting a payment method as default requires it to be active
Business Rules
Only one payment method can be default at a timeSetting a new default automatically unsets the previous defaultInactive payment methods cannot be set as defaultPayment methods can be created without verification (isVerified: false)Partial updates are supported - only provided fields are updatedDelete operations are permanent (hard delete)
Payment Method Type Examples
Credit/Debit Card Example
{
"paymentMethodType": "CREDIT_CARD",
"methodDetails": {
"cardType": "Visa",
"cardNumber": "4532015112830366",
"expiry": "12/2027",
"cardholderName": "John Doe"
},
"billingAddress": {
"street": "123 Main Street",
"city": "Dar es Salaam",
"country": "Tanzania"
},
"isDefault": true
}
Mobile Money (M-Pesa) Example
{
"paymentMethodType": "MNO_PAYMENT",
"methodDetails": {
"phoneNumber": "+255712345678",
"mccMnc": "M-PESA"
},
"isDefault": true
}
PayPal Example
{
"paymentMethodType": "PAYPAL",
"methodDetails": {
"email": "john.doe@example.com",
"paypalId": "johndoe123"
}
}
Bank Transfer Example
{
"paymentMethodType": "BANK_TRANSFER",
"methodDetails": {
"bankName": "CRDB Bank",
"accountNumber": "1234567890",
"routingNumber": "021000021",
"accountType": "Checking",
"accountHolderName": "John Doe"
},
"billingAddress": {
"street": "456 Bank Avenue",
"city": "Dar es Salaam",
"country": "Tanzania"
}
}
Cryptocurrency Example
{
"paymentMethodType": "CRYPTOCURRENCY",
"methodDetails": {
"cryptoType": "Bitcoin",
"walletAddress": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
"network": "BTC Mainnet"
}
}
Mobile Payment (Apple Pay) Example
{
"paymentMethodType": "MOBILE_PAYMENT",
"methodDetails": {
"provider": "Apple Pay",
"deviceId": "iPhone-12-Pro-XYZ123"
}
}
Digital Wallet Example
{
"paymentMethodType": "WALLET",
"methodDetails": {
"walletType": "Skrill",
"walletId": "john.doe@example.com"
}
}
Gift Card Example
{
"paymentMethodType": "GIFT_CARD",
"methodDetails": {
"pin": "1234567890123456",
"balance": 50.00,
"currency": "USD"
}
}
Cash on Delivery Example
{
"paymentMethodType": "CASH_ON_DELIVERY",
"methodDetails": {
"instructions": "Please call 30 minutes before delivery"
}
}