Commit f6d01511 authored by mattwire's avatar mattwire
Browse files

Move javascript debug to mjwshared

parent 59c27f91
......@@ -263,8 +263,7 @@
* @param {string} errorCode
*/
debugging: function(scriptName, errorCode) {
// Uncomment the following to debug unexpected returns.
if ((typeof(CRM.vars.stripe) === 'undefined') || (Boolean(CRM.vars.stripe.jsDebug) === true)) {
if ((typeof(CRM.vars.payment) !== 'undefined') && (Boolean(CRM.vars.payment.jsDebug) === true)) {
console.log(new Date().toISOString() + ' ' + scriptName + ': ' + errorCode);
}
}
......
......@@ -241,3 +241,25 @@ function mjwshared_civicrm_links($op, $objectName, $objectId, &$links, &$mask, &
function mjwshared_civicrm_alterLogTables(&$logTableSpec) {
unset($logTableSpec['civicrm_paymentprocessor_webhook']);
}
/**
* Add stripe.js to forms, to generate stripe token
* hook_civicrm_alterContent is not called for all forms (eg. CRM_Contribute_Form_Contribution on backend)
*
* @param string $formName
* @param \CRM_Core_Form $form
*
* @throws \CRM_Core_Exception
*/
function mjwshared_civicrm_buildForm($formName, &$form) {
// Don't load js on ajax forms
if (CRM_Utils_Request::retrieveValue('snippet', 'String') === 'json') {
return;
}
$jsVars = [
'jsDebug' => (boolean) \Civi::settings()->get('mjwshared_jsdebug'),
];
\Civi::resources()->addVars('payment', $jsVars);
}
......@@ -29,4 +29,20 @@ return [
]
],
],
'mjwshared_jsdebug' => [
'name' => 'mjwshared_jsdebug',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => 0,
'is_domain' => 1,
'is_contact' => 0,
'title' => E::ts('Enable Javascript debugging?'),
'description' => E::ts('Enables debug logging to browser console for javascript based payment processors.'),
'html_attributes' => [],
'settings_pages' => [
'stripe' => [
'weight' => 15,
]
],
],
];
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment