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

Towards dev/financial/#16 Paypal unreliable getting payment processor type #12174

Merged
merged 1 commit into from
May 27, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

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)

@eileenmcnaughton
Copy link
Contributor Author

@mattwire this is also waiting for re-review from you

Copy link
Contributor

@mattwire mattwire left a 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).
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@eileenmcnaughton eileenmcnaughton merged commit 0763d2b into civicrm:master May 27, 2018
@eileenmcnaughton eileenmcnaughton deleted the matt branch May 27, 2018 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants