CRM-19107 Fixed PayPal Express redirection issue.
authorSunil Pawar <sunil@cividesk.com>
Mon, 1 Jan 2018 18:19:47 +0000 (23:49 +0530)
committerSunil Pawar <sunil@cividesk.com>
Mon, 1 Jan 2018 18:19:47 +0000 (23:49 +0530)
CRM/Core/Payment/PayPalImpl.php
CRM/Financial/Form/Payment.php
templates/CRM/common/paymentBlock.tpl

index bd1fb53e7ac518030bfc66d969e1ca26da8da036..b6f255db8609cafb1f701c4f223102e9508a0919 100644 (file)
@@ -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',
index b5d2c2206611d6e337db1ba7f36e2c449e0116a1..4863f5848be048e93c601745f83f29fd8767289c 100644 (file)
@@ -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,
index f509332d76001db4f7f56d88c7b6498da7409252..8436164bff90ee830c417cd5abbcc44460cdc263 100644 (file)
 
       var payment_instrument_id = $('#payment_instrument_id').val();
 
-      var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="&currency=`$currency`&`$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type;
+      var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="&formName=`$form.formName`&currency=`$currency`&`$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type;
       {literal}
       if (typeof(CRM.vars) != "undefined") {
         if (typeof(CRM.vars.coreForm) != "undefined") {