Skip to content
Snippets Groups Projects
Commit c4adaee7 authored by mattwire's avatar mattwire Committed by Rich
Browse files

Add check for mjwshared extension

parent 0354399b
Branches
No related tags found
No related merge requests found
......@@ -318,12 +318,12 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
'publishableKey' => CRM_Core_Payment_Stripe::getPublicKeyById($form->_paymentProcessor['id']),
'jsDebug' => TRUE,
];
CRM_Core_Resources::singleton()->addVars(E::SHORT_NAME, $jsVars);
\Civi::resources()->addVars(E::SHORT_NAME, $jsVars);
// Add help and javascript
CRM_Core_Region::instance('billing-block')->add(
['template' => 'CRM/Core/Payment/Stripe/Card.tpl', 'weight' => -1]);
CRM_Core_Resources::singleton()
\Civi::resources()
->addStyleFile(E::LONG_NAME, 'css/elements.css', 0, 'page-header')
->addScriptFile('com.drastikbydesign.stripe', 'js/civicrm_stripe.js');
}
......
<?php
/**
* https://civicrm.org/licensing
*/
use CRM_Stripe_ExtensionUtil as E;
/**
* Class CRM_Stripe_Check
*/
class CRM_Stripe_Check {
const MIN_VERSION_MJWSHARED = 0.2;
public static function checkRequirements(&$messages) {
$extensions = civicrm_api3('Extension', 'get', [
'full_name' => "mjwshared",
]);
if (empty($extensions['id']) || ($extensions['values'][$extensions['id']]['status'] !== 'installed')) {
$messages[] = new CRM_Utils_Check_Message(
'stripe_requirements',
E::ts('The Stripe extension requires the mjwshared extension which is not installed (https://lab.civicrm.org/extensions/mjwshared).'),
E::ts('Stripe: Missing Requirements'),
\Psr\Log\LogLevel::ERROR,
'fa-money'
);
}
if (version_compare($extensions['values'][$extensions['id']]['version'], self::MIN_VERSION_MJWSHARED) === -1) {
$messages[] = new CRM_Utils_Check_Message(
'stripe_requirements',
E::ts('The Stripe extension requires the mjwshared extension version %1 or greater but your system has version %2.',
[
1 => self::MIN_VERSION_MJWSHARED,
2 => $extensions['values'][$extensions['id']]['version']
]),
E::ts('Stripe: Missing Requirements'),
\Psr\Log\LogLevel::ERROR,
'fa-money'
);
}
}
}
## Release 6.0 (not yet released)
* Stripe API Version: 2019-08-14
* Switch publishable key/secret key in settings (upgrader does this automatically) so they are now "correct" per CiviCRM settings pages.
**This is a major new release. You cannot rollback once you've upgraded.**
* Use Stripe Elements: https://stripe.com/payments/elements.
* Use PaymentIntents and comply with the European SCA directive (https://stripe.com/docs/strong-customer-authentication).
* Require Stripe API Version: 2019-08-14 and ensure that all codepaths specify the API version.
* Switch publishable key/secret key in settings (upgrader does this automatically) so they are now "correct" per CiviCRM settings pages.
## Release 5.4.1
* Don't overwrite system messages when performing webhook checks.
......
......@@ -92,6 +92,7 @@ CRM.$(function($) {
$(document).ready(function() {
// Disable the browser "Leave Page Alert" which is triggered because we mess with the form submit function.
window.onbeforeunload = null;
// Load Stripe onto the form.
loadStripeBillingBlock();
......
......@@ -160,7 +160,7 @@ function stripe_civicrm_buildForm($formName, &$form) {
// Load stripe.js on all civi forms per stripe requirements
if (!isset(\Civi::$statics[E::LONG_NAME]['stripeJSLoaded'])) {
CRM_Core_Resources::singleton()->addScriptUrl('https://js.stripe.com/v3');
\Civi::resources()->addScriptUrl('https://js.stripe.com/v3');
\Civi::$statics[E::LONG_NAME]['stripeJSLoaded'] = TRUE;
}
}
......@@ -194,6 +194,7 @@ function stripe_civicrm_postProcess($formName, &$form) {
*/
function stripe_civicrm_check(&$messages) {
CRM_Stripe_Webhook::check($messages);
CRM_Stripe_Check::checkRequirements($messages);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment