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

Add payment method parent class #8

Merged
merged 3 commits into from
Oct 9, 2018

Conversation

tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Dec 8, 2017

Add SolidusSupport.payment_method_parent_class

This helps to get the parent class for payment methods.

For Solidus < 2.3 it is Spree::PaymentMethod for non credit card payment methods or Spree::Gateway for credit card payment methods.

For Solidus >= 2.3 it is Spree::PaymentMethod for non credit card payment methods or Spree::PaymentMethod::CreditCard for credit card payment methods.

Usage:

My::NonCreditCardPaymentMethod < SolidusSupport.payment_method_parent_class
My::CreditCardPaymentMethod < SolidusSupport.payment_method_parent_class(credit_card: true)
  • Also adds a test suite

This helps to get the parent class for payment methods.

For Solidus < 2.3 it is Spree::PaymentMethod for non credit card
payment methods or Spree::Gateway for credit card payment methods.

For Solidus >= 2.3 it is Spree::PaymentMethod for non credit card
payment methods or Spree::PaymentMethod::CreditCard for credit card
payment methods.

Usage:

    My::NonCreditCardPaymentMethod < SolidusSupport.payment_method_parent_class

    My::CreditCardPaymentMethod <
    SolidusSupport.payment_method_parent_class(credit_card: true)
Copy link
Contributor

@jordan-brough jordan-brough left a comment

Choose a reason for hiding this comment

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

👍 on having the payment_method_parent_class method.

No opinion on the other things.

@jhawthorn jhawthorn self-assigned this Jan 24, 2018
@@ -24,6 +24,18 @@ def payment_source_parent_class
end
end

def payment_method_parent_class(credit_card: false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is only useful when credit_card is true (otherwise it is Spree::PaymentMethod in all versions).

Maybe we should call this credit_card_payment_method_parent_class instead, and only deal with that case?

Either way 👍

@tvdeyen
Copy link
Member Author

tvdeyen commented Mar 28, 2018

@jhawthorn would you mind to review your comment?

@jhawthorn
Copy link
Contributor

Looks fine to me

@jhawthorn jhawthorn removed their assignment May 17, 2018
@ccarruitero
Copy link

ccarruitero commented Jun 18, 2018

I'm agree with @jhawthorn. Since there isn't a change for non-credit card payment methods, I think is not useful include them.

👍 to add a test suite

Aside, there are differences about how define partial name and provider class in gateway between some versions that could be useful in this lib. I build something similar in a payment extension. Not sure what do you think?

@kennyadsl kennyadsl merged commit cc5c37f into solidusio:master Oct 9, 2018
@tvdeyen tvdeyen deleted the add-payment_method_parent_class branch October 9, 2018 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants