Add a PaymentProvider
class to model Payment Gateways with multiple Payment Methods
Currently, for historical reasons, the Solidus Source conflates the idea of a payment method and a payment gateway/provider.
When the payment system was first conceived, there were only two payment methods: "Check", which was a bogus payment method that essentially meant "We'll deal with it in cash", and "Credit Card", which had the additional complexity of needing a "Gateway" to process the credit card payments.
Things have changed since then. Companies have emerged that handle many payment methods (credit, credit card, direct debit, Apple/Android pay, SEPA). Within Solidus core, we have taken great care to allow multiple payment sources, so now we have the ability of identifying a nonce as a "Braintree token" or a "Spreedly credit card" - but we still conflate "payment method", the option a user chooses to pay, and "payment gateway", the company processing payments.
This PR changes that by moving the API calls from payment methods to their providers. It also adds a representation in the database for "an account at a payment provider" (Braintree, Payone, Spreedly).
The PaymentMethod class, for historical reasons, will still respond to the four horsemen (#authorize
, #capture
, #cancel
, #void
). However, the payment method class will now delegate to its #provider
, which is newly a belongs_to
relation to an ActiveRecord object.
The database representation of a payment provider account is there to facilitate analytical tasks like finding all payments done through any payment method of the Payone account we use for the store in Czech Republic.
There is a migration which will copy all preferences from your payment method to its provider. Given that they are mostly credentials, which are now the responsibility of the PaymentProvider
, this seems a reasonable assumption to make.
If your payment method has non-credential preferences, you can still find them on the preferences
column in the spree_payment_methods
table.
A transaction of some representation of monetary value from a users account to a merchant's account.
A reversal of a payment
The mode of payment, choosable by the customer. Different from Payment provider, who presents an API
A representation of one account a customer holds, usually connected to the payment method with which one can make use of it.
The company who handles settling a payment or refund via any payment method, from any payment source.