function _commerce_stripe_form_configure_stripe_checkout in Commerce Stripe 7
Same name and namespace in other branches
- 7.3 commerce_stripe.module \_commerce_stripe_form_configure_stripe_checkout()
Parameters
$checkout_settings:
$checkout_currency:
$email:
$amount:
1 call to _commerce_stripe_form_configure_stripe_checkout()
- commerce_stripe_cardonfile_create_form in ./
commerce_stripe.module - Card on file callback: create form
File
- ./
commerce_stripe.module, line 922 - 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_form_configure_stripe_checkout($checkout_settings, $checkout_currency, $email, $amount) {
// Clean up js settings before adding them to the page.
$checkout_settings = array_filter(array_map(function ($value) {
if ($value === 0 or $value === 1) {
$value = (bool) $value;
}
return $value;
}, $checkout_settings));
// Get the image file if one is set.
if (isset($checkout_settings['image']['fid'])) {
$image = file_load($checkout_settings['image']['fid']);
if (is_object($image)) {
$checkout_settings['image'] = file_create_url($image->uri);
}
else {
// Empty image setting will cause a broken image to be displayed in checkout
// iframe.
unset($checkout_settings['image']);
}
}
$checkout_settings += array(
'currency' => $checkout_currency,
'email' => $email,
'amount' => $amount['amount'],
);
drupal_add_js(array(
'stripe' => array(
'checkout' => $checkout_settings,
),
), 'setting');
// Add external checkout.js library.
drupal_add_js('https://checkout.stripe.com/checkout.js', 'external');
}