$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
}
+
/**
- * Get current currency from DB or use default currency.
+ * Get the currency in use.
*
- * @param array $submittedValues
+ * This just defaults to getting the default currency
+ * where the form does not have better currency support.
*
* @return string
*/
- public function getCurrency($submittedValues = []) {
- return $submittedValues['currency'] ?? $this->_values['currency'] ?? CRM_Core_Config::singleton()->defaultCurrency;
+ public function getCurrency(): string {
+ return (string) \Civi::settings()->get('defaultCurrency');
}
/**
return $defaults;
}
+ /**
+ * Get submitted currency, or use default.
+ *
+ * @return string
+ */
+ public function getCurrency(): string {
+ return (string) $this->getSubmittedValue('currency') ?: CRM_Core_Config::singleton()->defaultCurrency;
+ }
+
/**
* Build the form object.
*
$params = [
'contact_id' => $this->_contactID,
- 'currency' => $this->getCurrency($submittedValues),
+ 'currency' => $this->getCurrency(),
'skipCleanMoney' => TRUE,
'id' => $this->_id,
];
* historic, possible handling in here. As we clean that up we should
* add deprecation notices into here.
*
- * @param array $submittedValues
- * Array allowed so forms inheriting this class do not break.
- * Ideally we would make a clear standard around how submitted values
- * are stored (is $this->_values consistently doing that?).
- *
* @return string
*/
- public function getCurrency($submittedValues = []) {
+ public function getCurrency() {
$currency = $this->_values['currency'] ?? NULL;
// For event forms, currency is in a different spot
if (empty($currency)) {
}
}
unset($params['note']);
- $contributionParams['currency'] = \Civi::settings()->get('defaultCurrency');;
+ $contributionParams['currency'] = $this->getCurrency();
$contributionParams['contact_id'] = $this->_contactID;
if ($this->_id) {
}
else {
//lets carry currency, CRM-4453
- $params['fee_currency'] = \Civi::settings()->get('defaultCurrency');
+ $params['fee_currency'] = $this->getCurrency();
if (!isset($lineItem[0])) {
$lineItem[0] = [];
}
'tax_amount' => $params['tax_amount'],
'amount_level' => $params['amount_level'],
'invoice_id' => $params['invoiceID'],
- 'currency' => \Civi::settings()->get('defaultCurrency'),
+ 'currency' => $this->getCurrency(),
'source' => $this->getSourceText(),
'is_pay_later' => FALSE,
'campaign_id' => $this->getSubmittedValue('campaign_id'),
'fee_level' => $params['amount_level'] ?? NULL,
'is_pay_later' => FALSE,
'fee_amount' => $params['fee_amount'] ?? NULL,
- 'fee_currency' => \Civi::settings()->get('defaultCurrency'),
+ 'fee_currency' => $this->getCurrency(),
'campaign_id' => $this->getSubmittedValue('campaign_id'),
'note' => $this->getSubmittedValue('note'),
'is_test' => ($this->_mode === 'test)'),
];
}
- /**
- * Get the currency in use.
- *
- * This just defaults to getting the default currency
- * as other currencies are not supported on the membership
- * forms at the moment.
- *
- * @param array $submittedValues
- *
- * @return string
- */
- public function getCurrency($submittedValues = []): string {
- return CRM_Core_Config::singleton()->defaultCurrency;
- }
-
/**
* Get the relevant payment instrument id.
*