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

Rename Gateway into PaymentMethod::CreditCard #2001

Merged
merged 11 commits into from
Jun 21, 2017
Prev Previous commit
Next Next commit
Rename Gateway into PaymentMethod::CreditCard
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.
  • Loading branch information
tvdeyen committed Jun 8, 2017
commit 858e8c056f606d30403aab8c054fb1af4e6e2e69
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Solidus 2.3.0 (master, unreleased)

- Renamed `Spree::Gateway` payment method into `Spree::PaymentMethod::CreditCard` [\#2001](https://github/com/solidusio/solidus/pull/2001) ([tvdeyen](https://github.com/tvdeyen))
Run `rake solidus:migrations:rename_gateways:up` to migrate your data.

- Renamed bogus payment methods [\#2000](https://github.com/solidusio/solidus/pull/2000) ([tvdeyen](https://github.com/tvdeyen))
`Spree::Gateway::BogusSimple` and `Spree::Gateway::Bogus` were renamed into `Spree::PaymentMethod::SimpleBogusCreditCard` and `Spree::PaymentMethod::BogusCreditCard`
Run `rake solidus:migrations:rename_gateways:up` to migrate your data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Spree
# base for extension. See https://github.com/solidusio/solidus_gateway/ for
# offically supported payment gateway implementations.
#
class Gateway < PaymentMethod
class PaymentMethod::CreditCard < PaymentMethod
def payment_source_class
CreditCard
end
Expand Down
1 change: 1 addition & 0 deletions core/lib/solidus/migrations/rename_gateways.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Solidus
module Migrations
class RenameGateways
DEFAULT_MAPPING = {
'Spree::Gateway' => 'Spree::PaymentMethod::CreditCard',
'Spree::Gateway::Bogus' => 'Spree::PaymentMethod::BogusCreditCard',
'Spree::Gateway::BogusSimple' => 'Spree::PaymentMethod::SimpleBogusCreditCard'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Spree::Gateway, type: :model do
describe Spree::PaymentMethod::CreditCard, type: :model do
context "fetching payment sources" do
let(:store) { create :store }
let(:user) { create :user }
Expand Down