function commerce_stripe_pi_cardonfile_create in Commerce Stripe Payment Intent 7
Card on file callback: create.
1 call to commerce_stripe_pi_cardonfile_create()
- commerce_stripe_pi_cardonfile_create_form_submit in ./
commerce_stripe_pi.module - Submission callback for cardonfile form.
1 string reference to 'commerce_stripe_pi_cardonfile_create'
File
- ./
commerce_stripe_pi.module, line 1768 - Payment intent stripe payment integration.
Code
function commerce_stripe_pi_cardonfile_create($form, &$form_state, $payment_method, $card_data) {
if (!commerce_stripe_pi_load_library()) {
return FALSE;
}
$account = $form_state['values']['user'];
$payment_intent = SetupIntent::retrieve($form_state['values']['stripe_pi_payment_intent']);
$stripe_pi_payment_method = _commerce_stripe_pi_create_payment_method($payment_intent, $account, $payment_method);
if (!$stripe_pi_payment_method) {
return;
}
// Associate a billing profile if we have one.
$profile = NULL;
if (isset($form_state['values']['commerce_customer_profile'])) {
$profile = $form_state['values']['commerce_customer_profile'];
$profile->status = TRUE;
// Set the profile's uid if it's being created at this time.
if (empty($profile->profile_id)) {
$profile->uid = $account->uid;
}
// Notify field widgets.
field_attach_submit('commerce_customer_profile', $profile, $form, $form_state);
// Save the profile to pass to the form validators.
commerce_customer_profile_save($profile);
}
_commerce_stripe_pi_save_cardonfile($stripe_pi_payment_method, $account->uid, $payment_method, $form_state['values']['credit_card']['cardonfile_instance_default'], $profile);
}