Bill
Autopay Enrollment

Enable Automatic Payments

Configure automatic payment collection for invoices and billing schedules


Enable automatic payments to collect invoices hands-free when they reach their due date. Configure default payment methods at the account level, enable autopay on individual invoices, or set up billing schedules with autopay for all generated invoices. Automatic payments streamline recurring billing, improve collection rates, and reduce manual payment processing.

Prerequisites

Before enabling automatic payments, ensure you have:


Setting Up Default Payment Methods


Configure a payment method as the default for automatic invoice payments.

import payload
 
pl = payload.Session('secret_key_3bW9...', api_version='v2')
 
# Set payment method as default for automatic payments
 
payment_method_id = 'pm_card_123'
 
updated = pl.PaymentMethod.get(payment_method_id)
 
 
updated.update(
    account_defaults={
        'paying': 'payments',  # Use for all payment transactions
    },
)
 
print(f'Default payment method set: {updated.id}')
print('Will be used for automatic invoice payments')
print(f'Type: {updated.type}')
print(f'Description: {updated.description}')

Setting a payment method as default:

  • Use account_defaults.paying field to specify default behavior
  • Set to "payments" to use for all payment transactions (including invoices)
  • Set to "payouts" to use only for receiving payouts
  • Set to "all" to use for both payments and payouts

Default payment method behavior:

  • Only one payment method per account can be default for "payments"
  • Setting a new default automatically removes default status from previous method
  • Default payment method is used for all automatic invoice payments
  • Can be overridden on specific invoices using payer.method_id

Check current default payment method

# Find the default payment method for an account
payment_methods = pl.PaymentMethod.filter_by(
    account_id="acct_customer123"
).all()
 
default_method = next(
    (m for m in payment_methods
     if (m.account_defaults or {}).get("paying") in ("payments", "all")),
    None
)
 
if default_method:
    print("Default payment method:", default_method.id)
    print("Type:", default_method.type)
 
    card = getattr(default_method, "card", None)
    bank = getattr(default_method, "bank_account", None)
    if card:
        print("Card ending in:", card.get("last_four"))
    elif bank:
        print("Bank account ending in:", bank.get("last_four"))
else:
    print("No default payment method set")

Override Default Payment Method


Override the default payment method for specific invoices or billing schedules by specifying payer.method_id.

import payload
 
pl = payload.Session('secret_key_3bW9...', api_version='v2')
 
# Create invoice with specific payment method (overrides default)
 
invoice = pl.Invoice.create(
    due_date='2024-02-15',
    description='Annual subscription renewal',
    payer={
        'account_id': 'acct_customer123',
        'method_id': 'pm_card_specific',  # Use this specific payment method
    },
    biller={'account_id': 'acct_merchant456'},
    items=[
        {
            'type': 'line_item',
            'description': 'Annual Plan',
            'line_item': {'value': 999.0, 'qty': 1},
        }
    ],
    # autopay_settings.allowed defaults to True
)
 
print(f'Invoice created: {invoice.id}')
print(f'Will charge payment method: {invoice.payer['method_id']}')
print(f'Due date: {invoice.due_date}')

Override the default payment method for a specific invoice.

When to specify payment method:

  • Different payment methods for different invoice types (e.g., business card for business expenses)
  • Customer requests using specific card for certain purchases
  • Billing high-value invoices to a specific payment source
  • Testing payment methods before making them default
  • Maintaining separate payment methods for different services
import payload
 
pl = payload.Session('secret_key_3bW9...', api_version='v2')
 
# Create billing schedule with specific payment method (overrides default)
 
schedule = pl.BillingSchedule.create(
    start_date='2024-02-01',
    description='Monthly Pro Plan Subscription',
    payer={
        'account_id': 'acct_customer123',
        'method_id': 'pm_card_business',  # Use this specific payment method
    },
    biller={'account_id': 'acct_merchant456'},
    recurring_schedule={
        'type': 'monthly',
        'monthly': {'billing_day': 1},  # Bill on 1st of each month
    },
    # autopay_settings.allowed defaults to True
    items=[
        {
            'type': 'line_item',
            'description': 'Pro Plan - Monthly Subscription',
            'line_item': {'value': 49.99, 'qty': 1},
        }
    ],
)
 
print(f'Billing schedule created: {schedule.id}')
print(f'Will charge payment method: {schedule.payer['method_id']}')
print('All generated invoices will use this payment method')

Override the default payment method for all invoices generated from a billing schedule.

Use cases:

  • Business subscriptions charged to a specific business card
  • Department-specific billing schedules with dedicated payment methods
  • Test schedules using test payment methods
  • Premium services with dedicated payment sources

Schema Reference


Fields relevant to enabling automatic payments:

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
account_id ID of Account
string
The unique identifier of the account that owns this payment method. This determines which account has access to use this payment method for transactions and defines the ownership and permissions associated with it. (ID prefix: acct)
Pattern: ^acct_[A-Za-z0-9]+$

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]+$

Billing Schedule Autopay

autopay_settings
object
Configuration for automatic payment behavior on this billing schedule. Controls whether invoices generated from this schedule will automatically charge the payer's payment method, or if manual payment is required. Essential for subscription and recurring billing scenarios.
allowed
boolean
Controls whether automatic payments are allowed for this billing schedule. When set to true, invoices will be automatically charged to the payer's payment method when due. When false, invoices must be paid manually. This provides control over whether the payer has opted into autopay for recurring billing.
payer
object
Information about the customer who will be charged according to this billing schedule. Includes the payer account and optionally the specific payment method to use for autopay. The payer receives invoices and is responsible for payment.
accountAccount
object
The expanded payer account object. When included, this provides full account details for the customer who will be charged according to this billing schedule.
Visibility: explicit
account_id ID of Account
string
The unique identifier of the account that will be charged for this billing schedule. This is the payer who will receive invoices and from whom payments will be collected. 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 charged automatically if autopay is enabled.
Visibility: explicit
method_id ID of PaymentMethod
string
The unique identifier of the payment method to use for automatic payments. If specified, this payment method will be charged when autopay is enabled. If not set, the account's default payment method will be used. Must belong to the payer account. (ID prefix: pm)
Pattern: ^pm_[A-Za-z0-9]+$

Next Steps

Continue configuring automatic payments and billing workflows


Manage Automatic Payments

Stop automatic payments when needed with Disable Autopay for customer requests or policy changes, track payment success rates and troubleshoot issues with Monitor Autopay to optimize collection, and review Autopay Overview to understand how automatic payments work.

Configure Billing

Set up recurring billing with Create Billing Schedules for subscription and membership billing, build one-time charges with Creating Invoices for non-recurring billing needs, and manage schedule settings with Update Billing Schedules to modify frequencies and autopay settings.

Manage Payment Methods

Understand available options with Payment Methods to choose the right payment types for your customers, add customer payment methods with Create Payment Methods for card and bank account collection, and modify settings with Update Payment Methods to change default payment method configurations.


Related articles