respond 200 to valid but unsupported paddle webhooks
This commit is contained in:
parent
cc4390d050
commit
3edf0cb471
@ -6,7 +6,7 @@ import type {
|
|||||||
PaddleSdkSubscriptionPaymentSucceededEvent,
|
PaddleSdkSubscriptionPaymentSucceededEvent,
|
||||||
PaddleSdkSubscriptionUpdatedEvent,
|
PaddleSdkSubscriptionUpdatedEvent,
|
||||||
} from "@devoxa/paddle-sdk";
|
} from "@devoxa/paddle-sdk";
|
||||||
import { PaddleSdkWebhookEventType } from "@devoxa/paddle-sdk";
|
import { PaddleSdkException, PaddleSdkWebhookEventType } from "@devoxa/paddle-sdk";
|
||||||
|
|
||||||
import type { ApiError } from "app/core/types";
|
import type { ApiError } from "app/core/types";
|
||||||
import subscriptionCreatedQueue from "../queue/subscription-created";
|
import subscriptionCreatedQueue from "../queue/subscription-created";
|
||||||
@ -47,6 +47,7 @@ const webhook: BlitzApiHandler = async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const event = paddleSdk.parseWebhookEvent(req.body);
|
const event = paddleSdk.parseWebhookEvent(req.body);
|
||||||
const alertName = event.eventType;
|
const alertName = event.eventType;
|
||||||
logger.info(`Received ${alertName} webhook`);
|
logger.info(`Received ${alertName} webhook`);
|
||||||
@ -58,6 +59,14 @@ const webhook: BlitzApiHandler = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return res.status(400).end();
|
return res.status(400).end();
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof PaddleSdkException && error.message.includes(req.body.alert_name)) {
|
||||||
|
// event implementation is missing such as `subscription_payment_refunded`
|
||||||
|
return res.status(200).end();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default webhook;
|
export default webhook;
|
||||||
|
Loading…
Reference in New Issue
Block a user