🔗 API Integration

Initiate Payment API

This endpoint initiates a new payment and returns a payment URL where the client can complete the transaction.

Endpoint

POST /payments/init-payment

Headers

NameRequiredTypeDescription
x-api-keyYesstringUnique API key identifying your organization (get it here)

Body Example

{
  "receiverWalletId": "5f7a209aeb3f76490ac4a3d1",
  "token": "TND",
  "amount": 10000,
  "type": "immediate",
  "description": "payment description",
  "acceptedPaymentMethods": ["wallet", "bank_card", "e-DINAR"],
  "lifespan": 10,
  "checkoutForm": true,
  "addPaymentFeesToAmount": true,
  "firstName": "John",
  "lastName": "Doe",
  "phoneNumber": "22777777",
  "email": "john.doe@gmail.com",
  "orderId": "1234657",
  "webhook": "https://merchant.tech/api/notification_payment",
  "silentWebhook": true,
  "successUrl": "https://gateway.sandbox.konnect.network/payment-success",
  "failUrl": "https://gateway.sandbox.konnect.network/payment-failure",
  "theme": "dark"
}

Request Body Parameters

OptionTypeDescription
receiverWalletId (required)stringKonnect wallet ID of the payment receiver (found in dashboard)
tokenstringCurrency of payment: ⁠TND, ⁠EUR, or ⁠USD. Non-TND payments are automatically converted
amount (required)numberPayment amount (in Millimes for TND / Centimes for EUR and USD)
typestringPayment type: ⁠immediate (full payment) or ⁠partial (allows partial payments)
descriptionstringPayment description visible to payer on gateway page
acceptedPaymentMethodsarrayAllowed payment methods: ⁠wallet, ⁠bank_card, ⁠e-DINAR, ⁠flouci. Defaults to ⁠["wallet","bank_card","e-DINAR"]
lifespannumberPayment link expiration time in minutes
checkoutFormbooleanWhether payer must fill checkout form before payment
addPaymentFeesToAmountbooleanIf true, adds Konnect fees to payers amount. Defaults to ⁠false
firstNamestringPayers first name
lastNamestringPayers last name
phoneNumberstringPayers phone number
emailstringPayers email address
orderIdstringCustom order identifier
webhookstringURL for payment notification (GET request)
silentWebhookbooleanIf true, calls webhook without redirecting payer
successUrlstringRedirect URL for successful payment (ignored if webhook is active and not silent)
failUrlstringRedirect URL for failed payment (ignored if webhook is active and not silent)
themestringGateway theme: ⁠light or ⁠dark. Defaults to ⁠light

Response

Example

{
  "payUrl": "https://dev.konnect.network/admin/pay?payment_ref=5e870a611631215d633fe083",
  "paymentRef": "60889219a388f75c94a943ec"
}

Response Parameters

ParameterTypeDescription
payUrlstringPayment gateway URL where the client can complete the payment
paymentRefstringUnique reference ID for the payment

Test

Best Practices

  1. Always implement proper error handling for both API calls and webhook notifications
  2. Set appropriate lifespan for payments based on your business needs
  3. Use silentWebhook when you need to process payment results without user redirection
  4. Store paymentRef for future reference and reconciliation

Rate Limits

  • Standard rate limit: 100 requests per minute
  • Contact support for increased limits if needed