Rawi

مرجع API · Billing & payment gateway

Cancel automatic renewal

post/billing/subscription/cancel
احراز هویتتوکن مشتری (Bearer)
سطح دسترسیکاربر رایگان · کاربر حرفه‌ای

Customer token (Bearer) — paid users with a Stripe subscription

محدودیت نرخ10/1min

Sets cancel_at_period_end on the Stripe subscription: nothing more is charged and the paid period runs to its end (renewal.ends_at). Returns AccountSettings (see GET /settings/account).

پاسخ‌ها

200 — AccountSettings

فیلدنوعتوضیح
email*string | nullEmail address.
phone*string | nullMobile number.
sms_notifications*boolean
email_notifications*object
email_notifications.reminders*boolean
email_notifications.report_ready*boolean
email_notifications.renewal*boolean
plan*string ("paid", "free")S5: reminders, report_ready, renewal
billing_period*string | null
plan_expires_at*string | null
payments*object[]
payments[].id*integerUnique ID.
payments[].period*string
payments[].status*stringCurrent status.
payments[].base_amount*integer
payments[].period_discount*integer
payments[].code_discount*integer
payments[].vat*integer
payments[].total*integer
payments[].currency*stringCurrency code, e.g. USD, EUR or IRT.
payments[].tracking_code*string | null
payments[].gateway_message*string | null
payments[].gateway_name*string | null
payments[].period_start*string | null
payments[].period_end*string | null
payments[].paid_at*string | null
payments[].created_at*string | nullWhen it was created (ISO 8601).
payments[].auto_renew*boolean
payments[].renewal_amount*integer | null«Renew automatically» (Stripe subscription)
payments[].amount_refunded*integerRefunds (status refunded / partially_refunded): total refunded so far and when the last one was made.
payments[].refunded_at*string | null
renewal*objectAutomatic renewal (Stripe subscription): renews_at / ends_at, cancel or resume (POST /billing/subscription).
renewal.auto*boolean
renewal.status*string | nullCurrent status.
renewal.can_cancel*booleanactive | past_due | cancel_at_period_end | none
renewal.can_resume*boolean
renewal.renews_at*string | null
renewal.ends_at*string | null
brand_names*any[]«Delete account» accepts any of these (or the email) as the typed confirmation.
json
{
  "email": "",
  "phone": "",
  "sms_notifications": false,
  "email_notifications": {
    "reminders": false,
    "report_ready": false,
    "renewal": false
  },
  "plan": "paid",
  "billing_period": "",
  "plan_expires_at": "",
  "payments": [
    {
      "id": 0,
      "period": "",
      "status": "",
      "base_amount": 0,
      "period_discount": 0,
      "code_discount": 0,
      "vat": 0,
      "total": 0,
      "currency": "",
      "tracking_code": "",
      "gateway_message": "",
      "gateway_name": "",
      "period_start": "",
      "period_end": "",
      "paid_at": "",
      "created_at": "",
      "auto_renew": false,
      "renewal_amount": 0,
      "amount_refunded": 0,
      "refunded_at": ""
    }
  ],
  "renewal": {
    "auto": false,
    "status": "",
    "can_cancel": false,
    "can_resume": false,
    "renews_at": "",
    "ends_at": ""
  },
  "brand_names": [
    null
  ]
}

401 — Missing/invalid token, or a token of the wrong owner (admin token on a user route or vice versa): {"message":"…","code":"unauthenticated"} (message in the request language)

فیلدنوع
message*string
codestring
json
{
  "message": "Please sign in to continue; your session has ended or is not valid.",
  "code": "unauthenticated"
}

409 — No subscription that still renews: {"message":"…","code":"no_subscription"}

فیلدنوع
messagestring
requires_confirmation*boolean
reasonstring
questions_countinteger
changesobject[]
changes[].fieldstring
changes[].fromany
changes[].toany
json
{
  "message": "",
  "requires_confirmation": true,
  "reason": "",
  "questions_count": 0,
  "changes": [
    {
      "field": "",
      "from": null,
      "to": null
    }
  ]
}

422 — Stripe refused: {"message":"…","code":"gateway_error"}

فیلدنوع
message*string
errors*object
json
{
  "message": "",
  "errors": {
    "email": [
      "ایمیل معتبر نیست."
    ]
  }
}

429 — Throttle 10 req/min

فیلدنوعتوضیح
message*string
resend_inintegerSeconds until a new login code may be requested (login-code cooldown only).
json
{
  "message": "Too Many Attempts.",
  "resend_in": 0
}

نمونهٔ curl

bash
curl -X POST 'http://127.0.0.1:8010/api/billing/subscription/cancel' \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $RAWI_USER_TOKEN"

امتحان در کنسول