From 8d3963e06ad4c515753c7ac2388129c644fec414 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Thu, 5 Mar 2020 21:55:03 +0000 Subject: [PATCH] Handle non-default currency --- CRM/Event/Cart/Form/Checkout/Payment.php | 35 ++++++++----------- .../CRM/Event/Cart/Form/Checkout/Payment.tpl | 1 + 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/CRM/Event/Cart/Form/Checkout/Payment.php b/CRM/Event/Cart/Form/Checkout/Payment.php index 5fc0f88097..5f79f4ec27 100644 --- a/CRM/Event/Cart/Form/Checkout/Payment.php +++ b/CRM/Event/Cart/Form/Checkout/Payment.php @@ -17,6 +17,11 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { public $is_pay_later = FALSE; public $pay_later_receipt; + /** + * @var array + */ + protected $_values = []; + /** * Register a participant. * @@ -122,6 +127,7 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { if ($payment_processor_id === NULL && $event_in_cart->event->payment_processor !== NULL) { $payment_processor_id = $event_in_cart->event->payment_processor; $this->financial_type_id = $event_in_cart->event->financial_type_id; + $this->_values['currency'] = $event_in_cart->event->currency; } else { if ($event_in_cart->event->payment_processor !== NULL && $event_in_cart->event->payment_processor !== $payment_processor_id) { @@ -141,28 +147,17 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { } } - if ($payment_processor_id == NULL) { - CRM_Core_Error::statusBounce(ts('A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).')); - } - - $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($payment_processor_id, $this->_mode); - $this->assign('paymentProcessor', $this->_paymentProcessor); - - CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, FALSE); - - if ($can_pay_later || self::is_administrator()) { - $this->addElement('checkbox', 'is_pay_later', - $pay_later_text - ); - $this->addElement('checkbox', 'payment_completed', - ts('Payment Completed') - ); + if ($can_pay_later) { + $this->addElement('checkbox', 'is_pay_later', $pay_later_text); + $this->addElement('checkbox', 'payment_completed', ts('Payment Completed')); $this->assign('pay_later_instructions', $this->pay_later_receipt); } - - // Event Cart does not support multiple payment processors - // so we cannot call $this->preProcessPaymentOptions(); - CRM_Financial_Form_Payment::addCreditCardJs($this->_paymentProcessor['id']); + else { + $this->_paymentProcessorIDs = [$payment_processor_id]; + $this->assignPaymentProcessor(FALSE); + CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, FALSE); + } + $this->assign('currency', $this->getCurrency()); } /** diff --git a/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl b/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl index 0f3168ab85..fba3a4770c 100644 --- a/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl +++ b/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl @@ -88,6 +88,7 @@  {$total|crmMoney:$currency|string_format:"%10s"} + -- 2.25.1