Skip to content

Commit

Permalink
Merge pull request civicrm#11329 from eileenmcnaughton/currency
Browse files Browse the repository at this point in the history
Currency
  • Loading branch information
colemanw authored and sluc23 committed Jan 10, 2018
2 parents 3fc6498 + ba7fe30 commit e502b42
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
21 changes: 21 additions & 0 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2360,4 +2360,25 @@ public function assignBillingName($params = array()) {
return $name;
}

/**
* Get the currency for the form.
*
* @todo this should be overriden on the forms rather than having this
* historic, possible handling in here. As we clean that up we should
* add deprecation notices into here.
*/
public function getCurrency() {
$currency = CRM_Utils_Array::value('currency', $this->_values);
// For event forms, currency is in a different spot
if (empty($currency)) {
$currency = CRM_Utils_Array::value('currency', CRM_Utils_Array::value('event', $this->_values));
}
if (empty($currency)) {
$currency = CRM_Utils_Request::retrieveValue('currency', 'String');
}
// @todo If empty there is a problem - we should probably put in a deprecation notice
// to warn if that seems to be happening.
return $currency;
}

}
13 changes: 13 additions & 0 deletions CRM/Core/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,19 @@ protected function getBaseReturnUrl() {
return $baseURL;
}

/**
* Get the currency for the transaction.
*
* Handle any inconsistency about how it is passed in here.
*
* @param $params
*
* @return string
*/
protected function getCurrency($params) {
return CRM_Utils_Array::value('currencyID', $params, CRM_Utils_Array::value('currency', $params));
}

/**
* Get url to return to after cancelled or failed transaction.
*
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Payment/PayPalImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public function doDirectPayment(&$params, $component = 'contribute') {

$args['paymentAction'] = 'Sale';
$args['amt'] = $params['amount'];
$args['currencyCode'] = $params['currencyID'];
$args['currencyCode'] = $this->getCurrency($params);
$args['invnum'] = $params['invoiceID'];
$args['ipaddress'] = $params['ip_address'];
$args['creditCardType'] = $params['credit_card_type'];
Expand Down
6 changes: 1 addition & 5 deletions CRM/Core/Payment/ProcessorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ public static function preProcess(&$form, $type = NULL, $mode = NULL) {

$form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons());

$currency = CRM_Utils_Array::value('currency', $form->_values);
// For event forms, currency is in a different spot
if (empty($currency)) {
$currency = CRM_Utils_Array::value('currency', $form->_values['event']);
}
$currency = $form->getCurrency();
$form->assign('currency', $currency);

// also set cancel subscription url
Expand Down

0 comments on commit e502b42

Please sign in to comment.