You are here

public static function Braintree_TransparentRedirect::parseAndValidateQueryString in Commerce Braintree 7

6 calls to Braintree_TransparentRedirect::parseAndValidateQueryString()
Braintree_CreditCard::createFromTransparentRedirect in braintree_php/lib/Braintree/CreditCard.php
create a customer from a TransparentRedirect operation
Braintree_CreditCard::updateFromTransparentRedirect in braintree_php/lib/Braintree/CreditCard.php
update a customer from a TransparentRedirect operation
Braintree_Customer::createFromTransparentRedirect in braintree_php/lib/Braintree/Customer.php
create a customer from a TransparentRedirect operation
Braintree_Customer::updateFromTransparentRedirect in braintree_php/lib/Braintree/Customer.php
update a customer from a TransparentRedirect operation
Braintree_Transaction::createFromTransparentRedirect in braintree_php/lib/Braintree/Transaction.php
@access public

... See full list

File

braintree_php/lib/Braintree/TransparentRedirect.php, line 247

Class

Braintree_TransparentRedirect
Static class providing methods to build Transparent Redirect urls

Code

public static function parseAndValidateQueryString($queryString) {

  // parse the params into an array
  parse_str($queryString, $params);

  // remove the hash
  $queryStringWithoutHash = null;
  if (preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) {
    $queryStringWithoutHash = $match[1];
  }
  if ($params['http_status'] != '200') {
    $message = null;
    if (array_key_exists('bt_message', $params)) {
      $message = $params['bt_message'];
    }
    Braintree_Util::throwStatusCodeException($params['http_status'], $message);
  }

  // recreate the hash and compare it
  if (self::_hash($queryStringWithoutHash) == $params['hash']) {
    return $params;
  }
  else {
    throw new Braintree_Exception_ForgedQueryString();
  }
}