braintree_php: Configuration::$global singleton is empty

General information

  • SDK/Library version: 3.29.0
  • Environment: both
  • Language, language version, and OS: PHP

Issue description


$config = new Configuration([
	'environment' => $environment,
	'merchantId' => $merchant_id,
	'publicKey' => $public_key,
	'privateKey' => $private_key,
]);

$gateway = new Gateway($config);

// throws InvalidSignature exception, because it can't find the public key
// WebhookNotificationGateway::_matchingSignature is calling $this->config->publicKey()
// which reads it from Configuration::$global, which is not set anywhere
$gateway->webhookNotification()->parse($signature, $payload);

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

Why i said don’t use test sample notification because

private function _matchingSignature($signaturePairs)
{
    foreach ($signaturePairs as $pair)
    {
        $components = preg_split("/\|/", $pair);
        if ($components[0] == $this->config->publicKey()) {
            return $components[1];
        }
    }

    return null;
}

From test you will get empty public key (at 0 index in $components variable). and because $global is empty, when you compare it with $this->config->publicKey() it also return empty value… so your condition will be true

@hypeJunction !

We just release v3.33.0 that includes the fix for WebhookNotificationGateway that uses proper config object to fetch the public key, and private key. Please re-open the issue if you are still having problems. Thank you.

Hey @hypeJunction !

We just released v3.30.0. If you can check with that version and let us know if you are running into the same issue or not.

Thanks.

I used the mock you posted above and it worked fine. I am debugging now to see why it’s failing with an actual test http requrest from braintree.