Cross-module dependencies and data flow patterns
┌─────────────────┐
│ Magento_Vault │
│ (Token Storage) │
└────────┬────────┘
│ extends
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Magento_Quote │──▶│ Magento_Payment │◀──│ Magento_Sales │
│ (Cart Payment) │ │ (Gateway Core) │ │(Order Payment) │
└─────────────────┘ └────────┬────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│Magento_Checkout │
│ (Payment Step) │
└─────────────────┘
| Module | Relationship | Integration Point |
|---|---|---|
| Magento_Quote | Uses Payment | Quote\Model\Quote\Payment extends payment methods |
| Magento_Sales | Uses Payment | Order\Payment executes payment commands |
| Magento_Checkout | Uses Payment | Payment step renders payment forms |
| Magento_Vault | Extends Payment | Adds token storage to payment methods |
| Magento_OfflinePayments | Uses Payment | Implements Check/Money Order, Bank Transfer |
| PayPal/Braintree | Uses Gateway | Full Gateway command implementation |
Payment methods are selected and validated at the quote level before order placement.
// Quote\Model\Quote\Payment
$quote->getPayment()->setMethod('checkmo');
$quote->getPayment()->importData([
'method' => 'cc',
'cc_number' => '4111...',
'cc_exp_month' => '12',
'cc_exp_year' => '2025'
]);
// Payment method validates data
$method = $this->methodFactory->create(
$quote->getPayment()->getMethod()
);
$method->validate();
| Column | Type | Description |
|---|---|---|
| payment_id | int | Primary key |
| quote_id | int | FK to quote |
| method | varchar | Payment method code |
| additional_data | text | Serialized additional info |
Order payment entity executes payment gateway commands and manages transactions.
┌──────────────────────────────────────────────────────────────────┐
│ Order Payment Flow │
├──────────────────────────────────────────────────────────────────┤
│ │
│ Order::place() │
│ │ │
│ ▼ │
│ Payment::place() │
│ │ │
│ ├──▶ payment_action = authorize │
│ │ │ │
│ │ ▼ │
│ │ MethodInterface::authorize() │
│ │ │ │
│ │ ▼ │
│ │ Gateway\Command::execute('authorize') │
│ │ │
│ └──▶ payment_action = authorize_capture │
│ │ │
│ ▼ │
│ MethodInterface::authorize() + capture() │
│ │
└──────────────────────────────────────────────────────────────────┘
| Quote Payment | Order Payment | Notes |
|---|---|---|
| method | method | Direct copy |
| cc_type | cc_type | Card type code (VI, MC, AE) |
| cc_last_4 | cc_last4 | Last 4 digits stored |
| additional_data | additional_information | Custom data (serialized) |
The Sales module's sales_payment_transaction table tracks all payment operations.
Checkout renders payment methods in the payment step and handles method selection.
// frontend/di.xml
<type name="Magento\Checkout\Model\
CompositeConfigProvider">
<arguments>
<argument name="configProviders">
<item name="ccform">
CcGenericConfigProvider
</item>
<item name="cc_card_config">
CcConfigProvider
</item>
</argument>
</arguments>
</type>
checkout/
└── steps/
└── billing-step/
└── payment/
├── renders/
│ └── cc-form (base CC)
├── payments-list
└── before-place-order
Magento_Vault extends Payment to provide tokenization and stored payment methods.
// Vault payment method code
{original_method_code}_vault
// Example:
braintree → braintree_cc_vault
paypal → paypal_vault
| Table | Purpose |
|---|---|
| vault_payment_token | Encrypted payment tokens (gateway_token, public_hash) |
| vault_payment_token_order_payment_link | Links tokens to order payments |
Official Magento modules that implement the Payment Gateway framework:
Full Gateway implementation
Multiple integration types
Non-gateway methods
Payment endpoints are primarily handled by Quote and Checkout modules, not Payment directly.
| Endpoint | Method | Module | Description |
|---|---|---|---|
| /V1/carts/mine/payment-methods | GET | Quote | List available payment methods |
| /V1/carts/mine/selected-payment-method | PUT | Quote | Set payment method on cart |
| /V1/carts/mine/payment-information | POST | Checkout | Save payment info + place order |
| /V1/customers/me/paymentTokens | GET | Vault | List saved payment tokens |