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

[REF] [Towards membership api] Cleanup access to payment_processor_id #19910

Merged
merged 1 commit into from
Mar 26, 2021
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
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']);
}

}