-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
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);
Metadata
Metadata
Assignees
Labels
No labels