function commerce_stripe_settings_form in Commerce Stripe 7
Same name and namespace in other branches
- 7.3 commerce_stripe.module \commerce_stripe_settings_form()
- 7.2 commerce_stripe.module \commerce_stripe_settings_form()
Payment method settings form.
Parameters
$settings: Default settings provided from rules
Return value
array Settings form array
File
- ./
commerce_stripe.module, line 151 - 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_settings_form($settings) {
$form = array();
$form['stripe_currency'] = array(
'#type' => 'select',
'#title' => t('Currency'),
'#options' => array(
'CAD' => t('CAD'),
'EUR' => t('EUR'),
'GBP' => t('GBP'),
'USD' => t('USD'),
'AUD' => t('AUD'),
'CHF' => t('CHF'),
),
'#description' => t('Select the currency that you are using.'),
'#default_value' => !empty($settings['stripe_currency']) ? $settings['stripe_currency'] : 'USD',
);
$form['secret_key'] = array(
'#type' => 'textfield',
'#title' => t('Secret Key'),
'#description' => t('Secret API Key. Get your key from https://stripe.com/'),
'#default_value' => !empty($settings['secret_key']) ? $settings['secret_key'] : '',
'#required' => TRUE,
);
$form['public_key'] = array(
'#type' => 'textfield',
'#title' => t('Publishable Key'),
'#description' => t('Publishable API Key. Get your key from https://stripe.com/'),
'#default_value' => !empty($settings['public_key']) ? $settings['public_key'] : '',
'#required' => TRUE,
);
$form['display_title'] = array(
'#type' => 'textfield',
'#title' => t('Payment method display title'),
'#description' => t('Payment method display title'),
'#default_value' => !empty($settings['display_title']) ? $settings['display_title'] : t('Stripe'),
);
$form['receipt_email'] = array(
'#type' => 'checkbox',
'#title' => t('Email receipts'),
'#description' => t('When selected, customers will receive email receipts from Stripe.'),
'#default_value' => isset($settings['receipt_email']) ? $settings['receipt_email'] : 0,
);
$form['integration_type'] = array(
'#type' => 'select',
'#title' => t('Integration type'),
'#description' => t('Choose Stripe integration method: Stripe.js makes it easy to collect credit card (and other similarly sensitive) details without having the information touch your server. Checkout is an embeddable iframe for desktop, tablet, and mobile devices.'),
'#options' => array(
'stripejs' => t('stripe.js'),
'checkout' => t('checkout'),
),
'#default_value' => !empty($settings['integration_type']) ? $settings['integration_type'] : STRIPE_DEFAULT_INTEGRATION,
);
// Stripe Checkout specific settings.
// @see: https://stripe.com/docs/checkout#integration-custom
$form['checkout_settings'] = array(
'#type' => 'fieldset',
'#title' => t('These settings are specific to "checkout" integration type.'),
'#states' => array(
'visible' => array(
':input[name$="[integration_type]"]' => array(
'value' => 'checkout',
),
),
),
);
// Highly recommended checkout options:
// Name
$form['checkout_settings']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('The name of your company or website.'),
'#default_value' => isset($settings['checkout_settings']['name']) ? $settings['checkout_settings']['name'] : variable_get('site_name', ''),
);
// Description
$form['checkout_settings']['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#description' => t('A description of the product or service being purchased.'),
'#default_value' => isset($settings['checkout_settings']['description']) ? $settings['checkout_settings']['description'] : '',
);
// Image
$form['checkout_settings']['image'] = array(
'#type' => 'managed_file',
'#title' => t('Image'),
'#progress_message' => t('Please wait...'),
'#progress_indicator' => 'bar',
'#description' => t('Click "Browse..." to select an image to upload.'),
'#required' => FALSE,
'#upload_location' => 'public://commerce_stripe/checkout_images/',
'#default_value' => isset($settings['checkout_settings']['image']) ? $settings['checkout_settings']['image']['fid'] : '',
'#element_validate' => array(
'commerce_stripe_settings_form_image_validate',
),
);
// Optional checkout options:
// panelLabel
$form['checkout_settings']['panelLabel'] = array(
'#type' => 'textfield',
'#title' => t('Payment button label'),
'#description' => t('The label of the payment button in the Checkout form (e.g. “Subscribe”, “Pay {{amount}}”, etc.). If you include {{amount}}, it will be replaced by the provided amount. Otherwise, the amount will be appended to the end of your label.'),
'#default_value' => isset($settings['checkout_settings']['panelLabel']) ? $settings['checkout_settings']['panelLabel'] : "Pay {{amount}}",
);
// zipCode
$form['checkout_settings']['zipCode'] = array(
'#type' => 'checkbox',
'#title' => t('ZIP code verification'),
'#description' => t('Specify whether Checkout should validate the billing ZIP code.'),
'#default_value' => isset($settings['checkout_settings']['zipCode']) ? $settings['checkout_settings']['zipCode'] : 0,
);
// allowRememberMe
$form['checkout_settings']['allowRememberMe'] = array(
'#type' => 'checkbox',
'#title' => t('Show "Remember Me" option'),
'#description' => t('Specify whether Checkout should allow the user to store their credit card for faster checkout.'),
'#default_value' => isset($settings['checkout_settings']['allowRememberMe']) ? $settings['checkout_settings']['allowRememberMe'] : 0,
);
// bitcoin
$form['checkout_settings']['bitcoin'] = array(
'#type' => 'checkbox',
'#title' => t('Accept Bitcoin'),
'#description' => t('When checked, Stripe Checkout will accept Bitcoin as payment.') . l(t('Must be enabled in your Stripe account.'), 'https://dashboard.stripe.com/account/bitcoin/enable'),
'#default_value' => isset($settings['checkout_settings']['bitcoin']) ? $settings['checkout_settings']['bitcoin'] : 0,
);
// billingAddress (Undocumented option)
$form['checkout_settings']['billingAddress'] = array(
'#type' => 'checkbox',
'#title' => t('Billing address'),
'#description' => t('Specify whether to enable billing address collection in Checkout.'),
'#default_value' => isset($settings['checkout_settings']['billingAddress']) ? $settings['checkout_settings']['billingAddress'] : 0,
);
// shippingAddress (Undocumented option)
$form['checkout_settings']['shippingAddress'] = array(
'#type' => 'checkbox',
'#title' => t('Shipping address'),
'#description' => t('Specify whether to enable shipping address collection in Checkout.'),
'#default_value' => isset($settings['checkout_settings']['shippingAddress']) ? $settings['checkout_settings']['shippingAddress'] : 0,
);
if (module_exists('commerce_cardonfile')) {
$form['cardonfile'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Card on File functionality.'),
'#default_value' => isset($settings['cardonfile']) ? $settings['cardonfile'] : 0,
);
}
else {
$form['cardonfile'] = array(
'#type' => 'markup',
'#markup' => t('To enable Card on File funcitionality download and install the Card on File module.'),
);
}
return $form;
}