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

Webhooks Testing Gives Errors #37

Open
ParadiseStudios opened this issue Feb 21, 2018 · 0 comments · May be fixed by #50
Open

Webhooks Testing Gives Errors #37

ParadiseStudios opened this issue Feb 21, 2018 · 0 comments · May be fixed by #50

Comments

@ParadiseStudios
Copy link

Assumes:
Omnipay is setup correctly.
Omnipay makes a successful transaction to Braintree.
MerchantID, PublicKey & PrivateKey are set correctly.

$sampleNotificationSignature = 'WITHHELD';
$sampleNotificationPayload = 'WITHHELD';
use Omnipay\Omnipay;
$gateway = Omnipay::create('Braintree');
$gateway->setPrivateKey('WITHHELD');
$gateway->setPublicKey('WITHHELD');
$gateway->setMerchantId('WITHHELD');
$gateway->setTestMode(TRUE);
$notification = $gateway->parseNotification([
    'bt_signature'  => $sampleNotificationSignature,
    'bt_payload'    => $sampleNotificationPayload
])->send();

When trying to test WebHooks from Braintree, POST from the test url results in the following errors...

Fatal error: Uncaught Braintree\Exception\Configuration: Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway). in /vendor/braintree/braintree_php/lib/Braintree/Configuration.php:254

Stack trace:
#0 /vendor/braintree/braintree_php/lib/Braintree/WebhookNotificationGateway.php(10): Braintree\Configuration->assertHasAccessTokenOrKeys()
#1 /vendor/braintree/braintree_php/lib/Braintree/Gateway.php(257): Braintree\WebhookNotificationGateway->__construct(Object(Braintree\Gateway))
#2 /vendor/braintree/braintree_php/lib/Braintree/WebhookNotification.php(35): Braintree\Gateway->webhookNotification()
#3 /vendor/omnipay/braintree/src/Gateway.php(281): Braintree\WebhookNotification::parse('DETAILS HIDDEN')
#4 braintree.php(27 in /vendor/braintree/braintree_php/lib/Braintree/Configuration.php on line 254

I believe this must be an error in omnipay's code. I see no reason why this would fail when transactions, customer creation, payments and charges all post fine when submitting the shopping cart. I've created an issue for it on Stackoverflow.

https://stackoverflow.com/questions/48843652/omnipay-braintree-webhooks-testing-gives-errors

The code below works, essentially overriding omnipay and using braintree_php directly.

use Braintree_Gateway;
use Braintree_Configuration;
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('PRIVATE');
Braintree_Configuration::publicKey('PRIVATE');
Braintree_Configuration::privateKey('PRIVATE');

$sampleNotification = Braintree_WebhookTesting::sampleNotification(
    Braintree_WebhookNotification::SUBSCRIPTION_WENT_PAST_DUE,
    'my_id'
);

$webhookNotification = Braintree_WebhookNotification::parse(
    $sampleNotification['bt_signature'],
    $sampleNotification['bt_payload']
);

$webhookNotification->subscription->id;

print_r($webhookNotification);
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

Successfully merging a pull request may close this issue.

1 participant