Skip to main content

Phase 10 β€” Refunds

The refund flow. COOCO initiates the refund request, RideNDine processes it via Stripe, and sends the result back via webhook.


Overview​

Customer / Admin β†’ COOCO β†’ RideNDine β†’ Stripe
↓ (webhook)
COOCO (update + notify)
StepFromToAction
10.1Customer / AdminCOOCOInternal β€” refund request
10.2COOCORideNDinePOST /refunds/create
10.3RideNDineStripeProcess refund
10.4StripeRideNDineStripe refund webhook
10.5RideNDineCOOCOPOST /webhooks/refund-status
10.6COOCOCustomer + Chef + AdminInternal notification

Step 10.1 β€” Refund Request (Internal)​

From: Customer / Admin β†’ To: COOCO

COOCO collects refund information:

FieldDescription
order_idID of the order to be refunded
reasonchef_rejected / customer_cancel
amount_centsRefund amount (full or partial)
requested_bycustomer / admin

Step 10.2 β€” Send Refund Request to RideNDine​

From: COOCO β†’ To: RideNDine

Endpoint: POST /refunds/create

Called via Directus Extension: POST /ridendine/refunds.

Purpose: RideNDine processes the refund via Stripe.

Request Body​

{
"ridendine_order_id": "<orders.ridendine_order_id>",
"external_order_id": "<orders.id>",
"amount_cents": 5000,
"reason": "chef_rejected | customer_cancel",
"requested_by": "customer | admin"
}

Step 10.3 β€” Stripe Process Refund (RideNDine Internal)​

RideNDine creates a refund request on Stripe. COOCO is not involved at this step.


Step 10.4 β€” Stripe Refund Webhook (RideNDine Internal)​

Stripe calls the RideNDine webhook to confirm the refund. COOCO is not involved at this step.


Step 10.5 β€” Webhook: Refund Status​

From: RideNDine β†’ To: COOCO

Endpoint (COOCO expose): {DIRECTUS_URL}/ridendine/webhooks/refund-status

Method: POST

Purpose: COOCO updates the refund status.

Payload received​

{
"refund_id": "<string>",
"external_order_id": "<orders.id>",
"amount_cents": 5000,
"status": "REFUNDED | FAILED"
}

Handling when REFUNDED​

FieldValue
orders.payment_statusREFUNDED
orders.statusCANCELLED

Step 10.6 β€” Result Notification (Internal)​

From: COOCO β†’ To: Customer + Chef + Admin

Directus Flow sends an email notification with the refund result to all relevant parties.

No requests are sent to RideNDine at this step.