Processing Payments via API
Learn how to process payments directly through the Transaction API
The Payment API allows you to process payments directly by creating transactions through your backend. This gives you full control over the payment flow and enables you to build custom payment experiences integrated with your application logic. Use the Transaction API when you need programmatic control over payment processing, batch operations, or server-to-server payment flows.
The Payment API is ideal for server-side payment processing and backend integrations. For hosted payment pages, see Payment Links. For embedded payment forms, see Payment Form or Checkout Plugin.
Prerequisites
Before processing payments through the API, it's helpful to learn about the following topics.
Learn about API authentication
Understand how to authenticate API requests using API keys and manage credentials securely.
Learn about processing accounts
Processing accounts enable you to receive payments and settle funds to your bank account.
Learn about payment methods
Understand how payment methods are stored and used for processing payments and enabling Autopay.
When to Use Payment API
Use the Payment API when you need direct, programmatic control over payment processing from your backend. The Transaction API enables server-side payment flows where you manage the entire payment lifecycle through API calls.
By using the Payment API, you handle payment data securely on your backend while Payload manages PCI compliance, card network communication, and settlement processing. You have complete control over payment timing, error handling, and integration with your business logic.
Common use cases
- Backend Payment Processing: Process payments server-side as part of application workflows
- Batch Payment Operations: Process multiple payments programmatically
- Scheduled Payments: Create payments triggered by scheduled jobs or cron tasks
- Order Fulfillment Integration: Capture authorized payments when orders ship
- Subscription Billing: Charge customers on recurring schedules using saved payment methods
Processing Card Payments
Process a one-time card payment by creating a transaction with card details.
This example creates a payment transaction with:
-
type='payment'specifies this is a payment transaction -
amountsets the payment amount in dollars -
sender.method.cardcontains the card details (number, expiry, CVV) -
receiver.account_ididentifies your account receiving payment
The response includes transaction details with status showing the payment processing state
(processing, authorized, processed, declined, or rejected).
Payment Methods: Card payments support Visa, Mastercard, American Express, and Discover. Transactions process immediately and return results in real-time.
Processing Bank Payments
Process bank account payments by providing bank account details.
This example:
- Uses
sender.method.bank_accountinstead of card details - Requires
account_holder,account_number, androuting_number
Bank account payments follow bank processing timelines and may require additional verification for first-time use.
Canadian Bank Payments
On a Canadian check, the routing number is usually BBBBB-III where I is the institution
number and B is the branch or bank transit code. To translate this to an EFT routing number,
format it as 0IIIBBBBB. See also
Routing numbers (Canada) (opens in a new tab).
Using Saved Payment Methods
Process payments using previously saved payment methods by referencing the payment method ID.
This example:
- References a saved payment method using
sender.method_id - No sensitive card or bank details needed in the request
- Automatically uses the payment method associated with the customer
- Enables faster checkout and recurring payment scenarios
Saved payment methods improve security by avoiding repeated transmission of sensitive data and enable one-click payment experiences.
Saved Payment Methods: Customers can save payment methods during checkout or through dedicated flows. See Payment Methods for details on saving and managing payment methods.
Authorization and Capture
Use two-step processing to authorize a payment first, then capture it later when ready to settle.
This example demonstrates two-step processing:
- Authorization: Set
status='authorized'to hold funds without capturing - The authorization validates the card and reserves funds
- Capture: Call
update()on the transaction withstatus='processed'to settle - Captured funds are transferred and the transaction completes
Two-step processing is useful when you need to confirm order details, check inventory, or wait for fulfillment before charging the customer.
Authorization Expiry: Card authorizations typically expire after 7 days. Capture authorized payments before they expire or the funds will be automatically released back to the customer.
Enhanced Transaction Data
Include order details, line items, and shipping information with payment transactions.
This example includes:
-
order_detailswith order number and line items - Each line item includes name, SKU, quantity, and unit price
-
shipping_detailswith recipient name and address - Enhanced data helps with reporting, reconciliation, and customer support
Including detailed transaction data improves record-keeping, enables better reporting, and provides context for customer service inquiries.
Associating Payments with Customers
Link transactions to customer accounts to maintain payment history and enable saved payment methods.
Reference existing customer account
Process a payment for an existing customer by referencing their account ID.
This example:
- Sets
sender.account_idto reference an existing customer account - Customer details (name, email, address) are automatically pulled from the account
- Provides payment method details (card) for this transaction
- Associates the transaction with the customer's payment history
Use this approach when you have already created a customer account using the Accounts API.
Provide customer details inline
Create or update a customer account inline while processing the payment.
This example:
- Sets
sender.accountwith inline customer details (name, email) - Creates or updates the customer account as part of the transaction
- Provides payment method details (card) for this transaction
- Associates the transaction with the customer's payment history
Use this approach when processing a payment for a new customer or when you want to create/update customer details inline.
Linking payments to customers enables customer lifetime value tracking, payment history, and personalized experiences.
Retrieving Transaction Details
Retrieve complete transaction details using the transaction ID.
This allows you to:
- Check the current transaction status
- Retrieve payment method details
- Access order and shipping information
- View transaction timestamps and processing details
- Get sender and receiver account information
Listing Transactions
Query transactions by account, type, status, or other filters.
This example:
- Filters transactions by receiver account ID
- Limits results to payment type transactions
- Only returns processed transactions
- Supports pagination for large result sets
Use transaction listing to build reporting dashboards, reconcile payments, and analyze payment activity.
Schema Reference
The following fields are available when creating and configuring payment transactions:
Transaction Configuration
Core fields used when creating payment transactions. For complete API reference, see Transactions API Reference.
typepayment, deposit, withdraw, refund, payoutamountdescriptionsenderaccountAccountaccount_id ID of Account^acct_[A-Za-z0-9]+$methodPaymentMethodmethod_id ID of PaymentMethod^pm_[A-Za-z0-9]+$receiveraccountAccountaccount_id ID of Account^acct_[A-Za-z0-9]+$methodPaymentMethodmethod_id ID of PaymentMethod^pm_[A-Za-z0-9]+$order_detailscust_ref_numberincl_costssales_taxline_itemsshipping_detailsdestcitycountry_codepostal_code^([A-Z][0-9][A-Z] [0-9][A-Z][0-9]|[0-9]{5}|[0-9]{9})$rcpt_companyrcpt_first_namercpt_last_namestate_provincestreet_addressunit_numbersrcpostal_code^([A-Z][0-9][A-Z] [0-9][A-Z][0-9]|[0-9]{5}|[0-9]{9})$sourceapi, keyed, swipe, emv, emv_quickchip, nfc, googlepay, applepay, checkstatuscodeapproved, card_expired, duplicate_attempt, exceeded_limit, general_decline, insufficient_bal, invalid_card_code, invalid_card_number, invalid_zip, invalid_address, invalid_account_number, suspicious_activity, too_many_attempts, processing_issue, issue_reading_card, not_supported, general_reject, general_adjustment, payment_stopped"Undocumented"messagevalueprocessing, authorized, processed, declined, rejected, voided, adjustedNext Steps
Enhance your payment processing implementation
Manage Payment Methods
Create and manage payment methods to enable saved cards and bank accounts for faster checkout.
Handle Refunds and Voids
Process refunds and voids to reverse payments and handle customer returns.
Monitor Payment Events
Subscribe to webhook notifications to track payment status changes and automate workflows.
Related articles
- Payment Links - Hosted payment request links
- Payment Form - Build custom payment forms
- Checkout Plugin - Embedded checkout form
- Transactions API Reference