capture cancellation reason/comment, add callback docs

This commit is contained in:
Shawn Erquhart
2025-03-03 12:06:13 -05:00
parent cf207e45a4
commit cc884fdde6
4 changed files with 50 additions and 0 deletions

View File

@@ -6,6 +6,26 @@ const http = httpRouter();
polar.registerRoutes(http, {
// Optional custom path, default is "/events/polar"
path: "/events/polar",
// Optional callback for when a subscription is updated
onSubscriptionUpdated: async (ctx, event) => {
console.log("Subscription updated", event);
if (event.data.customerCancellationReason) {
console.log(
"Customer cancellation reason",
event.data.customerCancellationReason
);
console.log(
"Customer cancellation comment",
event.data.customerCancellationComment
);
}
// This callback is run in an Action, so you could pipe this customer
// cancellation reason to another service, for example.
},
// Other available callbacks:
onSubscriptionCreated: undefined,
onProductCreated: undefined,
onProductUpdated: undefined,
});
export default http;