The payment form snippet has been extracted so it can be called from anywhere, use this & remove the over-loaded snippet
note the change of field name is to align front end & back-end but still an issue as back-end is select & front end is radio
CRM-16555 last may have been too agressive
CRM-16555 test fixes
x
if ($this->_online) {
$element->freeze();
}
+
$totalAmount = NULL;
if (empty($this->_lineItems)) {
$buildPriceSet = FALSE;
public function postProcess() {
$contactID = $this->getContactID();
$isPayLater = $this->_params['is_pay_later'];
- if (isset($this->_params['payment_processor']) && $this->_params['payment_processor'] == 0) {
+ if (isset($this->_params['payment_processor_id']) && $this->_params['payment_processor_id'] == 0) {
$this->_params['is_pay_later'] = $isPayLater = TRUE;
}
// add a description field at the very beginning
$form->_values['fee'] = $priceSetFields['fields'];
$form->_priceSetId = $priceSetID;
$form->setFormAmountFields($priceSetID);
- if (!empty($params['payment_processor'])) {
- $form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array('id' => $params['payment_processor']));
+ if (!empty($params['payment_processor_id'])) {
+ $form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array(
+ 'id' => $params['payment_processor_id'],
+ ));
if ($form->_paymentProcessor['billing_mode'] == 1) {
$form->_contributeMode = 'direct';
}
}
}
else {
- $form->_params['payment_processor'] = 0;
+ $form->_params['payment_processor_id'] = 0;
}
$priceFields = $priceFields[$priceSetID]['fields'];
CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution');
*/
public static function getFormParams($id, array $params) {
if (!isset($params['is_pay_later'])) {
- if (!empty($params['payment_processor'])) {
+ if (!empty($params['payment_processor_id'])) {
$params['is_pay_later'] = 0;
}
else {
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $pid => $value) {
if (!empty($value['is_default'])) {
- $this->_defaults['payment_processor'] = $pid;
+ $this->_defaults['payment_processor_id'] = $pid;
}
}
}
// Build payment processor form
if (empty($_GET['onbehalf'])) {
CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
- // Return if we are in an ajax callback
+ // Return if we are in an ajax - this is probably redundant now as
+ // processor does not call this form for a snippet anymore - but unsure about
+ // cdType
if ($this->_snippet) {
return;
}
}
if (count($pps) > 1) {
- $this->addRadio('payment_processor', ts('Payment Method'), $pps,
+ $this->addRadio('payment_processor_id', ts('Payment Method'), $pps,
NULL, " ", TRUE
);
}
elseif (!empty($pps)) {
$key = array_keys($pps);
$key = array_pop($key);
- $this->addElement('hidden', 'payment_processor', $key);
+ $this->addElement('hidden', 'payment_processor_id', $key);
if ($key === 0) {
$this->assign('is_pay_later', $this->_values['is_pay_later']);
$this->assign('pay_later_text', $this->_values['pay_later_text']);
}
if (!empty($fields['is_recur']) &&
- CRM_Utils_Array::value('payment_processor', $fields) == 0
+ CRM_Utils_Array::value('payment_processor_id', $fields) == 0
) {
$errors['_qf_default'] = ts('You cannot set up a recurring contribution if you are not paying online by credit card.');
}
}
// also return if paylater mode
- if (CRM_Utils_Array::value('payment_processor', $fields) == 0 && $self->_isBillingAddressRequiredForPayLater == 0) {
+ if (CRM_Utils_Array::value('payment_processor_id', $fields) == 0 && $self->_isBillingAddressRequiredForPayLater == 0) {
return empty($errors) ? TRUE : $errors;
}
if (!empty($self->_paymentFields)) {
CRM_Core_Form::validateMandatoryFields($self->_paymentFields, $fields, $errors);
}
- CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor'], $fields, $errors, $self);
+ CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor_id'], $fields, $errors, $self);
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
if (($this->_values['is_pay_later'] &&
empty($this->_paymentProcessor) &&
!array_key_exists('hidden_processor', $params)) ||
- (!empty($params['payment_processor']) && $params['payment_processor'] == 0)
+ (!empty($params['payment_processor_id']) && $params['payment_processor_id'] == 0)
) {
$params['is_pay_later'] = 1;
}
$form->_paymentProcessors = $noFees ? array() : $form->get('paymentProcessors');
$form->_paymentProcessorID = NULL;
if ($form->_paymentProcessors) {
- // Fetch type during ajax request
- if (isset($_GET['type']) && $form->_snippet) {
- $form->_paymentProcessorID = CRM_Utils_Request::retrieve('type', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, 0);
- }
- // Remember type during form post
- elseif (!empty($form->_submitValues)) {
- $form->_paymentProcessorID = CRM_Utils_Array::value('payment_processor', $form->_submitValues);
+ if (!empty($form->_submitValues)) {
+ $form->_paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $form->_submitValues);
$form->_paymentProcessor = CRM_Utils_Array::value($form->_paymentProcessorID, $form->_paymentProcessors);
$form->set('type', $form->_paymentProcessorID);
$form->set('mode', $form->_mode);
if (!empty($this->_paymentProcessors)) {
foreach ($this->_paymentProcessors as $pid => $value) {
if (!empty($value['is_default'])) {
- $this->_defaults['payment_processor'] = $pid;
+ $this->_defaults['payment_processor_id'] = $pid;
}
}
}
if ($this->_values['event']['is_monetary']) {
if (count($pps) > 1) {
- $this->addRadio('payment_processor', ts('Payment Method'), $pps,
+ $this->addRadio('payment_processor_id', ts('Payment Method'), $pps,
NULL, " "
);
}
elseif (!empty($pps)) {
$ppKeys = array_keys($pps);
$currentPP = array_pop($ppKeys);
- $this->addElement('hidden', 'payment_processor', $currentPP);
+ $this->addElement('hidden', 'payment_processor_id', $currentPP);
}
}
}
if ($self->_values['event']['is_monetary']) {
- if (empty($self->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 && !isset($fields['payment_processor'])) {
- $errors['payment_processor'] = ts('Please select a Payment Method');
+ if (empty($self->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 && !isset
+ ($fields['payment_processor_id'])) {
+ $errors['payment_processor_id'] = ts('Please select a Payment Method');
}
// return if this is express mode
if ($self->_paymentProcessor &&
$params['is_primary'] = 1;
if ($this->_values['event']['is_pay_later']
- && (!array_key_exists('hidden_processor', $params) || $params['payment_processor'] == 0)
+ && (!array_key_exists('hidden_processor', $params) || $params['payment_processor_id'] == 0)
) {
$params['is_pay_later'] = 1;
}
<td>{$form.contact_id.html}</td>
{/if}
{if $contributionMode}
- <tr class="crm-contribution-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
+ <tr class="crm-contribution-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
{/if}
<tr class="crm-contribution-form-block-contribution_type_id crm-contribution-form-block-financial_type_id">
<td class="label">{$form.financial_type_id.label}</td><td{$valueStyle}>{$form.financial_type_id.html}
</table>
+ <div id="billing-payment-block">
<div class="accordion ui-accordion ui-widget ui-helper-reset">
{* Billing Pane is the only billing pane currently *}
{foreach from=$billingPanes key=paneName item=paneValue}
</div>
{/foreach}
</div>
+ </div>
+ {include file="CRM/common/paymentBlock.tpl"}
<!-- start of soft credit -->
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-processed {if $noSoftCredit}collapsed{/if}" id="softCredit">
{if $snippet and !empty($isOnBehalfCallback)}
{include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"}
-{* Callback snippet: Load payment processor *}
-{elseif $snippet}
-{include file="CRM/Core/BillingBlock.tpl"}
- {if $is_monetary}
- {* Put PayPal Express button after customPost block since it's the submit button in this case. *}
- {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">
- <legend>{ts}Checkout with PayPal{/ts}</legend>
- <div class="section">
- <div class="crm-section paypalButtonInfo-section">
- <div class="content">
- <span class="description">{ts}Click the PayPal button to continue.{/ts}</span>
- </div>
- <div class="clear"></div>
- </div>
- <div class="crm-section {$expressButtonName}-section">
- <div class="content">
- {$form.$expressButtonName.html} <span class="description">Checkout securely. Pay without sharing your financial information. </span>
- </div>
- <div class="clear"></div>
- </div>
- </div>
- </fieldset>
- </div>
- {/if}
- {/if}
-
-{* Main Form *}
{else}
{literal}
<script type="text/javascript">
</fieldset>
{/if}
- {if $form.payment_processor.label}
+ {if $form.payment_processor_id.label}
{* PP selection only works with JS enabled, so we hide it initially *}
<fieldset class="crm-group payment_options-group" style="display:none;">
<legend>{ts}Payment Options{/ts}</legend>
<div class="crm-section payment_processor-section">
- <div class="label">{$form.payment_processor.label}</div>
- <div class="content">{$form.payment_processor.html}</div>
+ <div class="label">{$form.payment_processor_id.label}</div>
+ <div class="content">{$form.payment_processor_id.html}</div>
<div class="clear"></div>
</div>
</fieldset>
<div id="billing-payment-block">
{* If we have a payment processor, load it - otherwise it happens via ajax *}
{if $paymentProcessorID or $isBillingAddressRequiredForPayLater}
- {include file="CRM/Contribute/Form/Contribution/Main.tpl" snippet=4}
+ {include file="CRM/Financial/Form/Payment.tpl" snippet=4}
{/if}
</div>
{include file="CRM/common/paymentBlock.tpl"}
payment_information.show();
}
}
-
+
function skipPaymentMethod() {
var flag = false;
cj('.price-set-option-content input').each( function(){
<div id="billing-payment-block">
{include file="CRM/Core/BillingBlock.tpl"}
</div>
+{include file="CRM/common/paymentBlock.tpl"}
+--------------------------------------------------------------------+
*}
{* Callback snippet: Load payment processor *}
-{if $snippet}
- {include file="CRM/Core/BillingBlock.tpl"}
- <div id="paypalExpress">
- {* Put PayPal Express button after customPost block since it's the submit button in this case. *}
- {if $paymentProcessor.payment_processor_type EQ 'PayPal_Express'}
- {assign var=expressButtonName value='_qf_Register_upload_express'}
- <fieldset class="crm-group payPalExpress-group">
- <legend>{ts}Checkout with PayPal{/ts}</legend>
- <div class="description">{ts}Click the PayPal button to continue.{/ts}</div>
- <div>{$form.$expressButtonName.html} <span style="font-size:11px; font-family: Arial, Verdana;">Checkout securely. Pay without sharing your financial information. </span>
- </div>
- </fieldset>
- {/if}
- </div>
-{else}
+
{if $action & 1024}
{include file="CRM/Event/Form/Registration/PreviewHeader.tpl"}
{/if}
</fieldset>
{/if}
- {if $form.payment_processor.label}
+ {if $form.payment_processor_id.label}
<fieldset class="crm-group payment_options-group" style="display:none;">
<legend>{ts}Payment Options{/ts}</legend>
<div class="crm-section payment_processor-section">
- <div class="label">{$form.payment_processor.label}</div>
- <div class="content">{$form.payment_processor.html}</div>
+ <div class="label">{$form.payment_processor_id.label}</div>
+ <div class="content">{$form.payment_processor_id.html}</div>
<div class="clear"></div>
</div>
</fieldset>
{literal}
function toggleConfirmButton() {
var payPalExpressId = "{/literal}{$payPalExpressId}{literal}";
- var elementObj = cj('input[name="payment_processor"]');
+ var elementObj = cj('input[name="payment_processor_id"]');
if (elementObj.attr('type') == 'hidden') {
var processorTypeId = elementObj.val();
}
}
}
- cj('input[name="payment_processor"]').change(function () {
+ cj('input[name="payment_processor_id"]').change(function () {
toggleConfirmButton();
});
payment_processor.hide();
payment_information.hide();
// also unset selected payment methods
- cj('input[name="payment_processor"]').removeProp('checked');
+ cj('input[name="payment_processor_id"]').removeProp('checked');
}
else {
payment_options.show();
}
}
}
- {/literal}{/if}{literal}
+ {/literal}{literal}
</script>
{/literal}
}
{/literal}{/if}{literal}
- var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q='snippet=4&type='}"{literal} + type;
+ var dataUrl = {/literal}"{crmURL p='civicrm/payment/form' h=0 q='snippet=4&processor_id='}"{literal} + type;
{/literal}
{if $urlPathVar}
dataUrl = dataUrl + '&id=' + '{$contributionPageID}'
{/if}
- {if $qfKey}
- dataUrl = dataUrl + '&qfKey=' + '{$qfKey}'
- {/if}
{literal}
var response = cj.ajax({
CRM.$(function($) {
$('.crm-group.payment_options-group').show();
- $('input[name="payment_processor"]').change( function() {
+ $('#payment_processor_id').change( function() {
buildPaymentBlock( $(this).val() );
});
});
'billing_middle_name' => 'Goat',
'billing_last_name' => 'Gruff',
'selectMembership' => $this->_ids['membership_type'],
- 'payment_processor' => 1,
+ 'payment_processor_id' => 1,
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),
'billing_last_name' => 'Gruff',
'email' => 'billy@goat.gruff',
'selectMembership' => $this->_ids['membership_type'],
- 'payment_processor' => 1,
+ 'payment_processor_id' => 1,
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),
'billing_last_name' => 'Gruff',
'email' => 'billy@goat.gruff',
'selectMembership' => $this->_ids['membership_type'],
- 'payment_processor' => 1,
+ 'payment_processor_id' => 1,
'credit_card_number' => '4111111111111111',
'credit_card_type' => 'Visa',
'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),