function _uc_stripe_create_stripe_customer in Ubercart Stripe 7.3
1 call to _uc_stripe_create_stripe_customer()
- _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 1151 - 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_create_stripe_customer($order, $payment_method_id = NULL) {
$stripe_customer_id = FALSE;
try {
// If the token is not in the user's session, we can't set up a new customer
$shipping_info = array();
if (!empty($order->delivery_postal_code)) {
$shipping_info = array(
'name' => @"{$order->delivery_first_name} {$order->delivery_last_name}",
'phone' => @$order->delivery_phone,
);
$delivery_country = uc_get_country_data(array(
'country_id' => $order->delivery_country,
));
if ($delivery_country === FALSE) {
$delivery_country = array(
0 => array(
'country_iso_code_2' => 'US',
),
);
}
$shipping_info['address'] = array(
'city' => @$order->delivery_city,
'country' => @$delivery_country[0]['country_iso_code_2'],
'line1' => @$order->delivery_street1,
'line2' => @$order->delivery_street2,
'postal_code' => @$order->delivery_postal_code,
);
}
$params = array(
'description' => "OrderID: {$order->order_id}",
'email' => "{$order->primary_email}",
);
if (!empty($shipping_info)) {
$params['shipping'] = $shipping_info;
}
//Create the customer in stripe
$customer = \Stripe\Customer::create($params);
return $customer;
} catch (Exception $e) {
$message = t("Stripe Customer Creation Failed for order !order: !message", array(
"!order" => $order_id,
"!message" => $e
->getMessage(),
));
uc_order_comment_save($order_id, $user->uid, $message, 'admin');
watchdog('uc_stripe', 'Failed stripe customer creation: @message', array(
'@message' => $message,
));
return false;
}
}