Midtrans / midtrans-nodejs-client

Official Midtrans Payment API Client for Node JS | https://midtrans.com
MIT License
180 stars 57 forks source link

How to override webhook url using library? #69

Open AhmetHuseyinDOK opened 6 months ago

AhmetHuseyinDOK commented 6 months ago

In the Midtrans documentation, it is shown that we can override the webhook url via headers, How can I achieve the same result using this library ?

https://docs.midtrans.com/docs/https-notification-webhooks#customizing-notification-url-via-api

AhmetHuseyinDOK commented 6 months ago

Ok I found a workaround,

this.snapApi.httpClient.http_client.defaults.headers.common['X-Override-Notification'] = "https://somewebhook.com/handler/ ";

But I think, it would be nice to be able to do it with an optional config like this

this.snapApi.createTransaction({
            transaction_details: {
                gross_amount: transaction.amount,
                order_id: transaction.id,
            },
            enabled_payments: ['gopay'],
            overrideNotification: 'https://somenotificatipon.com/webhookhandler/' // would be much nicer
        })