메인 콘텐츠로 건너뛰기
POST
/
subscriptions
/
{subscription_id}
/
change-plan
JavaScript
import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
});

await client.subscriptions.changePlan('subscription_id', {
  product_id: 'product_id',
  proration_billing_mode: 'prorated_immediately',
  quantity: 0,
});

결제 실패 처리

요금제 변경 결제가 실패할 때 수행할 작업을 제어하려면 on_payment_failure 매개변수를 사용하세요:
동작
prevent_change결제가 성공할 때까지 구독을 현재 요금제에 유지합니다. 요금제 변경은 보류 상태로 유지됩니다.
apply_change결제 결과에 관계없이 즉시 요금제 변경을 적용합니다. 기본값입니다.
on_payment_failure이 지정되지 않은 경우 동작은 대시보드에서 구성된 비즈니스 수준 설정으로 기본 설정됩니다.
프리미엄 기능에 대한 액세스를 허용하기 전에 결제를 확인하려는 중요한 업그레이드에는 prevent_change을 사용하세요.

인증

Authorization
string
header
필수

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

경로 매개변수

subscription_id
string
필수

Subscription Id

본문

application/json
product_id
string
필수

Unique identifier of the product to subscribe to

proration_billing_mode
enum<string>
필수

Proration Billing Mode

사용 가능한 옵션:
prorated_immediately,
full_immediately,
difference_immediately
quantity
integer<int32>
필수

Number of units to subscribe for. Must be at least 1.

필수 범위: x >= 0
addons
Attach Addon Request · object[] | null

Addons for the new plan. Note : Leaving this empty would remove any existing addons

discount_code
string | null

Optional discount code to apply to the new plan. If provided, validates and applies the discount to the plan change. If not provided and the subscription has an existing discount with preserve_on_plan_change=true, the existing discount will be preserved (if applicable to the new product).

metadata
object

Metadata for the payment. If not passed, the metadata of the subscription will be taken

on_payment_failure
null | enum<string>

Controls behavior when the plan change payment fails.

  • prevent_change: Keep subscription on current plan until payment succeeds
  • apply_change (default): Apply plan change immediately regardless of payment outcome

If not specified, uses the business-level default setting.

사용 가능한 옵션:
prevent_change,
apply_change

응답

Subscription plan changed. If on_payment_failure=prevent_change, the plan change is pending until payment succeeds.