{"openapi":"3.1.0","info":{"title":"API Integration Workflow Demo","description":"A minimal FastAPI demo that showcases API request handling, ECPay stage checkout, callback verification, persistent SQLite event tracking, reload-safe payment status pages, and optional Slack notification delivery after confirmed payment.","version":"0.7.0"},"paths":{"/":{"get":{"tags":["system"],"summary":"Home","operationId":"home__get","responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}}}}},"/health":{"get":{"tags":["system"],"summary":"Health Check","operationId":"health_check_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Health Check Health Get"}}}}}}},"/api/integrations/orders":{"post":{"tags":["integrations"],"summary":"Create Order Integration","operationId":"create_order_integration_api_integrations_orders_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/integrations/webhooks/ecpay/return":{"post":{"tags":["integrations"],"summary":"Ecpay Return Callback","operationId":"ecpay_return_callback_api_integrations_webhooks_ecpay_return_post","responses":{"200":{"description":"Successful Response","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/api/integrations/events/{event_id}":{"get":{"tags":["integrations"],"summary":"Get Integration Event","operationId":"get_integration_event_api_integrations_events__event_id__get","parameters":[{"name":"event_id","in":"path","required":true,"schema":{"type":"string","title":"Event Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventRecord"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/integrations/events":{"get":{"tags":["integrations"],"summary":"Get Recent Integration Events","operationId":"get_recent_integration_events_api_integrations_events_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":20,"minimum":1,"default":5,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecentEventsResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/payments/ecpay/checkout":{"post":{"tags":["payments"],"summary":"Create Ecpay Checkout For Event","operationId":"create_ecpay_checkout_for_event_api_payments_ecpay_checkout_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ECPayCheckoutRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ECPayCheckoutResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/payments/ecpay/redirect/{event_id}":{"get":{"tags":["payment-pages"],"summary":"Ecpay Redirect Page","operationId":"ecpay_redirect_page_payments_ecpay_redirect__event_id__get","parameters":[{"name":"event_id","in":"path","required":true,"schema":{"type":"string","title":"Event Id"}}],"responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/payments/ecpay/result":{"post":{"tags":["payment-pages"],"summary":"Ecpay Result Post","operationId":"ecpay_result_post_payments_ecpay_result_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"get":{"tags":["payment-pages"],"summary":"Ecpay Result Page","operationId":"ecpay_result_page_payments_ecpay_result_get","parameters":[{"name":"event_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Event Id"}},{"name":"merchant_trade_no","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Trade No"}}],"responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/payments/ecpay/back":{"get":{"tags":["payment-pages"],"summary":"Ecpay Back Page","operationId":"ecpay_back_page_payments_ecpay_back_get","parameters":[{"name":"event_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Event Id"}}],"responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"CreateOrderResponse":{"properties":{"event_id":{"type":"string","title":"Event Id"},"status":{"type":"string","const":"pending_payment","title":"Status"},"target_system":{"type":"string","title":"Target System"},"mapped_payload":{"$ref":"#/components/schemas/MappedOrder"},"next_step":{"type":"string","title":"Next Step"},"recent_lookup_url":{"type":"string","title":"Recent Lookup Url"}},"type":"object","required":["event_id","status","target_system","mapped_payload","next_step","recent_lookup_url"],"title":"CreateOrderResponse"},"ECPayCheckoutRequest":{"properties":{"event_id":{"type":"string","title":"Event Id","examples":["evt_8f0b2c9e2e4d4f7a8e3a9f53b2bf0eb4"]}},"type":"object","required":["event_id"],"title":"ECPayCheckoutRequest"},"ECPayCheckoutResponse":{"properties":{"event_id":{"type":"string","title":"Event Id"},"status":{"type":"string","const":"redirect_ready","title":"Status"},"merchant_trade_no":{"type":"string","title":"Merchant Trade No"},"payment_page_url":{"type":"string","title":"Payment Page Url"},"ecpay_checkout_url":{"type":"string","title":"Ecpay Checkout Url"}},"type":"object","required":["event_id","status","merchant_trade_no","payment_page_url","ecpay_checkout_url"],"title":"ECPayCheckoutResponse"},"EventRecord":{"properties":{"event_id":{"type":"string","title":"Event Id"},"source":{"type":"string","title":"Source"},"status":{"type":"string","enum":["pending_payment","redirect_ready","payment_processing","payment_callback_received","paid","payment_failed"],"title":"Status"},"target_system":{"type":"string","title":"Target System"},"mapped_payload":{"$ref":"#/components/schemas/MappedOrder"},"payment_page_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payment Page Url"},"merchant_trade_no":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Trade No"},"ecpay_trade_no":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ecpay Trade No"},"payment_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payment Type"},"rtn_code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Rtn Code"},"rtn_msg":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Rtn Msg"},"last_event_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Event Type"},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"notification_status":{"type":"string","enum":["pending","sent","disabled","failed","not_applicable"],"title":"Notification Status","default":"pending"},"notification_channel":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notification Channel"},"notification_sent_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notification Sent At"},"notification_last_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notification Last Error"},"created_at":{"type":"string","title":"Created At"},"updated_at":{"type":"string","title":"Updated At"}},"additionalProperties":false,"type":"object","required":["event_id","source","status","target_system","mapped_payload","created_at","updated_at"],"title":"EventRecord"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"MappedOrder":{"properties":{"external_order_id":{"type":"string","title":"External Order Id"},"client_name":{"type":"string","title":"Client Name"},"client_email":{"type":"string","format":"email","title":"Client Email"},"total_amount":{"type":"integer","title":"Total Amount"},"currency":{"type":"string","const":"TWD","title":"Currency"},"source_platform":{"type":"string","title":"Source Platform"}},"type":"object","required":["external_order_id","client_name","client_email","total_amount","currency","source_platform"],"title":"MappedOrder"},"OrderRequest":{"properties":{"source":{"type":"string","maxLength":50,"minLength":2,"title":"Source","examples":["demo_store"]},"order_id":{"type":"string","maxLength":100,"minLength":3,"title":"Order Id","examples":["DEMO-1001"]},"customer_name":{"type":"string","maxLength":100,"minLength":2,"title":"Customer Name","examples":["Alex Chen"]},"customer_email":{"type":"string","format":"email","title":"Customer Email","examples":["alex@example.com"]},"amount":{"type":"integer","exclusiveMinimum":0.0,"title":"Amount","examples":[499]},"currency":{"type":"string","maxLength":3,"minLength":3,"title":"Currency","default":"TWD","examples":["TWD"]}},"type":"object","required":["source","order_id","customer_name","customer_email","amount"],"title":"OrderRequest"},"RecentEventsResponse":{"properties":{"events":{"items":{"$ref":"#/components/schemas/EventRecord"},"type":"array","title":"Events"}},"type":"object","required":["events"],"title":"RecentEventsResponse"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}