//native
type Zoho = {
token: string;
};
/**
* Buy one-time addon for a subscription
* Create hosted page for buying a one-time addon for a subscription.
*/
export async function main(
auth: Zoho,
X_com_zoho_subscriptions_organizationid: string,
body: {
subscription_id: string;
addons: {
addon_code: string;
quantity?: number;
tags?: { tag_id?: number; tag_option_id?: number }[];
item_custom_fields?: { label?: string; value?: string }[];
price?: number;
tax_id: {};
tax_exemption_id?: string;
tax_exemption_code?: string;
product_type?: string;
}[];
redirect_url?: string;
coupon_code?: {};
cfdi_usage?: string;
exchange_rate?: never;
payment_gateways?: { payment_gateway?: string }[];
},
) {
const url = new URL(
`https://www.zohoapis.com/billing/v1/hostedpages/buyonetimeaddon`,
);
const response = await fetch(url, {
method: "POST",
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