You are here

function commerce_stripe_pi_customer_id in Commerce Stripe Payment Intent 7

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

Parameters

int $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_pi_customer_id()
_commerce_stripe_pi_create_payment_method in ./commerce_stripe_pi.module
Call Stripe to create card for a user.

File

./commerce_stripe_pi.module, line 1896
Payment intent stripe payment integration.

Code

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