Subscriptions
Change Plan
Modify an existing subscription’s plan, enabling both upgrades and downgrades to different pricing tiers.
Note: This will use the existing payment information of the customer to upgrade/downgrade the plan.
POST
/
subscriptions
/
{subscription_id}
/
change-plan
JavaScript
import DodoPayments from 'dodopayments';
const client = new DodoPayments({
bearerToken: 'My Bearer Token',
});
await client.subscriptions.changePlan('subscription_id', {
product_id: 'product_id',
proration_billing_mode: 'prorated_immediately',
quantity: 0,
});from dodopayments import DodoPayments
client = DodoPayments(
bearer_token="My Bearer Token",
)
client.subscriptions.change_plan(
subscription_id="subscription_id",
product_id="product_id",
proration_billing_mode="prorated_immediately",
quantity=0,
)package main
import (
"context"
"github.com/dodopayments/dodopayments-go"
"github.com/dodopayments/dodopayments-go/option"
)
func main() {
client := dodopayments.NewClient(
option.WithBearerToken("My Bearer Token"),
)
err := client.Subscriptions.ChangePlan(
context.TODO(),
"subscription_id",
dodopayments.SubscriptionChangePlanParams{
ProductID: dodopayments.F("product_id"),
ProrationBillingMode: dodopayments.F(dodopayments.SubscriptionChangePlanParamsProrationBillingModeProratedImmediately),
Quantity: dodopayments.F(int64(0)),
},
)
if err != nil {
panic(err.Error())
}
}
package com.dodopayments.api.example;
import com.dodopayments.api.client.DodoPaymentsClient;
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
import com.dodopayments.api.models.subscriptions.SubscriptionChangePlanParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();
SubscriptionChangePlanParams params = SubscriptionChangePlanParams.builder()
.subscriptionId("subscription_id")
.productId("product_id")
.prorationBillingMode(SubscriptionChangePlanParams.ProrationBillingMode.PRORATED_IMMEDIATELY)
.quantity(0)
.build();
client.subscriptions().changePlan(params);
}
}package com.dodopayments.api.example
import com.dodopayments.api.client.DodoPaymentsClient
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
import com.dodopayments.api.models.subscriptions.SubscriptionChangePlanParams
fun main() {
val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()
val params: SubscriptionChangePlanParams = SubscriptionChangePlanParams.builder()
.subscriptionId("subscription_id")
.productId("product_id")
.prorationBillingMode(SubscriptionChangePlanParams.ProrationBillingMode.PRORATED_IMMEDIATELY)
.quantity(0)
.build()
client.subscriptions().changePlan(params)
}require "dodopayments"
dodo_payments = Dodopayments::Client.new(
bearer_token: "My Bearer Token",
environment: "test_mode" # defaults to "live_mode"
)
result = dodo_payments.subscriptions.change_plan(
"subscription_id",
product_id: "product_id",
proration_billing_mode: :prorated_immediately,
quantity: 0
)
puts(result)curl --request POST \
--url https://test.dodopayments.com/subscriptions/{subscription_id}/change-plan \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"product_id": "<string>",
"quantity": 1,
"addons": [
{
"addon_id": "<string>",
"quantity": 1
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://test.dodopayments.com/subscriptions/{subscription_id}/change-plan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'product_id' => '<string>',
'quantity' => 1,
'addons' => [
[
'addon_id' => '<string>',
'quantity' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Subscription Id
Body
application/json
Unique identifier of the product to subscribe to
Proration Billing Mode
Available options:
prorated_immediately, full_immediately, difference_immediately Number of units to subscribe for. Must be at least 1.
Required range:
x >= 0Addons for the new plan. Note : Leaving this empty would remove any existing addons
Show child attributes
Show child attributes
Response
Subscription plan changed
Was this page helpful?
⌘I
JavaScript
import DodoPayments from 'dodopayments';
const client = new DodoPayments({
bearerToken: 'My Bearer Token',
});
await client.subscriptions.changePlan('subscription_id', {
product_id: 'product_id',
proration_billing_mode: 'prorated_immediately',
quantity: 0,
});from dodopayments import DodoPayments
client = DodoPayments(
bearer_token="My Bearer Token",
)
client.subscriptions.change_plan(
subscription_id="subscription_id",
product_id="product_id",
proration_billing_mode="prorated_immediately",
quantity=0,
)package main
import (
"context"
"github.com/dodopayments/dodopayments-go"
"github.com/dodopayments/dodopayments-go/option"
)
func main() {
client := dodopayments.NewClient(
option.WithBearerToken("My Bearer Token"),
)
err := client.Subscriptions.ChangePlan(
context.TODO(),
"subscription_id",
dodopayments.SubscriptionChangePlanParams{
ProductID: dodopayments.F("product_id"),
ProrationBillingMode: dodopayments.F(dodopayments.SubscriptionChangePlanParamsProrationBillingModeProratedImmediately),
Quantity: dodopayments.F(int64(0)),
},
)
if err != nil {
panic(err.Error())
}
}
package com.dodopayments.api.example;
import com.dodopayments.api.client.DodoPaymentsClient;
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
import com.dodopayments.api.models.subscriptions.SubscriptionChangePlanParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();
SubscriptionChangePlanParams params = SubscriptionChangePlanParams.builder()
.subscriptionId("subscription_id")
.productId("product_id")
.prorationBillingMode(SubscriptionChangePlanParams.ProrationBillingMode.PRORATED_IMMEDIATELY)
.quantity(0)
.build();
client.subscriptions().changePlan(params);
}
}package com.dodopayments.api.example
import com.dodopayments.api.client.DodoPaymentsClient
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
import com.dodopayments.api.models.subscriptions.SubscriptionChangePlanParams
fun main() {
val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()
val params: SubscriptionChangePlanParams = SubscriptionChangePlanParams.builder()
.subscriptionId("subscription_id")
.productId("product_id")
.prorationBillingMode(SubscriptionChangePlanParams.ProrationBillingMode.PRORATED_IMMEDIATELY)
.quantity(0)
.build()
client.subscriptions().changePlan(params)
}require "dodopayments"
dodo_payments = Dodopayments::Client.new(
bearer_token: "My Bearer Token",
environment: "test_mode" # defaults to "live_mode"
)
result = dodo_payments.subscriptions.change_plan(
"subscription_id",
product_id: "product_id",
proration_billing_mode: :prorated_immediately,
quantity: 0
)
puts(result)curl --request POST \
--url https://test.dodopayments.com/subscriptions/{subscription_id}/change-plan \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"product_id": "<string>",
"quantity": 1,
"addons": [
{
"addon_id": "<string>",
"quantity": 1
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://test.dodopayments.com/subscriptions/{subscription_id}/change-plan",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'product_id' => '<string>',
'quantity' => 1,
'addons' => [
[
'addon_id' => '<string>',
'quantity' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}