Updating Payment Methods via API
Learn how to update existing payment methods programmatically through the Payment Method API
The Payment Method API allows you to update non-sensitive details of existing payment methods. While you cannot change the actual payment credentials (card numbers, account numbers), you can update billing information, default settings, descriptions, and other metadata. This enables you to maintain accurate customer payment information without requiring customers to re-enter their payment details.
Sensitive payment credentials cannot be updated. To change card numbers, account numbers, or other sensitive details, create a new payment method. For creating payment methods, see Payment Method API.
Prerequisites
Before updating payment methods through the API, it's helpful to learn about the following topics.
Learn about payment methods
Understand payment method types, fields, and how payment methods are structured.
Learn about accounts
Understand customer accounts and how payment methods are associated with account holders.
When to Update Payment Methods
Use the Payment Method API to update payment methods when you need to modify non-sensitive details without requiring customers to re-enter their full payment information. Common scenarios include address changes, updating default payment method settings, or correcting customer information.
Common use cases
- Address Updates: Customer moves or needs to update billing address
- Default Payment Method Changes: Set or change which payment method is used by default
- Metadata Management: Update custom attributes or tags for internal tracking
- Account Holder Name Corrections: Fix typos or update names without re-entering card details
What Cannot Be Updated: You cannot update sensitive payment credentials like card numbers, account numbers, or routing numbers. These fields are write-only during creation. To change these details, create a new payment method and optionally delete the old one.
Updating Billing Address
Update the billing address associated with a payment method.
This example updates:
-
billing_address.address_line_1- Street address -
billing_address.city- City name -
billing_address.state_province- State or province -
billing_address.postal_code- ZIP or postal code -
billing_address.country_code- Country code (US, CA, etc.)
Updating billing addresses is useful when customers move or need to correct address information for Address Verification System (AVS) checks.
Partial Updates: You can update individual address fields without providing the complete address. Only the fields you include will be updated.
Updating Account Defaults
Configure or change which payment method is used as the default for an account.
This example configures:
-
account_defaults.paying: 'payments'- Set as default for collecting payments -
account_defaults.paying: 'payouts'- Set as default for sending payouts -
account_defaults.paying: 'all'- Set as default for both payments and payouts -
account_defaults.paying: null- Remove default status
When you set a payment method as the default, any previously set default for that transaction type is automatically removed.
Automatic Handling: Only one payment method per account can be the default for each transaction type. Setting a new default automatically removes the default flag from the previous payment method.
Updating Description and Metadata
Add or modify descriptive information and custom metadata.
This example updates:
-
description- Human-readable label for the payment method -
metadata- Custom key-value pairs for internal tracking
Descriptions help customers identify payment methods in your interface (e.g., "Work Visa", "Personal Checking"). Metadata enables you to store additional context like customer preferences or internal identifiers.
Updating Account Holder Name
Correct or update the account holder name without re-entering payment credentials.
This is useful for:
- Correcting typos in customer names
- Updating names after marriage or legal name changes
- Standardizing name formats across payment methods
Updating Multiple Fields
Update multiple payment method fields in a single API call.
You can update any combination of non-sensitive fields in a single request:
- Billing address
- Account defaults
- Description
- Metadata
- Account holder name
- Transfer type
Efficient Updates: Updating multiple fields in one API call is more efficient than making separate requests for each field.
Handling Update Errors
Handle validation errors and conflicts when updating payment methods.
try:
payment_method = pl.PaymentMethod.get("pm_1234567890")
payment_method.update(
billing_address={
"postal_code": "94102",
"country_code": "US"
}
)
print("Payment method updated:", payment_method.id)
except Exception as error:
print("Error type:", getattr(error, "error_type", None))
print("Error description:", getattr(error, "error_description", None))
print("Error details:", getattr(error, "details", None))
if getattr(error, "error_type", None) == "InvalidAttributes":
print("Validation failed:", error.details)
else:
print("Update failed:", getattr(error, "error_description", str(error)))Common error responses:
| Status | Error Type | Description |
|---|---|---|
| 400 | InvalidAttributes | Invalid field values (malformed postal code, invalid country code, etc.) |
| 401 | Unauthorized | Invalid or expired API secret key |
| 403 | Forbidden | Payment method is not in scope of the API secret key used |
| 404 | Not Found | Payment method ID doesn't exist |
| 429 | Too Many Requests | API rate limit reached |
| 500 | Internal Server Error | Unexpected error while processing the request |
For more information on error handling, see Errors API Reference.
Schema Reference
The following fields can be updated for existing payment methods:
Updatable Fields
Fields that can be modified after payment method creation:
account_holderdescriptiontransfer_typetwo_way, send_only, receive_onlyaccount_defaultsfundingall, deposits, withdrawspayingall, payments, payoutsbilling_addressaddress_line_1address_line_2citycountry_codepostal_codestate_provinceBilling Address Fields
All billing address fields can be updated:
postal_codeaddress_line_1address_line_2citystate_provincecountry_codeAccount Defaults Fields
Configure default payment method behavior:
payingall, payments, payoutsfundingall, deposits, withdrawsFor complete field documentation, see:
- Payment Methods API Reference - All payment method fields and update operations
Next Steps
Enhance payment processing and payment method management
Process Transactions
Use Payment API to process payments with updated payment methods, send Payouts using updated bank accounts, and set up Recurring Payments with updated defaults for subscriptions.
Manage Payment Methods
Create new payment methods with Payment Method API, implement Payment Method Verification to verify updated bank accounts, and explore Payment Methods for overview of management options.
Build User Interfaces
Create Payment Method Form to let customers update their own payment methods, build Payment Form for processing immediate payments, and integrate Checkout Plugin for complete checkout experiences.
Related articles
- Payment Methods - Overview of payment methods
- Creating Payment Methods - Create new payment methods via API
- Payment Method Verification - Verify payment methods
- Payment Methods API Reference - Complete API reference