MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / cancelSubscription

Function cancelSubscription

packages/payments/src/polar.ts:79–97  ·  view source on GitHub ↗
(subscriptionId: string)

Source from the content-addressed store, hash-verified

77}
78
79export async function cancelSubscription(subscriptionId: string) {
80 try {
81 return await polar.subscriptions.update({
82 id: subscriptionId,
83 subscriptionUpdate: {
84 cancelAtPeriodEnd: true,
85 },
86 });
87 } catch (error) {
88 if (error instanceof Error) {
89 // Don't throw an error if the subscription is already canceled
90 if (error.name === 'AlreadyCanceledSubscription') {
91 return polar.subscriptions.get({ id: subscriptionId });
92 }
93 }
94
95 throw error;
96 }
97}
98
99export function reactivateSubscription(subscriptionId: string) {
100 return polar.subscriptions.update({

Callers 1

subscription.tsFile · 0.90

Calls 1

getMethod · 0.45

Tested by

no test coverage detected