mirror of
https://github.com/LukeHagar/polar.git
synced 2025-12-06 04:20:58 +00:00
capture cancellation reason/comment, add callback docs
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user