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

WebhookNotification object payload parsed incorrectly #86

Open
soundsgoodsofar opened this issue May 28, 2021 · 1 comment
Open

WebhookNotification object payload parsed incorrectly #86

soundsgoodsofar opened this issue May 28, 2021 · 1 comment

Comments

@soundsgoodsofar
Copy link

I'm using version 1.6.3 of the SDK

The constructor of WebhookNotification.php appears to parse the object payload incorrectly for a number of webhooks.

It assumes that any webhook type starting with 'USER' will have an object of type User. This appears to be incorrect for webhooks for different payment method events.

For example, for a webhook of type USERS.VENMO_ACCOUNTS.CREATED, I get an object with the following structure:

‌‌print_r($properties['object'], true);
‌Array
(
    [token] => trm-REDACTED
    [type] => VENMO_ACCOUNT
    [status] => ACTIVATED
    [createdOn] => 2021-05-28T15:36:53
    [transferMethodCountry] => US
    [transferMethodCurrency] => USD
    [accountId] => REDACTED
    [userToken] => usr-REDACTED
)
@soundsgoodsofar
Copy link
Author

soundsgoodsofar commented May 28, 2021

I haven't verified the payload for all of these webhooks yet (just venmo), but I believe this would be the fix:

Change this section in WebhookNotification.php from:

} else if (strpos($properties['type'], 'USERS') === 0) {
    $this->object = new User($properties['object']);
}

to this:

} else if (strpos($properties['type'], 'USERS.BANK_ACCOUNTS') === 0) {
    $this->object = new BankAccount($properties['object']);
} else if (strpos($properties['type'], 'USERS.PAYPAL_ACCOUNTS') === 0) {
    $this->object = new PaypalAccount($properties['object']);
} else if (strpos($properties['type'], 'USERS.VENMO_ACCOUNTS') === 0) {
    $this->object = new VenmoAccount($properties['object']);
} else if (strpos($properties['type'], 'USERS') === 0) {
    $this->object = new User($properties['object']);
}

Looks like of those, BankAccounts is already parsed correctly actually.

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

1 participant