Provision Commerce Payment methods programmatically.

Public

Enable and configure Commerce Payment methods programmatically.

Get raw version
php
  1. <?php
  2.  
  3. /**
  4.  * Implements hook_commerce_payment_method_info_alter().
  5.  *
  6.  * Optional: Prevents payment from showing up as overridden, for us nit-picky folk.
  7.  */
  8. function dropbilling_commerce_commerce_payment_method_info_alter(&$payment_methods) {
  9. $payment_methods['paypal_wps']['active'] = TRUE;
  10. }
  11.  
  12. /**
  13.  * Example provisioning function
  14.  *
  15.  * Run on hook_install or _update
  16.  */
  17. function example_commerce_provision_paypal_wps() {
  18. $rules_config = rules_config_load('commerce_payment_paypal_wps');
  19.  
  20. // Ensure rule is enabled.
  21. $rules_config->active = TRUE;
  22.  
  23. // Settings.
  24. $actions = $rules_config->actions();
  25. $action = reset($actions);
  26. $action->settings['payment_method']['settings']['business'] = variable_get('site_paypal_email', NULL);
  27. $action->settings['payment_method']['settings']['ipn_logging'] = 'notification';
  28. $action->settings['payment_method']['settings']['ipn_create_billing_profile'] = 1;
  29.  
  30. $rules_config->save();
  31. }