From fb5e89bc475d754944120128187eff06167f1fe1 Mon Sep 17 00:00:00 2001 From: Sunil Pawar Date: Mon, 1 Jan 2018 23:49:47 +0530 Subject: [PATCH] CRM-19107 Fixed PayPal Express redirection issue. --- CRM/Core/Payment/PayPalImpl.php | 12 +++++++++++- CRM/Financial/Form/Payment.php | 7 +++++++ templates/CRM/common/paymentBlock.tpl | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index bd1fb53e7a..b6f255db86 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -139,7 +139,17 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { protected function addPaypalExpressCode(&$form) { // @todo use $this->isBackOffice() instead, test. if (empty($form->isBackOffice)) { - $form->_expressButtonName = $form->getButtonName('upload', 'express'); + /* + if payment method selected using ajax call then form object is of 'CRM_Financial_Form_Payment', + instead of 'CRM_Contribute_Form_Contribution_Main' so it generate wrong button name + and then clicking on express button it redirect to confirm screen rather than PayPal Express form + */ + if ('CRM_Financial_Form_Payment' == get_class($form) && $form->_formName) { + $form->_expressButtonName = '_qf_'.$form->_formName.'_upload_express'; + } + else { + $form->_expressButtonName = $form->getButtonName('upload', 'express'); + } $form->assign('expressButtonName', $form->_expressButtonName); $form->add( 'image', diff --git a/CRM/Financial/Form/Payment.php b/CRM/Financial/Form/Payment.php index b5d2c22066..4863f5848b 100644 --- a/CRM/Financial/Form/Payment.php +++ b/CRM/Financial/Form/Payment.php @@ -50,12 +50,19 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form { */ public $isBackOffice = FALSE; + /** + * @var String + */ + public $_formName = ''; + /** * Set variables up before form is built. */ public function preProcess() { parent::preProcess(); + $this->_formName = CRM_Utils_Request::retrieve('formName', 'String', $this); + $this->_values['custom_pre_id'] = CRM_Utils_Request::retrieve('pre_profile_id', 'Integer', $this); $this->_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, diff --git a/templates/CRM/common/paymentBlock.tpl b/templates/CRM/common/paymentBlock.tpl index f509332d76..8436164bff 100644 --- a/templates/CRM/common/paymentBlock.tpl +++ b/templates/CRM/common/paymentBlock.tpl @@ -111,7 +111,7 @@ var payment_instrument_id = $('#payment_instrument_id').val(); - var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="¤cy=`$currency`&`$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type; + var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="&formName=`$form.formName`¤cy=`$currency`&`$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type; {literal} if (typeof(CRM.vars) != "undefined") { if (typeof(CRM.vars.coreForm) != "undefined") { -- 2.25.1