Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WHMCS integration isn't working after latest update #4

Open
iamfasal opened this issue Nov 28, 2019 · 15 comments
Open

WHMCS integration isn't working after latest update #4

iamfasal opened this issue Nov 28, 2019 · 15 comments
Assignees

Comments

@iamfasal
Copy link

Hello Guys,

We had an integration between WHMCS and RocketChat to alert whenever an even occur on it. This isn't working after updating to the latest 2.3.0 version for some reason. The calls are coming from the WHMCS module same as before, however, the RocketChat always throwing "400 Bad Request" to those calls. Was there anything changed on this webhook treating part?

This is the RC log:

I20191127-19:46:28.243(5.5) API ➔ debug POST: /hooks/Z69xeq/iRRnsHBg3QvvsBG229jJv25ZAwPrMJAC678jP5 I20191127-19:46:28.246(5.5) Integrations ➔ Incoming WebHook.info Post integration: Orders I20191127-19:46:28.248(5.5) Integrations ➔ Incoming WebHook.debug @urlParams: { integrationId: 'Z69xeq', token: 'iRRnsHBg3QvvsBG229jJv25ZAwPrMJAC678jP5' } I20191127-19:46:28.250(5.5) Integrations ➔ Incoming WebHook.debug @bodyParams: { text: '[Order #690751](https://DOMAIN/admin/orders.php?action=view&id=22) <br> A new order has been accepted.', attachments: [ { title: 'Client', text: 'XXXXX', title_link: 'https://DOMAIN/admin/clientssummary.php?userid=20' }, { title: 'Amount', text: '$1.00 USD', title_link: '' }, { title: 'Invoice #', text: '14', title_link: 'https://DOMAIN/admin/invoices.php?action=edit&id=14' }, { title: 'Payment Method', text: 'PayPal', title_link: '' }, { title: 'Status', text: 'Active', title_link: '' } ] } I20191127-19:46:28.257(5.5) API ➔ debug Failure { statusCode: 400, body: { success: false, error: 'Invalid href value provided', stack: undefined } }

This is the error I'm getting on WHMCS:

GuzzleHttp\Exception\ClientException: Client error: POST https://CHAT>DOMAIN/hooks/Z69xeq/iRRnsHBg3QvvsBG229jJv25ZAwPrMJAC678jP5 resulted in a 400 Bad Request response:
{"success":false,"error":"Invalid href value provided"}

Can you please shed some light on this to resolve? This is a crucial integration part for us.

Thanks :)

@digitalsparky digitalsparky self-assigned this Nov 28, 2019
@digitalsparky
Copy link
Owner

Can you try this patch, looks like it's not liking the title_link in attachments that are blank, so it makes it optional.

https://github.com/digitalsparky/rocketchat-whmcs/blob/ISSUE-4/RocketChat.php

@iamfasal
Copy link
Author

Thanks for the patch, but unfortunately that didn't sort the issue :(

[WHMCS Application] ERROR: GuzzleHttp\Exception\ClientException: Client error: POST https://CHAT.DOMAIN/hooks/6tb3eepi/mQF2rbswqW533C6FzJedQuR48y5RbDAdKD resulted in a 400 Bad Request response: {"success":false,"error":"Invalid href value provided"} in /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() #4 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true) #5 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn() #6 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending() #7 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList() #8 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending() #9 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Client.php(131): GuzzleHttp\Promise\Promise->wait() #10 /home/xxxx/public_html/modules/notifications/RocketChat/RocketChat.php(75): GuzzleHttp\Client->request('POST', 'https://ch...', Array) #11 /home/xxxx/public_html/vendor/whmcs/whmcs-foundation/lib/Notification/Rule.php(0): WHMCS\Module\Notification\RocketChat\RocketChat->sendNotification(Object(WHMCS\Notification\Notification), Array, Array) #12 /home/xxxx/public_html/vendor/whmcs/whmcs-foundation/lib/Notification/Events.php(0): WHMCS\Notification\Rule->triggerNotification(Object(WHMCS\Notification\Notification)) #13 /home/xxxx/public_html/vendor/whmcs/whmcs-foundation/lib/Notification/Events.php(0): WHMCS\Notification\Events::trigger('Ticket', 'opened', Array) #14 /home/xxxx/public_html/includes/hookfunctions.php(0): WHMCS\Notification\Events::WHMCS\Notification{closure}(Array) #15 /home/xxxx/public_html/includes/ticketfunctions.php(0): run_hook('TicketOpen', Array) #16 /home/xxxx/public_html/includes/ticketfunctions.php(0): openNewTicket('0', '0', 1, 'Test ticket', 'Test ticket', 'Medium', false, Array, '', '', '', '', false) #17 /home/xxxx/public_html/whmcsdata/crons/pipe.php(0): processPipedTicket('supt@ser...', 'Fasal ', 'fasal.offi...', 'Test ticket', 'Test ticket', false, Array) #18 {main} {"exception":"[object] (GuzzleHttp\Exception\ClientException(code: 400): Client error: POST https://CHAT.DOMAIN/hooks/6tb3eepipL/mQF2rbswqW533C6FzJedQuR48y5RbDAd resulted in a 400 Bad Request response:\n{"success":false,"error":"Invalid href value provided"}\n at /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)"} []

