Overview of Solidus payment and refund architecture
Solidus uses a layered architecture for payments and refunds to allow for granular customization and integration with various Payment Service Providers (PSPs). The system is composed of the following core components:
- Payment Gateways: The lowest level of abstraction; these provide the specific logic required to integrate with a PSP's API (often built on ActiveMerchant).
- Payment Sources: Models that store information about how a user pays (e.g., credit cards). Reusable sources can be stored in a user's wallet.
- Payment Methods: Represent the way a customer pays (e.g., PayPal, Stripe, Check). They act as the primary interface for Solidus, delegating calls to payment gateways or providing custom logic for 'virtual' methods (like store credit) that don't require a PSP.
- Payments (
Spree::Payment): Connects user input to the system, associating an order, a payment source, and a payment method. It uses a state machine to track the payment status. - Refunds (
Spree::Refund): Separate models associated with a payment, allowing flexible refund processing via the#perform!method.