From: Eileen McNaughton Date: Wed, 3 Jun 2015 05:40:29 +0000 (+1200) Subject: CRM-16555 paypal express is still not replacing the confirm button with it's own... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=31d31a051a89de0b0bda1071c031adb3d67388a2;p=civicrm-core.git CRM-16555 paypal express is still not replacing the confirm button with it's own - but it's failing in the same way as in 4.6 & this is closer to how we want to code it --- diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 3a35c663eb..7d70cd484c 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -111,7 +111,7 @@ abstract class CRM_Core_Payment { * Should form building stop at this point? */ public function buildForm(&$form) { - return FALSE; + return FALSE; } /** diff --git a/CRM/Core/Payment/Form.php b/CRM/Core/Payment/Form.php index cde6d66028..2251c4608d 100644 --- a/CRM/Core/Payment/Form.php +++ b/CRM/Core/Payment/Form.php @@ -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); diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 5316ff5523..db61e765fb 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -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') ); } diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index 1fc9db762d..20417cd4f7 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -25,14 +25,16 @@ +--------------------------------------------------------------------+ */ +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()); diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 4944a35aaa..8c95b561a4 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -389,7 +389,6 @@ {literal} CRM.$(function($) { - toggleConfirmButton(); enableHonorType(); showRecurHelp(); skipPaymentMethod(); diff --git a/templates/CRM/Core/BillingBlock.tpl b/templates/CRM/Core/BillingBlock.tpl index ef1c67237f..71d676f90c 100644 --- a/templates/CRM/Core/BillingBlock.tpl +++ b/templates/CRM/Core/BillingBlock.tpl @@ -31,8 +31,6 @@ {$paymentTypeLabel} {crmRegion name="billing-block-pre"} - {* todo move this region assignment to paypal processor *} - {include file= "CRM/Financial/Form/PaypalPro.tpl"} {/crmRegion}
{foreach from=$paymentFields item=paymentField} @@ -199,36 +197,34 @@ $('#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(); }); + {/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} diff --git a/templates/CRM/Event/Form/Registration/Register.tpl b/templates/CRM/Event/Form/Registration/Register.tpl index 2e067da846..96a8b3f78d 100644 --- a/templates/CRM/Event/Form/Registration/Register.tpl +++ b/templates/CRM/Event/Form/Registration/Register.tpl @@ -170,7 +170,6 @@ }); CRM.$(function($) { - toggleConfirmButton(); skipPaymentMethod(); }); diff --git a/templates/CRM/Financial/Form/PaypalExpress.tpl b/templates/CRM/Financial/Form/PaypalExpress.tpl index 9e9044918d..ffef775580 100644 --- a/templates/CRM/Financial/Form/PaypalExpress.tpl +++ b/templates/CRM/Financial/Form/PaypalExpress.tpl @@ -23,7 +23,7 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{if $paymentProcessor.payment_processor_type EQ 'PayPal_Express'} +
{assign var=expressButtonName value='_qf_Main_upload_express'}
@@ -44,4 +44,3 @@
-{/if}