Replies: 2 comments
-
Hi, Rough sketch: import { OnVendureBootstrap, OrderStateTransitionEvent, PluginCommonModule,
VendurePlugin, EventBus } from '@vendure/core';
@VendurePlugin({
imports: [PluginCommonModule],
})
export class WebhooksPlugin implements OnVendureBootstrap {
constructor(
private workerService: WorkerService,
private eventBus: EventBus,
) {}
/**
* When the server bootstraps, set up a subscription for events
* published whenever an Order changes state.
*/
onVendureBootstrap() {
this.eventBus.ofType(OrderStateTransitionEvent).subscribe(event => {
if (event.toState === 'PaymentSettled') {
// Here you make your webhook request.
// You could even make the webhook urls configurable using
// the `init` pattern demonstrated here:
// https://github.com/vendure-ecommerce/plugin-template/blob/db7a0aa415775a8352dcb3e7d373a56e2f6cb3d6/src/plugin.ts#L51-L58
}
});
}
} |
Beta Was this translation helpful? Give feedback.
-
I have written a plugin that triggers a channel aware webhook on configurable events for my project: github source |
Beta Was this translation helpful? Give feedback.
-
Are there webhooks available in Vendure? For example, if there is a new order, can we have webhook hit an external endpoint to execute some code?
Beta Was this translation helpful? Give feedback.
All reactions