Braintree\Util::verifyKeys PHP Method

verifyKeys() public static method

compares the expected signature of a gateway request against the actual structure sent by the user
public static verifyKeys ( array $signature, array $attributes )
$signature array
$attributes array
    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);
        }
    }

Usage Example

 public function update($subscriptionId, $attributes)
 {
     Util::verifyKeys(self::_updateSignature(), $attributes);
     $path = $this->_config->merchantPath() . '/subscriptions/' . $subscriptionId;
     $response = $this->_http->put($path, ['subscription' => $attributes]);
     return $this->_verifyGatewayResponse($response);
 }
All Usage Examples Of Braintree\Util::verifyKeys