fix(server): respond stripe webhook immediately
This commit is contained in:
@@ -64,9 +64,14 @@ export class StripeWebhook {
|
|||||||
`[${event.id}] Stripe Webhook {${event.type}} received.`
|
`[${event.id}] Stripe Webhook {${event.type}} received.`
|
||||||
);
|
);
|
||||||
|
|
||||||
// handle duplicated events?
|
// Stripe requires responseing webhook immediately and handle event asynchronously.
|
||||||
// see https://stripe.com/docs/webhooks#handle-duplicate-events
|
setImmediate(() => {
|
||||||
await this.event.emitAsync(event.type, event.data.object);
|
// handle duplicated events?
|
||||||
|
// see https://stripe.com/docs/webhooks#handle-duplicate-events
|
||||||
|
this.event.emitAsync(event.type, event.data.object).catch(e => {
|
||||||
|
this.logger.error('Failed to handle Stripe Webhook event.', e);
|
||||||
|
});
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error('Stripe Webhook error', err);
|
this.logger.error('Stripe Webhook error', err);
|
||||||
throw new NotAcceptableException();
|
throw new NotAcceptableException();
|
||||||
|
|||||||
Reference in New Issue
Block a user