function _commerce_stripe_save_cardonfile in Commerce Stripe 7
Same name and namespace in other branches
- 7.3 commerce_stripe.module \_commerce_stripe_save_cardonfile()
- 7.2 commerce_stripe.module \_commerce_stripe_save_cardonfile()
2 calls to _commerce_stripe_save_cardonfile()
- commerce_stripe_cardonfile_create in ./
commerce_stripe.module - Card on file callback: create
- commerce_stripe_submit_form_submit in ./
commerce_stripe.module - Payment method callback: checkout form submission.
File
- ./
commerce_stripe.module, line 668 - 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_save_cardonfile($card, $uid, $payment_method, $set_default) {
// Store the Stripe customer and card ids in the remote id field of {commerce_cardonfile} table
$remote_id = (string) $card->customer . '|' . (string) $card->id;
// Populate and save the card
$card_data = commerce_cardonfile_new();
$card_data->uid = $uid;
$card_data->payment_method = $payment_method['method_id'];
$card_data->instance_id = $payment_method['instance_id'];
$card_data->remote_id = $remote_id;
$card_data->card_type = $card->type;
$card_data->card_name = $card->name;
$card_data->card_number = $card->last4;
$card_data->card_exp_month = $card->exp_month;
$card_data->card_exp_year = $card->exp_year;
$card_data->status = 1;
$card_data->instance_default = 0;
if (property_exists($card, 'type')) {
$card_data->card_type = $card->type;
}
else {
$card_data->card_type = $card->brand;
}
commerce_cardonfile_save($card_data);
if ($set_default) {
commerce_cardonfile_set_default_card($card_data->card_id);
}
watchdog('commerce_stripe', 'Stripe Customer Profile @profile_id created and saved to user @uid.', array(
'@profile_id' => (string) $card->customer,
'@uid' => $uid,
));
}