Can you please shed some light on this further there?

@digitalsparky
Copy link
Owner

Ok, no worries, I'll have a look to see where things are going awry in a test instance - looks like the actual inbound hook is requiring some data that's not being provided. It's probable that attachments with no custom links would need to default to the main link for the notification - theoretically, that should work...

@digitalsparky
Copy link
Owner

I've made another quick change that will change the title_link to the notification link by default, which theoretically should make it happier as it'll be providing a title link regardless.

@iamfasal
Copy link
Author

I will test and let you know shortly. Thanks for your efforts! :)

@iamfasal
Copy link
Author

iamfasal commented Nov 29, 2019

@digitalsparky I just tested that new patch, but that isn't parsing correctly and getting 500 error on Notification page for me here so I reverted it back. Looks like there is a syntax error on the new patch file RocketChat.php

php -l RocketChat.php
Errors parsing RocketChat.php

I'm not good at PHP coding, however, had a quick overview and seems like 65th and 66th line is causing the issue since "'title_link' =" actually would be "'title_link' =>" and the square bracket isn't closed that might have causing this situation. :\

@digitalsparky
Copy link
Owner

Oops, sorry, try now.

@iamfasal
Copy link
Author

Thanks for sorting out the syntax, however, the initial issue persists. I'm getting below error when open a ticket or placing orders:

[WHMCS Application] ERROR: GuzzleHttp\Exception\ClientException: Client error: POST https://CHAT.DOMAIN/hooks/6tb3eepi/mQF2rbswqW533C6FzJedQuR48y5RbDAdKD resulted in a 400 Bad Request response: {"success":false,"error":"Invalid href value provided"} in /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() #4 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true) #5 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn() #6 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending() #7 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList() #8 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending() #9 /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Client.php(131): GuzzleHttp\Promise\Promise->wait() #10 /home/xxxx/public_html/modules/notifications/RocketChat/RocketChat.php(75): GuzzleHttp\Client->request('POST', 'https://ch...', Array) #11 /home/xxxx/public_html/vendor/whmcs/whmcs-foundation/lib/Notification/Rule.php(0): WHMCS\Module\Notification\RocketChat\RocketChat->sendNotification(Object(WHMCS\Notification\Notification), Array, Array) #12 /home/xxxx/public_html/vendor/whmcs/whmcs-foundation/lib/Notification/Events.php(0): WHMCS\Notification\Rule->triggerNotification(Object(WHMCS\Notification\Notification)) #13 /home/xxxx/public_html/vendor/whmcs/whmcs-foundation/lib/Notification/Events.php(0): WHMCS\Notification\Events::trigger('Ticket', 'opened', Array) #14 /home/xxxx/public_html/includes/hookfunctions.php(0): WHMCS\Notification\Events::WHMCS\Notification{closure}(Array) #15 /home/xxxx/public_html/includes/ticketfunctions.php(0): run_hook('TicketOpen', Array) #16 /home/xxxx/public_html/includes/ticketfunctions.php(0): openNewTicket('0', '0', 1, 'Test ticket', 'Test ticket', 'Medium', false, Array, '', '', '', '', false) #17 /home/xxxx/public_html/whmcsdata/crons/pipe.php(0): processPipedTicket('supt@ser...', 'Fasal ', 'fasal.offi...', 'Test ticket', 'Test ticket', false, Array) #18 {main} {"exception":"[object] (GuzzleHttp\Exception\ClientException(code: 400): Client error: POST https://CHAT.DOMAIN/hooks/6tb3eepipL/mQF2rbswqW533C6FzJedQuR48y5RbDAd resulted in a 400 Bad Request response:\n{"success":false,"error":"Invalid href value provided"}\n at /home/xxxx/public_html/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)"} []

