You are here

function commerce_stripe_customer_id in Commerce Stripe 7

Same name and namespace in other branches
  1. 7.3 commerce_stripe.module \commerce_stripe_customer_id()
  2. 7.2 commerce_stripe.module \commerce_stripe_customer_id()

Checks existing cards on file to see if the customer has a Stripe customer id

Parameters

integer $uid: The customer's Drupal user id

string $instance_id: The payment method instance id

Return value

mixed The customer id if one was found, otherwise FALSE

1 call to commerce_stripe_customer_id()
_commerce_stripe_create_card in ./commerce_stripe.module

File

./commerce_stripe.module, line 1128
This module provides Stripe (http://stripe.com/) payment gateway integration to Commerce. Commerce Stripe offers a PCI-compliant way to process payments straight from you Commerce shop.

Code

function commerce_stripe_customer_id($uid, $instance_id) {
  $stored_cards = commerce_cardonfile_load_multiple_by_uid($uid, $instance_id);
  if (!empty($stored_cards)) {
    $card_data = reset($stored_cards);
    list($customer_id, $card_id) = explode('|', $card_data->remote_id);
  }
  return !empty($customer_id) ? $customer_id : FALSE;
}