From 82600fc74e623dd5ba939d42e9f883f8c046b5da Mon Sep 17 00:00:00 2001 From: Peter Hartmann <peter@hartmanncomputer.com> Date: Thu, 2 Mar 2017 20:14:28 -0500 Subject: [PATCH] load js with webform --- CRM/Core/Payment/Stripe.php | 2 +- stripe.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Payment/Stripe.php b/CRM/Core/Payment/Stripe.php index 7d8a61ce..f7e2214d 100644 --- a/CRM/Core/Payment/Stripe.php +++ b/CRM/Core/Payment/Stripe.php @@ -282,7 +282,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment { * contain a Stripe payment processor, return the api public key for * that processor. */ - public function stripe_get_key($form) { + public static function stripe_get_key($form) { if (empty($form->_paymentProcessor)) { return; } diff --git a/stripe.php b/stripe.php index 1c50cb7b..ccb952df 100644 --- a/stripe.php +++ b/stripe.php @@ -183,3 +183,21 @@ function stripe_civicrm_managed(&$entities) { } } } + + /** + * Implementation of hook_civicrm_alterContent + * + * @return void + */ + function stripe_civicrm_alterContent( &$content, $context, $tplName, &$object ) { + if($context == 'form' && !empty($object->_paymentProcessor['class_name'])) { + if($object->_paymentProcessor['class_name'] == 'Payment_Stripe') { + $stripe_key = CRM_Core_Payment_Stripe::stripe_get_key($object); + if(empty($stripe_key)) { + return; + } + $stripeJSURL = CRM_Core_Resources::singleton()->getUrl('com.drastikbydesign.stripe', 'js/civicrm_stripe.js'); + $content .= "<script src='{$stripeJSURL}'></script>"; + } + } + } -- GitLab