Not sure of the cause :(

@digitalsparky
Copy link
Owner

ugh, okay, bare with me, I'm going to stand up a staging system and I'll try and figure this out.

@iamfasal
Copy link
Author

Thanks Matt for your excellent assistance, much appreciated! :)

@iamfasal
Copy link
Author

iamfasal commented Dec 2, 2019

Any update on this Matt? :)

@digitalsparky
Copy link
Owner

Hi @fasalsh

I've setup a dev environment and tested, I was able to replicate the issue, however once I set the systemurl for WHMCS that issue went away and all was working fine.

It relies on being able to post a static URL, so it uses the System URL defined in settings -> general to assemble that URL.

If it doesn't have a System URL then it'll error out because the only part of the link it has to work with is the path.

Can you check your system to make sure you've got that setting configured including http:// or https:// at the start.

Cheers

@iamfasal
Copy link
Author

iamfasal commented Dec 6, 2019

Hi @digitalsparky

The system URL is already set correctly on our WHMCS, so that isn't the case in our case. The below are the package versions in use on our server:

RocketChat: 2.3.0
Node: 8.15.1
NPM: 6.9.0
PHP: 7.2
WHMCS: 7.8.3

Does any of the above will conflict with this module system? I can see a POST text is appending in front of the hook call, that could've causing this situation but not sure.

[WHMCS Application] ERROR: GuzzleHttp\Exception\ClientException: Client error: POST https://CHAT.DOMAIN/hooks/6tb3eepipLsk/mQF2rbswqW533C6FzJedQuR48y5RbDAdKDj9qybELRyat resulted in a 400 Bad Request response: {"success":false,"error":"Invalid href value provided"} in /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() #4 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true) #5 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn() #6 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending() #7 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList() #8 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending() #9 /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Client.php(131): GuzzleHttp\Promise\Promise->wait() #10 /home/xxxx/modules/notifications/RocketChat/RocketChat.php(73): GuzzleHttp\Client->request('POST', 'https://chat.do...', Array) #11 /home/xxxx/vendor/whmcs/whmcs-foundation/lib/Notification/Rule.php(0): WHMCS\Module\Notification\RocketChat\RocketChat->sendNotification(Object(WHMCS\Notification\Notification), Array, Array) #12 /home/xxxx/vendor/whmcs/whmcs-foundation/lib/Notification/Events.php(0): WHMCS\Notification\Rule->triggerNotification(Object(WHMCS\Notification\Notification)) #13 /home/xxxx/vendor/whmcs/whmcs-foundation/lib/Notification/Events.php(0): WHMCS\Notification\Events::trigger('Ticket', 'opened', Array) #14 /home/xxxx/includes/hookfunctions.php(0): WHMCS\Notification\Events::WHMCS\Notification{closure}(Array) #15 /home/xxxx/includes/ticketfunctions.php(0): run_hook('TicketOpen', Array) #16 /home/xxxx/includes/ticketfunctions.php(0): openNewTicket('0', '0', 2, 'Test Ignore', 'Test. Ignore.\n\n...', 'Medium', false, Array, '', '', '', '', false) #17 /home/xxxx/sh-whmcsdata/crons/pipe.php(0): processPipedTicket('sales@doma...', 'TEST ', 'official.test...', 'Test Ignore', 'Test. Ignore.\n\n...', false, Array) #18 {main} {"exception":"[object] (GuzzleHttp\Exception\ClientException(code: 400): Client error: POST https://CHAT.DOMAIN/hooks/6tb3eepipLsk/mQF2rbswqW533C6FzJedQuR48y5RbDAdKDj9qybELRyat resulted in a 400 Bad Request response:\n{"success":false,"error":"Invalid href value provided"}\n at /home/xxxx/modules/notifications/RocketChat/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)"} []

Please review and let me know if require any further details.

Thanks :)

@digitalsparky
Copy link
Owner

Hey folks, sorry for the delay, I've been preoccupied with other things. I'll look at this again shortly. I do have both WHMCS and RocketChat installed locally for testing, so I hope I'll be able to come up with a solution sooner rather than later.

It is rather odd though as all the documentation looks to be correct, unless RC has a bug in it resulting in the error.

@evgenijtrapecija
Copy link

Hello, do you have any news about this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants