-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Towards dev/financial/#16 Paypal unreliable getting payment processor type #12174
Conversation
@mattwire this is also waiting for re-review from you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton Ok, reviewed and tested this. It's effectively no functional change as we're just replacing string checks with const checks which should be more reliable. If you could just add the @deprecated
tag to _processorName then it's ok to merge.
/** | ||
* Processor type label. | ||
* | ||
* (Deprecated parameter but used in some messages). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @deprecated (Deprecated parameter but used in some messages).
@@ -110,7 +110,7 @@ public function isPayPalType($typeName) { | |||
* @throws \Civi\Payment\Exception\PaymentProcessorException | |||
*/ | |||
protected function supportsBackOffice() { | |||
if ($this->_processorName == ts('PayPal Pro')) { | |||
if ($this->isPayPalType($this::PAYPAL_PRO)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@@ -129,7 +129,7 @@ protected function supportsBackOffice() { | |||
* @throws \Civi\Payment\Exception\PaymentProcessorException | |||
*/ | |||
protected function supportsPreApproval() { | |||
if ($this->_processorName == ts('PayPal Express') || $this->_processorName == ts('PayPal Pro')) { | |||
if ($this->isPayPalType($this::PAYPAL_EXPRESS) || $this->isPayPalType($this::PAYPAL_PRO)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@@ -147,13 +147,13 @@ protected function supportsPreApproval() { | |||
public function buildForm(&$form) { | |||
if ($this->supportsPreApproval()) { | |||
$this->addPaypalExpressCode($form); | |||
if ($this->_processorName == ts('PayPal Express')) { | |||
if ($this->isPayPalType($this::PAYPAL_EXPRESS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
CRM_Core_Region::instance('billing-block-post')->add(array( | ||
'template' => 'CRM/Financial/Form/PaypalExpress.tpl', | ||
'name' => 'paypal_express', | ||
)); | ||
} | ||
if ($this->_processorName == ts('PayPal Pro')) { | ||
if ($this->isPayPalType($this::PAYPAL_PRO)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
*/ | ||
public function cancelSubscription(&$message = '', $params = array()) { | ||
if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal') { | ||
if ($this->isPayPalType($this::PAYPAL_PRO)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@@ -787,7 +790,7 @@ static public function handlePaymentNotification() { | |||
* @throws \Civi\Payment\Exception\PaymentProcessorException | |||
*/ | |||
public function updateSubscriptionBillingInfo(&$message = '', $params = array()) { | |||
if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal') { | |||
if ($this->isPayPalType($this::PAYPAL_PRO)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
*/ | ||
public function changeSubscriptionAmount(&$message = '', $params = array()) { | ||
if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal') { | ||
if ($this->isPayPalType($this::PAYPAL_PRO)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
*/ | ||
public function getPaymentFormFields() { | ||
if ($this->_processorName == ts('PayPal Pro')) { | ||
if ($this->isPayPalType($this::PAYPAL_PRO)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@@ -1177,7 +1181,7 @@ protected function mapPaypalParamsToCivicrmParams($fieldMap, $paypalParams) { | |||
* @throws \Civi\Payment\Exception\PaymentProcessorException | |||
*/ | |||
protected function isPaypalExpress($params) { | |||
if ($this->_processorName == ts('PayPal Express')) { | |||
if ($this->isPayPalType($this::PAYPAL_EXPRESS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Overview
Second reviewer's commit of #12007 - code standardisation in paypal class to prevent e-notices & missing details in messages
Before
PHP notice on some payment submissions (eg. via webform_civicrm) and use of "non-standard" param.
After
No PHP notice and uses standard parameter so it works with all payment submissions that use standard methods to populate the payment processor array ($this->_paymentProcessor).
Related: #12091
Technical Details
Comments
@mattwire if you can confirm this still seems good to you I will merge it. I basically went through your commit & re-did it - removing the problematic line in isSupported & fixing this incorrect change
https://github.com/civicrm/civicrm-core/pull/12091/files#diff-96a0ea19e8ac102ef100c35b3b3d1c31R506
I feel OK about this now (as a reviewer's commit)