diff --git a/CRM/Core/Payment/Stripe.php b/CRM/Core/Payment/Stripe.php index 7d8a61ce5fb7e5c8e4018fc5a18981af08fbc602..f7e2214d1afccfb29fef06b0746717261517d21e 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 1c50cb7b30479c460f9fec89d75e09bc7bb2102b..ccb952dfbe841bdca5fec08612e9d6c5417fec4b 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>"; + } + } + }