{"openapi":"3.1.0","servers":[{"url":"https://billing-api.evedex.com"}],"info":{"title":"EVEDEX - Exchange/billing-backend","version":"1.0.0"},"paths":{"/api/ping":{"get":{"tags":["System"],"security":[],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PingResponse"}}}}}}},"/api/webhook/{paymentService}":{"post":{"tags":["Webhook"],"security":[],"parameters":[{"in":"path","name":"paymentService","schema":{"type":"string","enum":["stripe","crypto","evedex","applePay","googlePay"]},"required":true}],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookResponse"}}}},"400":{"description":"400 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/billing/subscription/{subscriptionId}/payment":{"post":{"tags":["Subscription"],"security":[{"InternalKey":[]}],"parameters":[{"in":"path","name":"subscriptionId","schema":{"type":"string","format":"uuid"},"required":true}],"requestBody":{"description":"Update payment method for subscription","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionUpdatePaymentMethodBody"}}}},"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionUpdatePaymentMethodResponse"}}}},"404":{"description":"404 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/subscription/list":{"get":{"tags":["Subscription"],"security":[{"InternalKey":[]}],"parameters":[{"in":"query","name":"limit","schema":{"anyOf":[{"type":"number"},{"type":"string"}],"default":20}},{"in":"query","name":"offset","schema":{"anyOf":[{"type":"number"},{"type":"string"}],"default":0}},{"in":"query","name":"status","schema":{"type":"string","enum":["active","canceled","finished","incomplete","incomplete_expired","past_due","paused","trialing","unpaid","awaiting","pending_cancel"]}}],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionListResponse"}}}},"400":{"description":"400 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/subscription/{subscriptionId}":{"get":{"tags":["Subscription"],"security":[{"InternalKey":[]}],"parameters":[{"in":"path","name":"subscriptionId","schema":{"type":"string","format":"uuid"},"required":true}],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionObject"}}}},"404":{"description":"404 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/billing/subscriptions/{subscriptionId}/cancel":{"post":{"tags":["Subscription"],"security":[],"parameters":[{"in":"path","name":"subscriptionId","schema":{"type":"string","format":"uuid"},"required":true}],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"type":"object","properties":{"validUntil":{"type":"string"}},"required":["validUntil"]}}}},"400":{"description":"400 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"404 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/refund/{billId}":{"post":{"tags":["Refund"],"security":[{"InternalKey":[]}],"parameters":[{"in":"path","name":"billId","schema":{"anyOf":[{"type":"string"},{"type":"string","format":"uuid"}]},"required":true}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRefundBody"}}}},"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefundObject"}}}},"404":{"description":"404 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/product/list":{"get":{"tags":["Product"],"security":[],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ProductObject"}}}}},"400":{"description":"400 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/product/{productId}":{"get":{"tags":["Product"],"security":[],"parameters":[{"in":"path","name":"productId","schema":{"type":"string","format":"uuid"},"required":true}],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductObject"}}}},"400":{"description":"400 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/paysystem/list/{billId}":{"get":{"tags":["Paysystem"],"security":[],"parameters":[{"in":"path","name":"billId","schema":{"anyOf":[{"type":"string"},{"type":"string","format":"uuid"}]},"required":true}],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaysystemListResponse"}}}},"400":{"description":"400 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/payment-service":{"get":{"tags":["PaymentService"],"security":[],"responses":{"200":{"description":"200 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/checkout/{billId}":{"post":{"tags":["Checkout"],"security":[],"parameters":[{"in":"path","name":"billId","schema":{"anyOf":[{"type":"string"},{"type":"string","format":"uuid"}]},"required":true}],"requestBody":{"description":"Create checkout for customer","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCheckoutBody"}}}},"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutResponse"}}}},"404":{"description":"404 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/bill/{billId}":{"get":{"tags":["Bill"],"security":[],"parameters":[{"in":"path","name":"billId","schema":{"anyOf":[{"type":"string"},{"type":"string","format":"uuid"}]},"required":true}],"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillObject"}}}},"404":{"description":"404 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/bill":{"post":{"tags":["Bill"],"security":[{"InternalKey":[]}],"requestBody":{"description":"Create bill for customer","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateBillBody"}}}},"responses":{"200":{"description":"200 OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillResponse"}}}},"400":{"description":"400 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"500 Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"securitySchemes":{"InternalKey":{"type":"http","scheme":"bearer"}},"schemas":{"PingResponse":{"type":"object","properties":{"time":{"type":"number","description":"Current timestamp"}},"required":["time"],"description":"Ping response"},"WebhookResponse":{"type":"object","properties":{"status":{"type":"string","default":"ok"}},"required":["status"]},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string","description":"Error message"}},"required":["message"],"description":"Error response"},"SubscriptionUpdatePaymentMethodBody":{"type":"object","properties":{"returnUrl":{"type":"string","format":"uri"}},"required":["returnUrl"]},"SubscriptionUpdatePaymentMethodResponse":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]},"SubscriptionListResponse":{"type":"object","properties":{"list":{"type":"array","items":{"$ref":"#/components/schemas/SubscriptionObject"}},"count":{"type":"number"}},"required":["list","count"]},"SubscriptionObject":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"product":{"type":"string","format":"uuid"},"providerData":{"type":"object","properties":{"provider":{"type":"string"},"subscriptionId":{"type":"string"}},"required":["provider","subscriptionId"]},"status":{"type":"string"},"currentPeriodEnd":{"type":["string","null"]},"cancelAtPeriodEnd":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"productInfo":{"oneOf":[{"$ref":"#/components/schemas/ProductObject"},{"type":"null"}]}},"required":["id","product","providerData","status","currentPeriodEnd","cancelAtPeriodEnd","createdAt","updatedAt"]},"ProductObject":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"price":{"type":"number"},"currency":{"type":"string"},"description":{"type":"string"},"name":{"type":"string"},"access":{"type":"string","enum":["buffOnly","all","public"]},"privilegies":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","const":"premium"}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","const":"academyCourse"},"courses":{"type":"array","items":{"type":"string"}}},"required":["type","courses"]}]},"availability":{"type":"boolean"},"paymentInfo":{"anyOf":[{"type":"object","properties":{"mode":{"type":"string","const":"subscription"},"period":{"type":"string","enum":["1d","1m","6m","1y"]}},"required":["mode","period"]},{"type":"object","properties":{"mode":{"type":"string","const":"oneTime"}},"required":["mode"]}]},"discount":{"type":"number"},"lastSaleDate":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","price","currency","description","name","access","privilegies","availability","paymentInfo","discount","lastSaleDate","createdAt","updatedAt"]},"CreateRefundBody":{"type":"object","properties":{"amount":{"type":"number"},"currency":{"type":"string"},"failReason":{"type":"string"},"rollbackType":{"type":"string","enum":["notNeeded","full","manual"]}},"required":["amount","currency","rollbackType"]},"RefundObject":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"bill":{"type":"string"},"amount":{"type":"number"},"currency":{"type":"string"},"status":{"type":"string","enum":["awaiting","returned","error"]},"failReason":{"type":"string"},"rollbackType":{"type":"string","enum":["notNeeded","full","manual"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","bill","amount","currency","status","failReason","rollbackType","createdAt","updatedAt"]},"PaysystemListResponse":{"type":"object","properties":{"recommended":{"type":"array","items":{"type":"string"}},"other":{"type":"array","items":{"type":"string"}}},"required":["recommended","other"]},"CreateCheckoutBody":{"type":"object","properties":{"paymentMethods":{"type":"array","items":{"type":"string","enum":["card"]}},"mode":{"type":"string","enum":["oneTime","subscription"]}},"required":["paymentMethods","mode"]},"CheckoutResponse":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]},"BillObject":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"product":{"type":["string","null"]},"linkCode":{"type":["string","null"]},"amount":{"type":["number","null"]},"comission":{"anyOf":[{"type":"object","additionalProperties":{"type":"number"}},{"type":"object"}]},"currency":{"type":["string","null"]},"payerName":{"type":["string","null"]},"payerEmail":{"type":["string","null"]},"payerPhone":{"type":["string","null"]},"paymentService":{"type":["string","null"],"enum":["stripe","crypto","evedex","applePay","googlePay",null]},"paymentSystem":{"type":["string","null"],"enum":["card",null]},"status":{"type":"string","enum":["awaiting","expired","canceled","paid","returned","error","verified","pending_cancel"]},"failReason":{"type":"string"},"paidAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","product","linkCode","amount","comission","currency","payerName","payerEmail","payerPhone","paymentService","paymentSystem","status","failReason","paidAt","createdAt","updatedAt"]},"CreateBillBody":{"type":"object","properties":{"user":{"type":"string"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"product":{"type":"array","items":{"type":"string"}},"trialPeriodDays":{"type":"number","default":0},"paymentService":{"type":"string","enum":["stripe","crypto","evedex","applePay","googlePay"],"default":"stripe"}}},"BillResponse":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"url":{"type":"string","format":"uri"},"paymentService":{"type":"string","enum":["stripe","crypto","evedex","applePay","googlePay"]}},"required":["id","url","paymentService"]}}}}