CRM-16555 paypal express is still not replacing the confirm button with it's own...
authorEileen McNaughton <eileen@fuzion.co.nz>
Wed, 3 Jun 2015 05:40:29 +0000 (17:40 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Thu, 4 Jun 2015 09:07:24 +0000 (21:07 +1200)
CRM/Core/Payment.php
CRM/Core/Payment/Form.php
CRM/Core/Payment/PayPalImpl.php
CRM/Core/Payment/ProcessorForm.php
templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Core/BillingBlock.tpl
templates/CRM/Event/Form/Registration/Register.tpl
templates/CRM/Financial/Form/PaypalExpress.tpl

index 3a35c663eb5de0adb84350bc88241653fc743491..7d70cd484ccd130f6dea6fe869b2b7d96938c342 100644 (file)
@@ -111,7 +111,7 @@ abstract class CRM_Core_Payment {
    *   Should form building stop at this point?
    */
   public function buildForm(&$form) {
-     return FALSE;
+    return FALSE;
   }
 
   /**
index cde6d66028491f2c491407cfa517da0b741e8a52..2251c4608dc7b221ef6b7382dc3223b4486226b4 100644 (file)
@@ -268,7 +268,6 @@ class CRM_Core_Payment_Form {
       }
     }
 
-
     self::setPaymentFieldsByProcessor($form, $processor, empty($isBillingDataOptional));
     self::addCommonFields($form, !$isBillingDataOptional, $form->_paymentFields);
     self::addRules($form, $form->_paymentFields);
index 5316ff5523c7412fbf87eb56a7d6c4c849dea68e..db61e765fb5a775a1ff415e26b75f3f4a6bfb83c 100644 (file)
@@ -96,6 +96,16 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
   public function buildForm(&$form) {
     if ($this->_processorName == 'PayPal Express' || $this->_processorName == 'PayPal Pro') {
       $this->addPaypalExpressCode($form);
+      if ($this->_processorName == 'PayPal Express') {
+        CRM_Core_Region::instance('billing-block-post')->add(array(
+          'template' => 'CRM/Financial/Form/PaypalExpress.tpl',
+        ));
+      }
+      if ($this->_processorName == 'PayPal Pro') {
+        CRM_Core_Region::instance('billing-block-pre')->add(array(
+          'template' => 'CRM/Financial/Form/PaypalPro.tpl',
+        ));
+      }
     }
     return FALSE;
   }
@@ -106,14 +116,14 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment {
    *
    * @param $form
    */
-  protected static function addPaypalExpressCode(&$form) {
+  protected function addPaypalExpressCode(&$form) {
     if (empty($form->isBackOffice)) {
       $form->_expressButtonName = $form->getButtonName('upload', 'express');
       $form->assign('expressButtonName', $form->_expressButtonName);
       $form->add(
         'image',
         $form->_expressButtonName,
-        $form->_paymentProcessor['url_button'],
+        $this->_paymentProcessor['url_button'],
         array('class' => 'crm-form-submit')
       );
     }
index 1fc9db762da0935dd05be5a4daffc4feb44aa921..20417cd4f79855668248f87ca5bad1fd261d501e 100644 (file)
  +--------------------------------------------------------------------+
  */
 
+use Civi\Payment\System;
 /**
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2015
  */
 
+
 /**
- * base class for building payment block for online contribution / event pages
+ * Base class for building payment block for online contribution / event pages.
  */
 class CRM_Core_Payment_ProcessorForm {
 
@@ -56,7 +58,7 @@ class CRM_Core_Payment_ProcessorForm {
     }
 
     $form->set('paymentProcessor', $form->_paymentProcessor);
-    $form->_paymentObject = CRM_Core_Payment::singleton($mode, $form->_paymentProcessor, $form);
+    $form->_paymentObject = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
 
     $form->assign('suppressSubmitButton', $form->_paymentObject->isSuppressSubmitButtons());
 
index 4944a35aaa3ed50a685907e0c258dc4c822cbce7..8c95b561a477d7f2da6ee21dae9fc465e046dcc0 100644 (file)
   {literal}
 
   CRM.$(function($) {
-    toggleConfirmButton();
     enableHonorType();
     showRecurHelp();
     skipPaymentMethod();
index ef1c67237fd80bbdc6136303cf5e6b7408a4ad3c..71d676f90cca58e2c887cc0569a598fb9f38bf75 100644 (file)
@@ -31,8 +31,6 @@
         {$paymentTypeLabel}
       </legend>
       {crmRegion name="billing-block-pre"}
-        {* todo move this region assignment to paypal processor *}
-        {include file= "CRM/Financial/Form/PaypalPro.tpl"}
       {/crmRegion}
       <div class="crm-section billing_mode-section {$paymentTypeName}_info-section">
         {foreach from=$paymentFields item=paymentField}
         $('#credit_card_number').val(cc);
       });
     });
-    {/literal}
 
-    function toggleConfirmButton() {
-      var suppressSubmitButton = "{/literal}{$suppressSubmitButton}{literal}";
-      var elementObj = cj('input[name="payment_processor"]');
-      if ( elementObj.attr('type') == 'hidden' ) {
-        var processorTypeId = elementObj.val( );
-      }
-      else {
-        var processorTypeId = elementObj.filter(':checked').val();
-      }
+    $('input[name="payment_processor_id"]').change( function() {
+      function toggleConfirmButton() {
+        var suppressSubmitButton = {/literal}"{$suppressSubmitButton}"{literal};
+        var elementObj = $('input[name="payment_processor"]');
+        if ( elementObj.attr('type') == 'hidden' ) {
+          var processorTypeId = elementObj.val( );
+        }
+        else {
+          var processorTypeId = elementObj.filter(':checked').val();
+        }
 
-      if (suppressSubmitButton) {
-        cj("#crm-submit-buttons").hide();
-      }
-      else {
-        cj("#crm-submit-buttons").show();
+        if (suppressSubmitButton) {
+          $("#crm-submit-buttons").hide();
+        }
+        else {
+          $("#crm-submit-buttons").show();
+        }
       }
-    }
-
-    cj('input[name="payment_processor_id"]').change( function() {
       toggleConfirmButton();
     });
 
   </script>
+  {/literal}
 {/if}
 {/crmRegion}
 {crmRegion name="billing-block-post"}
   {* Payment processors sometimes need to append something to the end of the billing block. We create a region for
      clarity  - the plan is to move to assigning this through the payment processor to this region *}
-  {include file= "CRM/Financial/Form/PaypalExpress.tpl"}
 {/crmRegion}
 
index 2e067da84607d3dc1549c31aca91ee43784288ba..96a8b3f78d5d25b0f93f0a38a1e8c2a042699539 100644 (file)
     });
 
     CRM.$(function($) {
-      toggleConfirmButton();
       skipPaymentMethod();
     });
 
index 9e9044918d5deb56bf3021766d2efb5f374cf87f..ffef775580ad6fe1b583502abc630ab7e8b02142 100644 (file)
@@ -23,7 +23,7 @@
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-{if $paymentProcessor.payment_processor_type EQ 'PayPal_Express'}
+
   <div id="paypalExpress">
     {assign var=expressButtonName value='_qf_Main_upload_express'}
     <fieldset class="crm-group paypal_checkout-group">
@@ -44,4 +44,3 @@
       </div>
     </fieldset>
   </div>
-{/if}