//native
type Zoho = {
token: string;
};
/**
* Update customer payment details
* Create a Hosted Payment Page to update customers card, bank account (ACH) or PayPal details
*/
export async function main(
auth: Zoho,
X_com_zoho_subscriptions_organizationid: string,
body: { card_id: string; account_id: string; paypal_id: string },
) {
const url = new URL(
`https://www.zohoapis.com/billing/v1/hostedpages/updatepaymentmethod`,
);
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