From: Eileen McNaughton Date: Wed, 27 May 2015 21:53:18 +0000 (+1200) Subject: CRM-16555 introduce separated payment form as snippet X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=aaff4c697d6f94f01f5dacf5a3d876a95e50f5cb;p=civicrm-core.git CRM-16555 introduce separated payment form as snippet The point of this is to allow the payment form to be disambiguated from the contribution & event forms - allowing it to be called from elsewhere --- diff --git a/CRM/Core/xml/Menu/payment.xml b/CRM/Core/xml/Menu/payment.xml new file mode 100644 index 0000000000..1d5d58eb27 --- /dev/null +++ b/CRM/Core/xml/Menu/payment.xml @@ -0,0 +1,11 @@ + + + + + civicrm/payment/form + 1 + CRM_Financial_Form_Payment + true + 0 + + diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index d43def24b5..cbe6c24114 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -183,7 +183,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * @return array * associated array with payment processor related fields */ - public static function getPayment($paymentProcessorID, $mode) { + public static function getPayment($paymentProcessorID, $mode = 'based_on_id') { if (!$paymentProcessorID) { CRM_Core_Error::fatal(ts('Invalid value passed to getPayment function')); } diff --git a/CRM/Financial/Form/Payment.php b/CRM/Financial/Form/Payment.php new file mode 100644 index 0000000000..9d8ad34e6a --- /dev/null +++ b/CRM/Financial/Form/Payment.php @@ -0,0 +1,73 @@ +_paymentProcessorID = CRM_Utils_Request::retrieve('processor_id', 'Integer', CRM_Core_DAO::$_nullObject, + TRUE); + + $this->assignBillingType(); + + // @todo - round about way to load it - just load as an object using civi\payment\system::getByProcessor + $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID, 'unused'); + CRM_Core_Payment_ProcessorForm::preProcess($this); + + //@todo - figure out how to deal with payment express. + //get payPal express id and make it available to template + //$payPalExpressId = ($values['payment_processor_type'] == 'PayPal_Express') ? $values['id'] : 0; + // $this->assign('payPalExpressId', $payPalExpressId); + + // Add JS to show icons for the accepted credit cards + + $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames(); + CRM_Core_Resources::singleton() + ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10) + // workaround for CRM-13634 + // ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes))); + ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';'); + + $this->assign('paymentProcessorID', $this->_paymentProcessorID); + } + + public function buildQuickForm() { + CRM_Core_Payment_ProcessorForm::buildQuickForm($this); + } + +} diff --git a/templates/CRM/Core/BillingBlock.tpl b/templates/CRM/Core/BillingBlock.tpl index abf23e86f6..78d5d05e18 100644 --- a/templates/CRM/Core/BillingBlock.tpl +++ b/templates/CRM/Core/BillingBlock.tpl @@ -30,9 +30,10 @@ {$paymentTypeLabel} - {if $form.$expressButtonName} - {include file= "CRM/Core/paypalexpress.tpl"} - {/if} + {crmRegion name="billing-block-pre"} + {* todo move this region assignment to paypal processor *} + {include file= "CRM/Financial/PaypalPro.tpl"} + {/crmRegion}
{foreach from=$paymentFields item=paymentField}
@@ -201,5 +202,12 @@ {/literal} {/if} - {/crmRegion} + +{if $is_monetary} + {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/PaypalExpress.tpl"} + {/crmRegion} +{/if} diff --git a/templates/CRM/Core/paypalexpress.tpl b/templates/CRM/Core/BillingBlockWrapper.tpl similarity index 73% rename from templates/CRM/Core/paypalexpress.tpl rename to templates/CRM/Core/BillingBlockWrapper.tpl index b0b4b0c3ba..274c62801d 100644 --- a/templates/CRM/Core/paypalexpress.tpl +++ b/templates/CRM/Core/BillingBlockWrapper.tpl @@ -24,14 +24,8 @@ +--------------------------------------------------------------------+ *} -
-
- {ts}If you have a PayPal account, you can click the PayPal button to continue. Otherwise, fill in the credit card and billing information on this form and click Continue at the bottom of the page.{/ts} -
-
-
-
- {$form.$expressButtonName.html} -
Save time. Checkout securely. Pay without sharing your financial information.
-
+{* wrapper for the billing block including the div to make the block swappable & the js to make that happen +This allows the billing block to change when the card type changes *} +
+ {include file="CRM/Core/BillingBlock.tpl"}
diff --git a/templates/CRM/Financial/Form/Payment.tpl b/templates/CRM/Financial/Form/Payment.tpl new file mode 100644 index 0000000000..e78ae8f578 --- /dev/null +++ b/templates/CRM/Financial/Form/Payment.tpl @@ -0,0 +1,27 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.6 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2015 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} + +{include file="CRM/Core/BillingBlockWrapper.tpl"} diff --git a/templates/CRM/Financial/Form/PaypalExpress.tpl b/templates/CRM/Financial/Form/PaypalExpress.tpl new file mode 100644 index 0000000000..9e9044918d --- /dev/null +++ b/templates/CRM/Financial/Form/PaypalExpress.tpl @@ -0,0 +1,47 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.6 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2015 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | 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'} +
+ {ts}Checkout with PayPal{/ts} +
+
+
+ {ts}Click the PayPal button to continue.{/ts} +
+
+
+
+
+ {$form.$expressButtonName.html} Checkout securely. Pay without sharing your financial information. +
+
+
+
+
+
+{/if} diff --git a/templates/CRM/Financial/Form/PaypalPro.tpl b/templates/CRM/Financial/Form/PaypalPro.tpl new file mode 100644 index 0000000000..472e5b18d7 --- /dev/null +++ b/templates/CRM/Financial/Form/PaypalPro.tpl @@ -0,0 +1,38 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 4.6 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2015 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{if $form.$expressButtonName} +
+
+ {ts}If you have a PayPal account, you can click the PayPal button to continue. Otherwise, fill in the credit card and billing information on this form and click Continue at the bottom of the page.{/ts} +
+
+
+
+ {$form.$expressButtonName.html} +
Save time. Checkout securely. Pay without sharing your financial information.
+
+
+{/if}