Skip to content

Commit

Permalink
Merge pull request #19910 from eileenmcnaughton/mem_pay
Browse files Browse the repository at this point in the history
[REF] [Towards membership api] Cleanup access to payment_processor_id
  • Loading branch information
monishdeb authored Mar 26, 2021
2 parents 26b0187 + 17dcf20 commit cc89c07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ public function assignBillingType() {
/**
* @return int
*/
public function getPaymentProcessorID() {
return $this->_paymentProcessorID;
public function getPaymentProcessorID(): int {
return (int) $this->_paymentProcessorID;
}

/**
Expand Down
13 changes: 11 additions & 2 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ public function submit(): void {
$params['financial_type_id'] = $this->getFinancialTypeID();

//get the payment processor id as per mode. Try removing in favour of beginPostProcess.
$params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->_paymentProcessor['id'];
$params['payment_processor_id'] = $formValues['payment_processor_id'] = $this->getPaymentProcessorID();
$params['register_date'] = CRM_Utils_Time::date('YmdHis');

// add all the additional payment params we need
Expand Down Expand Up @@ -1808,7 +1808,7 @@ protected function legacyProcessRecurringContribution(array $params, $contactID)
}
$recurParams['invoice_id'] = $this->getInvoiceID();
$recurParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
$recurParams['payment_processor_id'] = $params['payment_processor_id'] ?? NULL;
$recurParams['payment_processor_id'] = $this->getPaymentProcessorID();
$recurParams['is_email_receipt'] = (bool) $this->getSubmittedValue('send_receipt');
// we need to add a unique trxn_id to avoid a unique key error
// in paypal IPN we reset this when paypal sends us the real trxn id, CRM-2991
Expand Down Expand Up @@ -1879,4 +1879,13 @@ protected function isCreateRecurringContribution(): bool {
return $this->_mode && $this->getSubmittedValue('auto_renew');
}

/**
* Get the payment processor ID.
*
* @return int
*/
public function getPaymentProcessorID(): int {
return (int) ($this->getSubmittedValue('payment_processor_id') ?: $this->_paymentProcessor['id']);
}

}

0 comments on commit cc89c07

Please sign in to comment.