mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
3.9 KiB
3.9 KiB
TELEBIRR Payment Integration Flow
Overview
Complete payment flow for TELEBIRR integration using the /payments/initiate endpoint.
Payment Flow
1. Payment Method Selection
- User selects TELEBIRR from available payment methods
- Payment methods fetched from
/payments/methods - Extracts payment method ID for the request
2. Payment Initiation
Endpoint: POST /payments/initiate
Request:
{
"bookingId": "booking-uuid",
"method": "TELEBIRR",
"paymentMethodId": "payment-method-uuid",
"platform": "web"
}
Response:
{
"success": true,
"data": {
"intentId": "66aa30e2-52a2-4ad0-9043-df6df4a6fa4a",
"status": "REQUIRES_ACTION",
"clientAction": {
"url": "https://sandbox.waafipay.net/v2/hpp/token/2B68686270593243495535774B317263683930574A413D3D",
"type": "REDIRECT"
},
"merchantOrderId": "1781588440170af93c3b9"
},
"timestamp": "2026-06-16T05:40:41.004Z"
}
3. User Redirect
- App stores
intentIdin payment store - Updates payment status to
REQUIRES_ACTION - Redirects user to
clientAction.url - User completes payment on WaafiPay gateway
4. Callback Handling
Success Callback
URL: /booking/payment/telebirr/success
Query Parameters:
trxReforoutTradeNo- Transaction referenceresultCodeorcode- Result coderesultMsgormessage- Result messagemsisdn- Phone number (optional)bookingId- Booking UUID
Actions:
- Logs all query parameters
- Calls
PATCH /bookings/{bookingId}/confirmwith:{ "paymentReference": "trxRef", "paymentMethod": "TELEBIRR" } - Updates payment status to
SUCCEEDED - Redirects to
/booking/confirmation
Failure Callback
URL: /booking/payment/telebirr/failure
Query Parameters:
trxReforoutTradeNo- Transaction referenceresultCodeorcode- Error coderesultMsgormessage- Error message
Actions:
- Logs all query parameters
- Updates payment status to
FAILED - Shows error message to user
- Provides options to retry or go back
Console Logs
When TELEBIRR payment is initiated, check browser console for:
=== TELEBIRR PAYMENT INITIATION ===
Request payload: {
bookingId: "...",
method: "TELEBIRR",
paymentMethodId: "...",
platform: "web"
}
=== TELEBIRR PAYMENT RESPONSE ===
Full response: {...}
Intent ID: "66aa30e2-52a2-4ad0-9043-df6df4a6fa4a"
Status: "REQUIRES_ACTION"
Client Action: {url: "...", type: "REDIRECT"}
Redirect URL: "https://sandbox.waafipay.net/v2/hpp/token/..."
Merchant Order ID: "1781588440170af93c3b9"
====================================
=== REDIRECTING TO PAYMENT GATEWAY ===
Intent ID: 66aa30e2-52a2-4ad0-9043-df6df4a6fa4a
Status: REQUIRES_ACTION
Merchant Order ID: 1781588440170af93c3b9
Redirect URL: https://sandbox.waafipay.net/v2/hpp/token/...
=======================================
Files Modified
-
src/app/booking/payment/page.tsx- Added TELEBIRR-specific payment initiation
- Handles redirect response
- Logs all payment data
-
src/lib/payment-store.ts- Added
REQUIRES_ACTIONstatus
- Added
-
src/types/index.ts- Updated
PaymentMethodinterface
- Updated
-
Existing Callback Pages:
src/app/booking/payment/telebirr/success/page.tsxsrc/app/booking/payment/telebirr/failure/page.tsx
Testing Checklist
- Payment methods load from API
- TELEBIRR appears in payment options
- Selecting TELEBIRR calls
/payments/initiate - Console logs show correct request/response
- User redirects to WaafiPay gateway
- Success callback confirms booking
- Failure callback shows error
- User can retry after failure
Notes
- Other payment methods still use
/payments/intentendpoint - Only TELEBIRR uses the new
/payments/initiateflow - Payment store now supports
REQUIRES_ACTIONstatus - All callback query parameters are logged for debugging