Midtrans / midtrans-nodejs-client

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

Override Notification Url doesn't work #27

Closed cahyonobagus closed 3 years ago

cahyonobagus commented 3 years ago

Module Version: midtrans-client@1.2.2

What's the problem?

I can not override the notification URL with the module this way:

MidtransClient.httpClient.http_client.defaults.headers.common['X-Override-Notification'] = 'https://example.com/notifications'

The notification is always sent to the URL described on the Midtrans dashboard (SETTINGS > CONFIGURATION)

Expected Condition

If 'X-Override-Notification' is used, then the notification should be sent to the new URL.

Possible Causes

Method request on the Class HttpClient always uses Axios instead of using http_client from the constructor. So when I add headers with MidtransClient.httpClient.http_client.defaults.headers.common['X-Override-Notification'], It does not give any effect.

Solution

Use http_client from the constructor.

rizdaprasetya commented 3 years ago

Very nice, thanks for catching the issue and submitting the detailed analysis & fix on this PR. Great write up. Looks good, will be merged and released as new version soon.

Thanks for contributing 😃

rizdaprasetya commented 3 years ago

Done NPM released as version 1.2.3 just now. Thanks!