You are here

public static function Braintree_Util::verifyKeys in Commerce Braintree 7

verify user request structure

compares the expected signature of a gateway request against the actual structure sent by the user

Parameters

array $signature:

array $attributes:

19 calls to Braintree_Util::verifyKeys()
Braintree_Address::create in braintree_php/lib/Braintree/Address.php
@access public
Braintree_Address::update in braintree_php/lib/Braintree/Address.php
updates the address record
Braintree_CreditCard::create in braintree_php/lib/Braintree/CreditCard.php
Braintree_CreditCard::update in braintree_php/lib/Braintree/CreditCard.php
updates the creditcard record
Braintree_Customer::create in braintree_php/lib/Braintree/Customer.php
Creates a customer using the given +attributes+. If <tt>:id</tt> is not passed, the gateway will generate it.

... See full list

File

braintree_php/lib/Braintree/Util.php, line 191

Class

Braintree_Util
Braintree Utility methods

Code

public static function verifyKeys($signature, $attributes) {
  $validKeys = self::_flattenArray($signature);
  $userKeys = self::_flattenUserKeys($attributes);
  $invalidKeys = array_diff($userKeys, $validKeys);
  $invalidKeys = self::_removeWildcardKeys($validKeys, $invalidKeys);
  if (!empty($invalidKeys)) {
    asort($invalidKeys);
    $sortedList = join(', ', $invalidKeys);
    throw new InvalidArgumentException('invalid keys: ' . $sortedList);
  }
}