Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21315: (intra-rc regression) pay_later processor showing up in list of available processors #11141

Merged
merged 1 commit into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CRM/Contribute/Form/AbstractEditPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,4 +655,36 @@ protected function getDefaultPaymentInstrumentId() {
return key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
}

/**
* Add the payment processor select to the form.
*
* @param bool $isRequired
* Is it a mandatory field.
* @param bool $isBuildRecurBlock
* True if we want to build recur on change
* @param bool $isBuildAutoRenewBlock
* True if we want to build autorenew on change.
*/
protected function addPaymentProcessorSelect($isRequired, $isBuildRecurBlock = FALSE, $isBuildAutoRenewBlock = FALSE) {
if (!$this->_mode) {
return;
}
$js = ($isBuildRecurBlock ? array('onChange' => "buildRecurBlock( this.value ); return false;") : NULL);
if ($isBuildAutoRenewBlock) {
$js = array('onChange' => "buildAutoRenew( null, this.value, '{$this->_mode}');");
}
$element = $this->add('select',
'payment_processor_id',
ts('Payment Processor'),
array_diff_key($this->_processors, array(0 => 1)),
$isRequired,
$js
);
// The concept of _online is not really explained & the code is old
// @todo figure out & document.
if ($this->_online) {
$element->freeze();
}
}

}
20 changes: 4 additions & 16 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function buildQuickForm() {
}
}
$allPanes = array();
$recurJs = NULL;

//tax rate from financialType
$this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
$this->assign('currencies', json_encode(CRM_Core_OptionGroup::values('currencies_enabled')));
Expand All @@ -483,6 +483,8 @@ public function buildQuickForm() {
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$this->assign('invoicing', $invoicing);

$buildRecurBlock = FALSE;

// display tax amount on edit contribution page
if ($invoicing && $this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) {
$this->assign('totalTaxAmount', $this->_values['tax_amount']);
Expand Down Expand Up @@ -568,10 +570,10 @@ public function buildQuickForm() {
CRM_Contribute_Form_Contribution_Main::buildRecur($this);
$this->setDefaults(array('is_recur' => 0));
$this->assign('buildRecurBlock', TRUE);
$recurJs = array('onChange' => "buildRecurBlock( this.value ); return false;");
}
}
}
$this->addPaymentProcessorSelect(FALSE, $buildRecurBlock);

foreach ($paneNames as $name => $type) {
$allPanes[$name] = $this->generatePane($type, $defaults);
Expand Down Expand Up @@ -650,10 +652,8 @@ public function buildQuickForm() {

$this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);

$isUpdate = FALSE;
$component = 'contribution';
if ($this->_id) {
$isUpdate = TRUE;
$componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id);
if (CRM_Utils_Array::value('membership', $componentDetails)) {
$component = 'membership';
Expand Down Expand Up @@ -708,18 +708,6 @@ public function buildQuickForm() {
$this->addDateTime('cancel_date', ts('Cancelled / Refunded Date'), FALSE, array('formatType' => 'activityDateTime'));

$this->add('textarea', 'cancel_reason', ts('Cancellation / Refund Reason'), $attributes['cancel_reason']);
$this->add('text', 'refund_trxn_id', ts('Transaction ID for the refund payment'));
$element = $this->add('select',
'payment_processor_id',
ts('Payment Processor'),
$this->_processors,
NULL,
$recurJs
);

if ($this->_online) {
$element->freeze();
}

$totalAmount = NULL;
if (empty($this->_lineItems)) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ public function buildQuickForm() {
if ($this->_mode) {
// exclude events which are not monetary when credit card registration is used
$eventFieldParams['api']['params']['is_monetary'] = 1;
$this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE);
}
$this->addPaymentProcessorSelect(TRUE, FALSE, FALSE);

$element = $this->addEntityRef('event_id', ts('Event'), $eventFieldParams, TRUE);

Expand Down
8 changes: 1 addition & 7 deletions CRM/Member/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,7 @@ public function setDefaultValues() {
*/
public function buildQuickForm() {

if ($this->_mode) {
$this->add('select', 'payment_processor_id',
ts('Payment Processor'),
$this->_processors, TRUE,
array('onChange' => "buildAutoRenew( null, this.value, '{$this->_mode}');")
);
}
$this->addPaymentProcessorSelect(TRUE, FALSE, TRUE);
CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->getDefaultPaymentInstrumentId());
// Build the form for auto renew. This is displayed when in credit card mode or update mode.
// The reason for showing it in update mode is not that clear.
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Contribute/Form/Contribution.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
<span class="description">{ts}Date that a receipt was sent to the contributor.{/ts}</span>
</td>
</tr>
{if $contributionMode}
{if $form.payment_processor_id}
<tr class="crm-contribution-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="crm-marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
{/if}
</table>
Expand Down