Bill
Paying Invoices
Paying Invoices with Autopay

Paying Invoices with Autopay

Automatically charge invoices when they're due using saved payment methods


Automatic payments provide a hands-free way to collect invoices by charging customers' saved payment methods on the due date. This payment method eliminates the need for customers to manually pay each invoice and reduces late payments. Configure autopay once, and invoices are automatically charged when due.

Prerequisites

Before using autopay for invoice payments, ensure you have:


How Autopay Works for Invoices


Understand what happens when an invoice has autopay enabled.

The automatic payment process

Invoice Created

Invoice created with autopay enabled by default (autopay_settings.allowed: true)

Due Date Arrives

On the due date, Payload checks autopay eligibility

Payment Method Check

System verifies payer has a default payment method

Automatic Charge

Default payment method is charged for the balance

Status Update

Invoice status updates to paid on successful payment

If payment fails:

  • Zero-amount allocation created on invoice for tracking
  • Automatic retry for up to 5 days

Setting Up Default Payment Method


Configure a customer's default payment method for automatic invoice payments.

import payload
 
pl = payload.Session('secret_key_3bW9...', api_version='v2')
 
# Set up a payment method as default for automatic invoice payments
 
# First, create or get the payment method
payment_method = pl.PaymentMethod.create(
    account_id='acct_customer123',
    type='card',
    card={
        'card_number': '4111111111111111',
        'expiry': '12/25',
        'card_code': '123',
    },
    account_defaults={'paying': 'payments'},  # Use this for all payment transactions
)
 
print(f'Default payment method set: {payment_method.id}')
print(f'Account defaults: {payment_method.account_defaults}')
 
# Alternatively, update an existing payment method to be default
updated = pl.PaymentMethod.get('pm_card_789')
updated.update(
    account_defaults={'paying': 'payments'}  # Automatically used for invoice payments
)
 
print(f'Updated payment method: {updated.id}')
print(f'Now default for: {updated.account_defaults['paying']}')

Set the payment method that will be charged for all automatic invoice payments.

Setting a default:

  • Set account_defaults.paying to "payments" or "all"
  • Only one payment method per account can be default
  • Setting a new default removes previous default automatically
  • Used for all autopay invoices unless overridden

Creating Invoice with Autopay


Create invoices that will be automatically charged on their due date.

import payload
pl = payload.Session('secret_key_3bW9...', api_version='v2')
 
# Create an invoice with automatic payments enabled
 
invoice = pl.Invoice.create(
    due_date='2024-02-15',
    description='Monthly subscription - February 2024',
    payer={
        'account_id': 'acct_customer123'
        # No method_id - uses account's default payment method
    },
    biller={
        'account_id': 'acct_merchant456'
    },
    items=[
        {
            'type': 'line_item',
            'description': 'Pro Plan Subscription',
            'line_item': {
                'value': 99.00,
                'qty': 1
            }
        }
    ]
    # autopay_settings.allowed is True by default
    # Invoice will be automatically charged on due date
)
 
print(f'Invoice created: {invoice.id}')
print(f'Due date: {invoice.due_date}')
print(f'Will automatically charge: {invoice.payer['account_id']} on {invoice.due_date}')

Autopay is enabled by default when creating invoices. The invoice will be automatically charged on the due date if the payer has a default payment method.

What Happens on the Due Date


On the invoice due date, Payload automatically processes the payment.

Eligibility check:

  1. Invoice has autopay_settings.allowed: true
  2. Payer has default payment method configured
  3. Invoice has balance due > 0
  4. Invoice status is unpaid or partially_paid

If eligible:

  • Payment transaction created with trigger: "automatic"
  • Default payment method charged for balance
  • Payment allocation links transaction to invoice
  • Invoice status updates to paid or partially_paid

If payment fails:

  • Zero-amount allocation created for tracking
  • Automatic retry scheduled
  • Invoice remains unpaid
  • Retries continue for up to 5 days

Schema Reference


Fields relevant to automatic invoice payments:

Invoice Autopay Settings

autopay_settings
object
Configuration for automatic payment behavior on this invoice. Controls whether the invoice can automatically charge the payer's default payment method (if configured) when due, or if manual payment is required. Essential for managing recurring payments and subscription billing.
allowed
boolean
Controls whether automatic payment is allowed for this invoice. When set to true, if the payer has an automatic payment method configured, the invoice will be automatically charged when due. When false, the invoice must be paid manually.
due_date
string (date)
The date by which payment is due for this invoice. If autopay is enabled, the invoice will be automatically charged on this date. For manual payments, this serves as the payment deadline. Late fees or payment reminders may be triggered based on this date. Required for all invoices.
payer
object
Information about the customer being invoiced. Includes the payer account and optionally the specific payment method to use for autopay. The payer is responsible for paying this invoice and will receive communications about it.
accountAccount
object
The expanded payer account object. When included, this provides full account details for who is being invoiced and is responsible for payment.
Visibility: explicit
account_id ID of Account
string
The unique identifier of the account being invoiced. This is the payer who owes payment and will receive the invoice. Required if payer account is not provided inline. (ID prefix: acct)
Pattern: ^acct_[A-Za-z0-9]+$
Required if:
payer[account]=null
object
The expanded payment method object for autopay. When included, this shows the specific payment method (card, bank account, etc.) that will be automatically charged if autopay is enabled for this invoice.
Visibility: explicit
method_id ID of PaymentMethod
string
The unique identifier of the payment method to use for automatic payment of this invoice. If specified and autopay is enabled, this payment method will be charged when the invoice is due. If not set, the payer account's default payment method will be used. Not required to belong to the payer account. (ID prefix: pm)
Pattern: ^pm_[A-Za-z0-9]+$

Payment Method Defaults

account_defaults
object
Configuration for setting this payment method as the default for various transaction types on the associated account. This allows you to specify which payment and funding operations should automatically use this payment method.
funding
enum[string]
Specifies which types of funding transactions this payment method should be used for by default. Set to "deposits" to use for receiving funds into the account, "withdraws" to use for pulling funds from the account, or "all" to use for both funding types.
Values: all, deposits, withdraws
paying
enum[string]
Specifies which types of paying transactions this payment method should be used for by default. Set to "payments" to use for collecting payments from the account holder, "payouts" to use for sending credits or refunds to the account holder, or "all" to use for both payment types. Will be used for any automatic invoice payments if selected as the default for payments.
Values: all, payments, payouts

Next Steps

Explore automatic payments and configure invoice payment collection


Configure Comprehensive Autopay

Understand the complete autopay system with Autopay Overview for cross-platform automatic payment configuration, configure autopay for invoices and schedules with Enable Autopay, stop automatic payments when needed with Disable Autopay, and track and troubleshoot automatic payments with Monitor Autopay.

Alternative Payment Methods

Process invoice payments programmatically with Payment API for automated billing workflows, send payment links to customers with Payment Requests for self-service collection, and record offline payments with External Payments for check and wire transfers.

Automate Recurring Billing

Automate recurring invoice generation with Billing Schedules for subscription-based revenue, set up recurring billing with autopay using Create Billing Schedules, and track invoice progress through the complete lifecycle with Invoice Statuses.


Related articles