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 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);
 }
 /**
  *
  * @param array $params
  * @throws InvalidArgumentException
  */
 public function conditionallyVerifyKeys($params)
 {
     if (array_key_exists("customerId", $params)) {
         Util::verifyKeys($this->generateWithCustomerIdSignature(), $params);
     } else {
         Util::verifyKeys($this->generateWithoutCustomerIdSignature(), $params);
     }
 }
 /**
  * @ignore
  * @access private
  * @param array $attribs
  * @return object
  */
 private function create($attribs)
 {
     Util::verifyKeys(self::createSignature(), $attribs);
     return $this->_doCreate('/transactions', array('transaction' => $attribs));
 }
 /**
  * updates the address record
  *
  * if calling this method in context,
  * customerOrId is the 2nd attribute, addressId 3rd.
  * customerOrId & addressId are not sent in object context.
  *
  *
  * @access public
  * @param array $attributes
  * @param mixed $customerOrId (only used in call)
  * @param string $addressId (only used in call)
  * @return object Result\Successful or Result\Error
  */
 public function update($customerOrId, $addressId, $attributes)
 {
     $this->_validateId($addressId);
     $customerId = $this->_determineCustomerId($customerOrId);
     Util::verifyKeys(self::updateSignature(), $attributes);
     $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
     $response = $this->_http->put($path, array('address' => $attributes));
     return $this->_verifyGatewayResponse($response);
 }
 public function submitForPartialSettlement($transactionId, $amount, $attribs = [])
 {
     $this->_validateId($transactionId);
     Util::verifyKeys(self::submitForSettlementSignature(), $attribs);
     $attribs['amount'] = $amount;
     $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/submit_for_partial_settlement';
     $response = $this->_http->post($path, ['transaction' => $attribs]);
     return $this->_verifyGatewayResponse($response);
 }
 public function refund($transactionId, $amount_or_options = null)
 {
     self::_validateId($transactionId);
     if (gettype($amount_or_options) == "array") {
         $options = $amount_or_options;
     } else {
         $options = ["amount" => $amount_or_options];
     }
     Util::verifyKeys(self::refundSignature(), $options);
     $params = ['transaction' => $options];
     $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/refund';
     $response = $this->_http->post($path, $params);
     return $this->_verifyGatewayResponse($response);
 }
 /**
  * updates the creditcard record
  *
  * if calling this method in context, $token
  * is the 2nd attribute. $token is not sent in object context.
  *
  * @access public
  * @param array $attributes
  * @param string $token (optional)
  * @return Result\Successful|Result\Error
  */
 public function update($token, $attributes)
 {
     Util::verifyKeys(self::updateSignature(), $attributes);
     $this->_validateId($token);
     return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, ['creditCard' => $attributes]);
 }
 public function update($token, $attribs)
 {
     Util::verifyKeys(self::updateSignature(), $attribs);
     return $this->_doUpdate('/payment_methods/any/' . $token, ['payment_method' => $attribs]);
 }
Example #9
0
 public function testVerifyKeys()
 {
     $signature = ['amount', 'customerId', 'orderId', 'channel', 'paymentMethodToken', 'type', ['creditCard' => ['token', 'cvv', 'expirationDate', 'number']], ['customer' => ['id', 'company', 'email', 'fax', 'firstName', 'lastName', 'phone', 'website']], ['billing' => ['firstName', 'lastName', 'company', 'countryName', 'extendedAddress', 'locality', 'postalCode', 'region', 'streetAddress']], ['shipping' => ['firstName', 'lastName', 'company', 'countryName', 'extendedAddress', 'locality', 'postalCode', 'region', 'streetAddress']], ['options' => ['storeInVault', 'submitForSettlement', 'addBillingAddressToPaymentMethod']], ['customFields' => ['_anyKey_']]];
     // test valid
     $userKeys = ['amount' => '100.00', 'customFields' => ['HEY' => 'HO', 'WAY' => 'NO'], 'creditCard' => ['number' => '5105105105105100', 'expirationDate' => '05/12']];
     $n = Braintree\Util::verifyKeys($signature, $userKeys);
     $this->assertNull($n);
     $userKeys = ['amount' => '100.00', 'customFields' => ['HEY' => 'HO', 'WAY' => 'NO'], 'bogus' => 'FAKE', 'totallyFake' => 'boom', 'creditCard' => ['number' => '5105105105105100', 'expirationDate' => '05/12']];
     // test invalid
     $this->setExpectedException('InvalidArgumentException');
     Braintree\Util::verifyKeys($signature, $userKeys);
 }
 /**
  * updates the customer record
  *
  * if calling this method in static context, customerId
  * is the 2nd attribute. customerId is not sent in object context.
  *
  * @access public
  * @param string $customerId (optional)
  * @param array $attributes
  * @return Result\Successful|Result\Error
  */
 public function update($customerId, $attributes)
 {
     Util::verifyKeys(self::updateSignature(), $attributes);
     $this->_validateId($customerId);
     return $this->_doUpdate('put', '/customers/' . $customerId, ['customer' => $attributes]);
 }
 /**
  * Returns the trData string for updating a customer.
  *
  *  The customerId of the customer to update is required.
  *
  * <code>
  * $trData = TransparentRedirect::updateCustomerData(array(
  *     'redirectUrl' => 'http://example.com/redirect_here',
  *     'customerId' => 'customer123',
  *   ));
  * </code>
  *
  * @param array $params
  * @return string
  */
 public function updateCustomerData($params)
 {
     Util::verifyKeys(self::$_updateCustomerSignature, $params);
     if (!isset($params['customerId'])) {
         throw new InvalidArgumentException('expected params to contain customerId of customer to update');
     }
     $params["kind"] = TransparentRedirect::UPDATE_CUSTOMER;
     return $this->_data($params);
 }
 /**
  * updates the paypalAccount record
  *
  * if calling this method in context, $token
  * is the 2nd attribute. $token is not sent in object context.
  *
  * @access public
  * @param array $attributes
  * @param string $token (optional)
  * @return Result\Successful or Result\Error
  */
 public function update($token, $attributes)
 {
     Util::verifyKeys(self::updateSignature(), $attributes);
     $this->_validateId($token);
     return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, ['paypalAccount' => $attributes]);
 }