Skip to content
This repository has been archived by the owner on Sep 1, 2019. It is now read-only.

Commit

Permalink
Leave loading of Stripe.Js to civicrm_stripe.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jul 24, 2018
1 parent d4ba89f commit e71bc71
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CRM/Core/Payment/Stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {

/**
* Set default values when loading the (payment) form
*
*
* @param \CRM_Core_Form $form
*/
public function buildForm(&$form) {
Expand Down
2 changes: 2 additions & 0 deletions js/civicrm_stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@
});

function loadStripeBillingBlock() {
// Setup Stripe.Js
var $stripePubKey = $('#stripe-pub-key');

if ($stripePubKey.length) {
if (!$().Stripe) {
$.getScript('https://js.stripe.com/v2/', function () {
Expand Down
9 changes: 5 additions & 4 deletions stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ function stripe_civicrm_alterContent( &$content, $context, $tplName, &$object )
$stripeJSURL = CRM_Core_Resources::singleton()
->getUrl('com.drastikbydesign.stripe', 'js/civicrm_stripe.js');
$content .= "<script src='{$stripeJSURL}'></script>";
$content .= "<script src='https://js.stripe.com/v2/'></script>";
$_stripe_scripts_added = TRUE;
}
}
Expand All @@ -239,10 +238,12 @@ function stripe_civicrm_alterContent( &$content, $context, $tplName, &$object )
*/
function stripe_civicrm_buildForm($formName, &$form) {
global $_stripe_scripts_added;
if (!empty($form->_paymentProcessor['class_name'])) {
if (!isset($form->_paymentProcessor)) {
return;
}
$paymentProcessor = $form->_paymentProcessor;
if (!empty($paymentProcessor['class_name'])) {
if (!$_stripe_scripts_added) {
CRM_Core_Resources::singleton()
->addScriptUrl('https://js.stripe.com/v2/', 10, 'page-body');
CRM_Core_Resources::singleton()
->addScriptFile('com.drastikbydesign.stripe', 'js/civicrm_stripe.js');
}
Expand Down

0 comments on commit e71bc71

Please sign in to comment.