function hook_commerce_payment_method_info in Commerce Core 7
Define payment methods available to the Commerce Payment framework.
The Payment module uses this hook to gather information on payment methods defined by enabled modules.
Payment methods depend on a variety of callbacks that are used to configure the payment methods via Rules actions, integrate the payment method with the checkout form, handle display and manipulation of transactions after the fact, and allow for administrative payment entering after checkout. The Payment module ships with payment method modules useful for testing and learning, but all integrations with real payment providers will be provided as contributed modules. The Payment module will include helper code designed to make different types of payment services easier to integrate as mentioned above.
Each payment method is an associative array with the following keys:
- method_id: string identifying the payment method (must be a valid PHP identifier).
- base (optional): string used as the base for callback names, each of which will be defaulted to [base]_[callback] unless explicitly set; defaults to the method_id if not set.
- title: the translatable full title of the payment method, used in administrative interfaces.
- display_title (optional): the title to display on forms where the payment method is selected and may include HTML for methods that require images and special descriptions; defaults to the title.
- short_title (optional): an abbreviated title that may simply include the payment provider’s name as it makes sense to the customer (i.e. you would display PayPal, not PayPal WPS to a customer); defaults to the title.
- description (optional): a translatable description of the payment method, including the nature of the payment and the payment gateway that actually captures the payment.
- active (optional): TRUE of FALSE indicating whether or not the default payment method rule configuration for this payment method should be enabled by default; defaults to FALSE.
- checkout (optional): TRUE or FALSE indicating whether or not payments can be processed via this payment method through the checkout form; defaults to TRUE.
- terminal (optional): TRUE or FALSE indicating whether or not payments can be processed via this payment method through the administrative payment terminal on an order’s Payment tab; defaults to TRUE.
- offsite (optional): TRUE or FALSE indicating whether or not the customer must be redirected offsite to put in their payment information; used specifically by the off-site payment redirect checkout pane; defaults to FALSE.
- offsite_autoredirect (optional): TRUE or FALSE indicating whether or not the customer should be automatically redirected to an offsite payment site on the payment step of checkout; defaults to FALSE.
- callbacks (optional): an array of callback function names for the various
types of callback required for all the payment method operations, arguments
per callback in parentheses:
- settings_form: the name of the CALLBACK_commerce_payment_method_settings_form() of the payment method.
- submit_form: the name of the CALLBACK_commerce_payment_method_submit_form() of the payment method.
- submit_form_validate: the name of the CALLBACK_commerce_payment_method_submit_form_validate() of the payment method.
- submit_form_submit: the name of the CALLBACK_commerce_payment_method_submit_form_submit() of the payment method.
- redirect_form: the name of the CALLBACK_commerce_payment_method_redirect_form() of the payment method.
- redirect_form_back: the name of the CALLBACK_commerce_payment_method_redirect_form_back() of the payment method.
- redirect_form_validate: the name of the CALLBACK_commerce_payment_method_redirect_form_validate() of the payment method.
- redirect_form_submit: the name of the CALLBACK_commerce_payment_method_redirect_form_submit() of the payment method.
- file (optional): the filepath of an include file relative to the method's module containing the callback functions for this method, allowing modules to store payment method code in include files that only get loaded when necessary (like the menu item file property).
Return value
An array of payment methods, using the format defined above.
Related topics
2 functions implement hook_commerce_payment_method_info()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- commerce_payment_dummy_offsite_commerce_payment_method_info in modules/
payment/ tests/ commerce_payment_dummy_offsite.module - Implements hook_commerce_payment_method_info().
- commerce_payment_example_commerce_payment_method_info in modules/
payment/ modules/ commerce_payment_example.module - Implements hook_commerce_payment_method_info().
1 invocation of hook_commerce_payment_method_info()
- commerce_payment_methods in modules/
payment/ commerce_payment.module - Returns an array of payment methods defined by enabled modules.
File
- modules/
payment/ commerce_payment.api.php, line 159 - Hooks provided by the Payment module.
Code
function hook_commerce_payment_method_info() {
$payment_methods['paypal_wps'] = array(
'base' => 'commerce_paypal_wps',
'title' => t('PayPal WPS'),
'short_title' => t('PayPal'),
'description' => t('PayPal Website Payments Standard'),
'terminal' => FALSE,
'offsite' => TRUE,
'offsite_autoredirect' => TRUE,
);
return $payment_methods;
}