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

Webhook for multiple organisations #824

Open
gitstashgithub opened this issue Sep 22, 2021 · 3 comments
Open

Webhook for multiple organisations #824

gitstashgithub opened this issue Sep 22, 2021 · 3 comments

Comments

@gitstashgithub
Copy link

Hi guys,

I have a question about webhook. If our app is authorised for multiple Xero organisations, how do we make webhook work?
Below is the Webhook example from the document, you can see the first parameter for Webhook is XeroPHP\Application.

// Configure the webhook signing key on the application
$application->setConfig(['webhook' => ['signing_key' => 'xyz123']]);
$webhook = new Webhook($application, $request->getContent());

/**
 * @return int
 */
$webhook->getFirstEventSequence();

/**
 * @return int
 */
$webhook->getLastEventSequence();

/**
 * @return \XeroPHP\Webhook\Event[]
 */
$webhook->getEvents();

However, to initialise the XeroPHP\Application variable, we need $tenantId.

$application = new \XeroPHP\Application($accessToken, $tenantId);

The problem is, there are multiple tenants(organisations), so we don't know the $tenantId.

Does anyone know how to make it work? Thanks!

Gordon

@rodjsta
Copy link

rodjsta commented Sep 22, 2021

The JSON Payload contains the tenantId
image

getEvents() will return you an array of Event classes. Each Event will have the tenantId and other information as per the incoming JSON.

@gitstashgithub
Copy link
Author

@rodjsta thanks, but the problem is before this stage.
You need $webhook to run getEvents().
To create $webhook, you need a XeroPHP\Application instance.
To initialise a XeroPHP\Application instance, you need tenantId.

@rodjsta
Copy link

rodjsta commented Sep 22, 2021

@gitstashgithub, right... I see. Sorry, I actually handle my webhook events independent of this package. I essentially capture each event from the payload and process them separately.

https://medium.com/swlh/handling-xero-webhooks-with-a-laravel-application-61eefd4492c4

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

2 participants