//native
type Zoho = {
token: string;
};
/**
* Update a plan
* Update details of an existing plan.
*/
export async function main(
auth: Zoho,
plan_code: string,
X_com_zoho_subscriptions_organizationid: string,
body: {
plan_code: string;
name: string;
recurring_price: number;
unit?: string;
interval: number;
interval_unit?: string;
billing_cycles?: number;
trial_period?: number;
setup_fee?: number;
setup_fee_account_id?: string;
tags?: { tag_id?: number; tag_option_id?: number }[];
custom_fields?: { label?: string; value?: string }[];
addons?: { addon_code?: string; name?: {} }[];
product_type?: string;
hsn_or_sac?: string;
sat_item_key_code?: string;
unitkey_code?: string;
item_tax_preferences?: {
tax_specification?: string;
tax_name?: string;
tax_percentage?: number;
tax_id?: string;
}[];
tax_id?: string;
is_taxable?: string;
tax_exemption_id?: string;
tax_exemption_code?: string;
description?: string;
store_markup_description?: string;
can_charge_setup_fee_immediately?: false | true;
},
) {
const url = new URL(`https://www.zohoapis.com/billing/v1/plans/${plan_code}`);
const response = await fetch(url, {
method: "PUT",
headers: {
"X-com-zoho-subscriptions-organizationid":
X_com_zoho_subscriptions_organizationid,
"Content-Type": "application/json",
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago