AI Reports

Guides › Database reference › Orders and sales

Magento 2 sales_order_payment table

The payment of each order: the method used, amounts authorised, paid and refunded, and the gateway's references.

Key columns

ColumnWhat it means
parent_idThe order, linking to sales_order.entity_id.
methodPayment method code, such as checkmo, banktransfer or a gateway's own code.
amount_ordered / amount_paid / amount_refundedAmounts in the order currency; base_ versions are in your base currency.
last_trans_idThe latest transaction ID from the payment gateway.
cc_type / cc_last_4Card type and the last four digits, when the gateway provides them.
additional_informationExtra details from the payment method, stored as JSON.

Good to know

Example: Orders per payment method, last 30 days

Works on Magento Open Source and Adobe Commerce.

SELECT p.method, COUNT(*) AS orders, ROUND(SUM(o.base_grand_total), 2) AS revenue
FROM sales_order o
JOIN sales_order_payment p ON p.parent_id = o.entity_id
WHERE o.created_at >= NOW() - INTERVAL 30 DAY
GROUP BY p.method
ORDER BY orders DESC;

Tested on Magento Open Source and Adobe Commerce 2.4.8. Read-only. If your tables have a prefix, add it to each table name.

This table has the same 54 columns on Magento Open Source and Adobe Commerce.

Foreign keys

All 54 columns (Magento Open Source)

Show all columns
ColumnTypeCan be emptyMagento's description
entity_idint(10) unsignedEntity ID
parent_idint(10) unsignedParent ID
base_shipping_captureddecimal(20,4)yesBase Shipping Captured
shipping_captureddecimal(20,4)yesShipping Captured
amount_refundeddecimal(20,4)yesAmount Refunded
base_amount_paiddecimal(20,4)yesBase Amount Paid
amount_canceleddecimal(20,4)yesAmount Canceled
base_amount_authorizeddecimal(20,4)yesBase Amount Authorized
base_amount_paid_onlinedecimal(20,4)yesBase Amount Paid Online
base_amount_refunded_onlinedecimal(20,4)yesBase Amount Refunded Online
base_shipping_amountdecimal(20,4)yesBase Shipping Amount
shipping_amountdecimal(20,4)yesShipping Amount
amount_paiddecimal(20,4)yesAmount Paid
amount_authorizeddecimal(20,4)yesAmount Authorized
base_amount_ordereddecimal(20,4)yesBase Amount Ordered
base_shipping_refundeddecimal(20,4)yesBase Shipping Refunded
shipping_refundeddecimal(20,4)yesShipping Refunded
base_amount_refundeddecimal(20,4)yesBase Amount Refunded
amount_ordereddecimal(20,4)yesAmount Ordered
base_amount_canceleddecimal(20,4)yesBase Amount Canceled
quote_payment_idint(11)yesQuote Payment ID
additional_datatextyesAdditional Data
cc_exp_monthvarchar(12)yesCc Exp Month
cc_ss_start_yearvarchar(12)yesCc Ss Start Year
echeck_bank_namevarchar(128)yesEcheck Bank Name
methodvarchar(128)yesMethod
cc_debug_request_bodyvarchar(32)yesCc Debug Request Body
cc_secure_verifyvarchar(32)yesCc Secure Verify
protection_eligibilityvarchar(32)yesProtection Eligibility
cc_approvalvarchar(32)yesCc Approval
cc_last_4varchar(100)yesCc Last 4
cc_status_descriptionvarchar(32)yesCc Status Description
echeck_typevarchar(32)yesEcheck Type
cc_debug_response_serializedvarchar(32)yesCc Debug Response Serialized
cc_ss_start_monthvarchar(128)yesCc Ss Start Month
echeck_account_typevarchar(255)yesEcheck Account Type
last_trans_idvarchar(255)yesLast Trans ID
cc_cid_statusvarchar(32)yesCc Cid Status
cc_ownervarchar(128)yesCc Owner
cc_typevarchar(32)yesCc Type
po_numbervarchar(32)yesPo Number
cc_exp_yearvarchar(4)yesCc Exp Year
cc_statusvarchar(4)yesCc Status
echeck_routing_numbervarchar(32)yesEcheck Routing Number
account_statusvarchar(32)yesAccount Status
anet_trans_methodvarchar(32)yesAnet Trans Method
cc_debug_response_bodyvarchar(32)yesCc Debug Response Body
cc_ss_issuevarchar(32)yesCc Ss Issue
echeck_account_namevarchar(32)yesEcheck Account Name
cc_avs_statusvarchar(32)yesCc Avs Status
cc_number_encvarchar(128)yes
cc_trans_idvarchar(32)yesCc Trans ID
address_statusvarchar(32)yesAddress Status
additional_informationtextyesAdditional Information

Related tables

Gaurav Harsh

Gaurav Harsh is a Magento developer who works on large Adobe Commerce stores and builds AI Reports, a Magento extension for asking your store's data questions in plain English. LinkedIn