You are here

function _uc_stripe_is_stripe_id_valid in Ubercart Stripe 7.3

Parameters

string $stripe_id:

Return value

boolean result - if stripe_id is valid based on stripe api customer call

1 call to _uc_stripe_is_stripe_id_valid()
_uc_stripe_confirm_payment in ./uc_stripe.module
Ajax page callback for callback uc_stripe/ajax/confirm_payment page This is used to send payment and intent status back to JS client

File

./uc_stripe.module, line 1232
A stripe.js PCI-compliant payment gateway Forked from Bitcookie's work (thanks!) which was posted at http://bitcookie.com/blog/pci-compliant-ubercart-and-stripe-js from discussion in the uc_stripe issue queue, https://www.drupal.org/node/1467886

Code

function _uc_stripe_is_stripe_id_valid($stripe_id) {
  try {
    if (!_uc_stripe_prepare_api()) {
      $message = 'Stripe API not found.';
      watchdog('uc_stripe', 'Error in Stripe API: @message', array(
        '@message' => $message,
      ));
      return false;
    }
    $customer = \Stripe\Customer::retrieve($stripe_id);

    // Count deleted stripe customers as invalid
    return !$customer->deleted;
  } catch (Exception $e) {

    // IF customer is not found, an exception is thrown.
    return false;
  }
}