Skip to content
Snippets Groups Projects
Commit 910de8d3 authored by mattwire's avatar mattwire
Browse files

Add getIsRecur function to CRM.payment. Update release notes

parent a3bf0691
No related branches found
No related tags found
1 merge request!90.9
......@@ -8,13 +8,15 @@ Where:
* minor: Breaking change in some circumstances, or a new feature. Read carefully and make sure you understand the impact of the change.
* incremental: A "safe" change / improvement. Should *always* be safe to upgrade.
## Release 0.9 - not yet released
## Release 0.9 - not yet released (2020-07-18)
* Update API3 `Mjwpayment.get_payment` spec
* Refactor API3 `Mjwpayment.get_contribution` so it accepts `order_reference` and `trxn_id` params and returns a single contribution with matching payments
* Use API3 `Mjwpayment.create_payment` instead of API3 `Payment.create` API in `updateContributionRefund()` for compatibility with multiple versions of CiviCRM
* Allow completing a contribution that has Failed status via `updateContributionCompleted()`
* Add basic function for updating a contribution (eg. the trxn_id) without touching other things
* Refactor API3 `Mjwpayment.get_contribution` so it accepts `order_reference` and `trxn_id` params and returns a single contribution with matching payments.
* Use API3 `Mjwpayment.create_payment` instead of API3 `Payment.create` API in `updateContributionRefund()` for compatibility with multiple versions of CiviCRM.
* Allow completing a contribution that has Failed status via `updateContributionCompleted()`.
* Add basic function for updating a contribution (eg. the `trxn_id`) without touching other things.
* Don't trigger exception if payment processor ID not found for IPN, use debug function because we don't have access to getPaymentProcessorLabel() function.
* Add getIsRecur() function to CRM.payment library.
## Release 0.8.1
......
......@@ -14,7 +14,7 @@
<url desc="Release Notes">https://lab.civicrm.org/extensions/mjwshared/blob/0.8/docs/releasenotes.md</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-07-13</releaseDate>
<releaseDate>2020-07-18</releaseDate>
<version>0.9-dev</version>
<develStage>alpha</develStage>
<compatibility>
......
(function($, CRM, _, undefined) {
(function($) {
var payment = {
form: null,
......@@ -95,6 +95,51 @@
},
/**
* Are we creating a recurring contribution?
* @returns {boolean}
*/
getIsRecur: function() {
var isRecur = false;
// Auto-renew contributions for CiviCRM Webforms.
if (this.getIsDrupalWebform()) {
if (($('input[data-civicrm-field-key$="contribution_installments"]').length !== 0 && $('input[data-civicrm-field-key$="contribution_installments"]').val() > 1) ||
($('input[data-civicrm-field-key$="contribution_frequency_interval"]').length !== 0 && $('input[data-civicrm-field-key$="contribution_frequency_interval"]').val() > 0)
) {
isRecur = true;
}
}
// Auto-renew contributions
if (document.getElementById('is_recur') !== null) {
if (document.getElementById('is_recur').type == 'hidden') {
isRecur = (document.getElementById('is_recur').value == 1);
}
else {
isRecur = Boolean(document.getElementById('is_recur').checked);
}
}
// Auto-renew memberships
// This gets messy quickly!
// input[name="auto_renew"] : set to 1 when there is a force-renew membership with no priceset.
else if ($('input[name="auto_renew"]').length !== 0) {
if ($('input[name="auto_renew"]').prop('checked')) {
isRecur = true;
}
else if ($('input[name="auto_renew"]').attr('type') == 'hidden') {
// If the auto_renew field exists as a hidden field, then we force a
// recurring contribution (the value isn't useful since it depends on
// the locale - e.g. "Please renew my membership")
isRecur = true;
}
else {
isRecur = Boolean($('input[name="auto_renew"]').checked);
}
}
this.debugging(this.scriptName, 'isRecur is ' + isRecur);
return isRecur;
},
/**
* Output debug information
* @param {string} scriptName
* @param {string} errorCode
......@@ -116,4 +161,4 @@
$.extend(CRM.payment, payment);
}
}(jQuery, CRM, _));
}(CRM.$));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment