-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Rename Gateway into PaymentMethod::CreditCard #2001
Conversation
|
||
describe 'ActiveMerchant methods' do | ||
class PaymentGateway | ||
def initialize(options) |
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.
Put empty method definitions on a single line.
Spree::Deprecation.warn \ | ||
"provider_class is deprecated and will be removed from Solidus 3.0 " \ | ||
"(use gateway_class instead)" | ||
self.public_send :provider_class |
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.
Redundant self detected.
# Represents the gateway class of this payment method | ||
# | ||
def gateway_class | ||
if self.respond_to? :provider_class |
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.
Redundant self detected.
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.
This is excellent work. I ❤️ the added documentation, which is spot-on. I found two typos, which are absolute nits. 👍
# Uses STI (single table inheritance) to store all implemented payment methods | ||
# in one table (+spree_payment_methods+). | ||
# | ||
# This class is not ment to be instantiated. Please create instances of concrete payment methods. |
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.
This is excellent class documentation. Wow.
There's a typo in here though: "ment" should read "meant".
# The form your customer enters the payment information in during checkout | ||
# | ||
# 2. app/views/spree/checkout/existing_payment/_{method_type}.html.erb | ||
# The payment information of your customers resuable sources during checkout |
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.
Typo: "resuable" -> "reusable"
To remove confusion around payment methods, gateways and providers we rename the `Spree::Gateway::Bogus` and `Spree::Gateway::BogusSimple` payment methods into `Spree::PaymentMethod::BogusCreditCard` and `Spree::PaymentMethod::SimpleBogusCreditCard`.
Use `Spree:: PaymentMethod::BogusCreditCard` and `Spree::PaymentMethod::SimpleBogusCreditCard ` instead.
Running rake solidus:migrations:rename_gateways:up helps migrating your data to new bogus payment method class names. rake solidus:migrations:rename_gateways:down reverts this. Also includes a migration that invokes that task, so you don't need to care when deploying this change.
`Spree::Gateway` holds many methods that actually belongs into its parent class - `Spree::PaymentMethod`. It rather should only hold commonalities that are relevant for credit card payment methods. All payment methods that are not a credit card should inherit directly from `Spree::PaymentMethod` - like `Spree::PaymentMethod::StoreCredit` and friends already does.
In order to remove confusing parts of our current payment methods implementation we rename the `provider` methods from `Spree::PaymentMethod` into `gateway`. A gateway is a class that implements the API communication to the provider. See the `active_merchant` gem for a set of gateway classes we use in `solidus_gateway`. A provider on the other hand is a service vendor that offers a payment gateway and multiple payment methods (like Braintree). Therefore we plan to introduce a provider class later on. This then holds commonalities for mulitple payment methods, like credentials. Also it will be an ActiveRecord model so that payment methods can be grouped under one provider, which is very useful for BI and reporting.
This corrects the documentation on the Spree::PaymentMethod class.
Moves all `Spree::PaymentMethod` class methods to top of class instead of having them distributed all over the file.
The `Spree::Gateway` is an implementation of a credit card payment method. The current name is confusing. With moving this class into the `PaymentMethod` namespace and changing its name to `CreditCard` it is now more obvious what this class actually is. Several hints inside the class prove that: - It inherits from `Spree::PaymentMethod` - The `source_class` is `Spree::CreditCard` - In `supports?` it asks the gateway if it supports a certain credit card brand Further actions are required. First on foremost `solidus_gateway` needs to be changed in a way that all credit card based payment methods inherit from `Spree::PaymentMethod::CreditCard` from now on and all non credit card payment methods inherit from `Spree::PaymentMethod` directly.
Use `Spree::PaymentMethod::CreditCard` instead.
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.
Great stuff!
Indeed! I very much admire your guts to make such a major change in the name of making it all easier for us to work with the platform! I guess a big role in having the courage to do the refactoring play the tests, so thanks all as well for writing tests so good! |
The
Spree::Gateway
is an implementation of a credit card payment method. The current name is confusing.With moving this class into the
PaymentMethod
namespace and changing its name toCreditCard
it is now more obvious what this class actually is.Several hints inside the class prove that:
Spree::PaymentMethod
source_class
isSpree::CreditCard
supports?
it asks the gateway if it supports a certain credit card brandFurther actions are required. First on foremost
solidus_gateway
needs to be changed in a way that all credit card based payment methods inherit fromSpree::PaymentMethod::CreditCard
from now on and all non credit card payment methods inherit fromSpree::PaymentMethod
directly.includes #2000