Skip to content

Commit

Permalink
Merge pull request #18517 from JMAConsulting/financial-issue-150
Browse files Browse the repository at this point in the history
dev/financial#150: civicrm/payment/form url got empty currency argument in backoffice live CC form
  • Loading branch information
mattwire authored Jul 7, 2021
2 parents ddca977 + 10495d0 commit 44f9625
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
14 changes: 1 addition & 13 deletions CRM/Contribute/Form/AbstractEditPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,7 @@ public function assignProcessors() {
* @return string
*/
public function getCurrency($submittedValues = []) {
$config = CRM_Core_Config::singleton();

$currentCurrency = CRM_Utils_Array::value('currency',
$this->_values,
$config->defaultCurrency
);

// use submitted currency if present else use current currency
$result = CRM_Utils_Array::value('currency',
$submittedValues,
$currentCurrency
);
return $result;
return $submittedValues['currency'] ?? $this->_values['currency'] ?? CRM_Core_Config::singleton()->defaultCurrency;
}

public function preProcessPledge() {
Expand Down
14 changes: 10 additions & 4 deletions templates/CRM/common/paymentBlock.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@
var payment_instrument_id = $('#payment_instrument_id').val();
var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="formName=`$form.formName`&currency=`$currency`&`$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type;
var currency = '{$currency}';
currency = currency == '' ? $('#currency').val() : currency;

var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="formName=`$form.formName``$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type;
{literal}
if (typeof(CRM.vars) != "undefined") {
if (typeof(CRM.vars.coreForm) != "undefined") {
Expand All @@ -111,15 +114,18 @@
}
}
}
dataUrl = dataUrl + "&payment_instrument_id=" + payment_instrument_id;
dataUrl = dataUrl + "&payment_instrument_id=" + payment_instrument_id + "&currency=" + currency;

// Processors like pp-express will hide the form submit buttons, so re-show them when switching
$('.crm-submit-buttons', $form).show().find('input').prop('disabled', true);
CRM.loadPage(dataUrl, {target: '#billing-payment-block'});
}

$('[name=payment_processor_id]').on('change.paymentBlock', function() {
buildPaymentBlock($(this).val());
$('[name=payment_processor_id], #currency').on('change.paymentBlock', function() {
var payment_processor_id = $('[name=payment_processor_id]:checked').val() == undefined ? $('[name=payment_processor_id]').val() : $('[name=payment_processor_id]:checked').val();
if (payment_processor_id != undefined) {
buildPaymentBlock(payment_processor_id);
}
});

$('#payment_instrument_id').on('change.paymentBlock', function() {
Expand Down

0 comments on commit 44f9625

Please sign in to comment.