function commerce_stripe_commerce_payment_method_info in Commerce Stripe 7
Same name and namespace in other branches
- 7.3 commerce_stripe.module \commerce_stripe_commerce_payment_method_info()
- 7.2 commerce_stripe.module \commerce_stripe_commerce_payment_method_info()
Implements hook_commerce_payment_method_info().
File
- ./
commerce_stripe.module, line 59 - 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_commerce_payment_method_info() {
$payment_methods = array();
// The payment method info depends on the stripe integration method (stripe.js
// or Stripe Checkout) the administrator has selected. We need to load
// the rules action to determine which integration method is selected.
// Note that this code is intentionally duplicated to avoid the infinite
// recursion that would occur if we called _commerce_stripe_load_settings().
// @todo: Explore using a static variable to avoid that recursion.
$stripe_integration = STRIPE_DEFAULT_INTEGRATION;
$cardonfile = FALSE;
$payment_method_rule = rules_config_load('commerce_payment_commerce_stripe');
if ($payment_method_rule && $payment_method_rule->active) {
foreach ($payment_method_rule
->actions() as $action) {
// Skip any actions that are not simple rules actions. (i.e. loops)
if (!$action instanceof RulesAction) {
continue;
}
if (!empty($action->settings['payment_method']['method_id']) && $action->settings['payment_method']['method_id'] == 'commerce_stripe') {
// Default to Stripe.js if no integration_type has been chosen.
if (!empty($action->settings['payment_method']['settings']['integration_type'])) {
$stripe_integration = $action->settings['payment_method']['settings']['integration_type'];
}
$cardonfile = !empty($action->settings['payment_method']['settings']['cardonfile']) ? TRUE : FALSE;
break;
}
}
}
$payment_methods['commerce_stripe'] = array(
'title' => t('Stripe'),
'short_title' => t('Stripe'),
'display_title' => t('Credit card'),
'description' => t('Stripe payment gateway'),
'active' => FALSE,
'terminal' => FALSE,
'offsite' => FALSE,
);
// Set the cardonfile settings. We check that the administrator has enabled
// cardonfile functionality for commerce_stripe; if not, we do not add the
// cardonfile callbacks that would otherwise be called.
if ($cardonfile) {
// Provide general card management functionality outside of the checkout
// process.
// TODO: Write update hook to clear entity cache.
$payment_methods['commerce_stripe']['cardonfile'] = array(
'charge callback' => 'commerce_stripe_cardonfile_charge',
'delete callback' => 'commerce_stripe_cardonfile_delete',
'create form callback' => 'commerce_stripe_cardonfile_create_form',
'create callback' => 'commerce_stripe_cardonfile_create',
'update callback' => 'commerce_stripe_cardonfile_update',
);
}
return $payment_methods;
}