Skip to content

Accept Testimony Offer ​

Confirm payment and accept a testimony offer after successful Stripe checkout. This endpoint completes the acceptance process by validating the Stripe payment session and transitioning the testimony to the "accepted" state.

See Payment Integration for the complete payment integration guide.

Payment Flow ​

The complete offer acceptance flow involves three steps:

  1. Initiate Checkout - Call Checkout Offer to get a Stripe checkout URL
  2. Complete Payment - Redirect user to Stripe where they complete payment
  3. Confirm Acceptance - Call this endpoint with the offer ID and the session ID Stripe returns to your success page

After successful confirmation, the testimony transitions from offered to accepted state.

Webhook race

The backend also accepts the offer when Stripe's checkout.session.completed webhook arrives, which can happen before the client lands on your success page. Confirming the same paid session again is then a no-op 204; 409 Conflict — Pre tento posudok už bola prijatá ponuka. is answered only for a different paid session of an already accepted testimony. Confirm the state with Show Testimony.

HTTP Request ​

POST /api/v1/testimonies/offers/:offerId/accept

offerId is the offer that was checked out. Stripe returns it to your success page as the offerId query parameter, next to sessionId. The session must have been created for this offer.

Parameters ​

ParameterDescription
sessionId stringThe Stripe checkout session ID (cs_…) received as the sessionId query parameter on the success page.

Request Example ​

json
{
  "sessionId": "cs_test_a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0"
}

Response ​

204 No Content

Indicates the offer was successfully accepted and the testimony has transitioned to the "accepted" state.

Authentication ​

Requires authentication via Bearer token and a verified email. Only the client who owns the offer's testimony may accept it (403 Forbidden otherwise).

401 Unauthorized

json
{
  "message": "Unauthenticated."
}

Error Handling ​

All errors use the standard {"message": "..."} envelope (see Error Responses).

Payment Not Completed ​

422 Unprocessable Content

json
{
  "message": "Platba ešte nebola dokončená."
}

Returned when the Stripe session exists but has not been paid. A validation error with an errors object is returned instead when sessionId is missing or does not start with cs_.

Wrong Client ​

403 Forbidden

json
{
  "message": "This action is unauthorized."
}

The offer belongs to another client's testimony, or the caller is an expert. (In production the message is the generic Forbidden, see Error Responses.)

Unknown Offer ​

404 Not Found when no offer has the given offerId. An offer its expert has withdrawn is still found, and answers 409 (below).

Conflicts ​

409 Conflict with one of these messages:

  • Pre tento posudok už bola prijatá ponuka. — another session already won this testimony (see above). Verify with Show Testimony.
  • Platba nepatrí k tejto ponuke. — the session was paid for a different offer than the one in the URL.
  • Táto ponuka už nie je dostupná. — the offer was withdrawn by its expert, its expert can no longer be booked, or this session's payment has already been refunded. A payment made for such an offer is refunded automatically once Stripe's checkout.session.completed webhook is processed; a refunded session can never be accepted, so start a new checkout with another offer.
  • Prechod zo stavu „Zrušený“ do stavu „Prijatý“ nie je možný. — the testimony left the offered state (the message names the states by their Slovak labels).
  • Záznam bol medzitým zmenený. Skúste to znova. — concurrent modification; re-fetch the testimony and retry.

Stripe Errors ​

422 Unprocessable Content — Pri spracovaní platby nastala chyba. Skúste to znova. when Stripe rejected the request, for example an unknown session id.

502 Bad Gateway with the same message when Stripe could not be reached, rate-limited the request or answered with a server error — retry later.

json
{
  "message": "Pri spracovaní platby nastala chyba. Skúste to znova."
}

Business Logic ​

  • The offer can only be accepted if the testimony is in offered state
  • After successful acceptance:
    • The testimony transitions to accepted state
    • The offer is marked as accepted; expert, acceptedOffer, acceptedAt and invoices are populated on the testimony, and client and expert see each other's email and phone
    • The expert is notified by email; experts whose offers were not chosen are notified as well
    • Invoices are generated; the platform invoice is emailed to the client, the expert's invoice is emailed to the expert later, with the notification that the testimony was completed
    • The platform keeps its commission from the paid price; the expert is paid the expertAmount they offered