function commerce_braintree_express_checkout_validate_nonce in Commerce Braintree 7.3
Validates that a nonce is still active and has not been consumed.
Parameters
$nonce: The Braintree nonce.
Return value
bool TRUE if the nonce is still valid.
2 calls to commerce_braintree_express_checkout_validate_nonce()
- commerce_braintree_express_checkout_form_alter in modules/
commerce_braintree_express_checkout/ commerce_braintree_express_checkout.module - Implements hook_form_alter().
- commerce_braintree_express_checkout_submit_form in modules/
commerce_braintree_express_checkout/ commerce_braintree_express_checkout.module - Form callback for Braintree Express Checkout payment method.
File
- modules/
commerce_braintree_express_checkout/ commerce_braintree_express_checkout.module, line 226 - Provides integration PayPal Express Checkout for Braintree.
Code
function commerce_braintree_express_checkout_validate_nonce($nonce) {
// Utilize static caching to prevent extraneous API calls.
$valid =& drupal_static(__FUNCTION__);
if (!isset($valid)) {
$payment_method = commerce_payment_method_instance_load(COMMERCE_BRAINTREE_EXPRESS_CHECKOUT_INSTANCE_ID);
commerce_braintree_initialize($payment_method);
$result = Braintree_PaymentMethodNonce::find($nonce);
// The nonce is valid if a response is returned and it has not been
// previously consumed.
$valid = !empty($result) && isset($result->consumed) && $result->consumed == FALSE;
}
return $valid;
}