mirror of
https://github.com/LukeHagar/polar.git
synced 2025-12-06 04:20:58 +00:00
32 lines
951 B
TypeScript
32 lines
951 B
TypeScript
import { httpRouter } from "convex/server";
|
|
import { polar } from "./example";
|
|
|
|
const http = httpRouter();
|
|
|
|
polar.registerRoutes(http, {
|
|
// Optional custom path, default is "/polar/events"
|
|
path: "/polar/events",
|
|
// 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;
|