Stripe: Attach a Payment Method to a Customer
Stripe paymentMethods.postPaymentMethodsPaymentMethodAttach: arguments, response, policy and SDK examples.
← Payment methods operations · Get started
Operation stripe.postpaymentmethodspaymentmethodattach
Provider route: POST /v1/payment_methods/{payment_method}/attach. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/stripe with npm, or alter-sdk-stripe with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { StripeIntegration } from "@alter-ai/stripe";
async function execute(input: Parameters<StripeIntegration["paymentMethods"]["postPaymentMethodsPaymentMethodAttach"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new StripeIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.paymentMethods.postPaymentMethodsPaymentMethodAttach(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_stripe import StripeIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = StripeIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.payment_methods.post_payment_methods_payment_method_attach(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.payment_method | string | Required within parent | Maximum length: 5000 |
headers | object | Optional | Additional keys: not allowed |
headers.Idempotency-Key | string | Optional | Minimum length: 1 Maximum length: 255 |
body | object | Optional | Additional keys: not allowed |
body.customer | string | Optional | The ID of the customer to which to attach the PaymentMethod. Maximum length: 5000 |
body.customer_account | string | Optional | The ID of the Account representing the customer to which to attach the PaymentMethod. Maximum length: 5000 |
body.expand | array | Optional | Specifies which fields in the response should be expanded. |
body.expand[] | string | Each item | Maximum length: 5000 |
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Create a Payment Method — response body |
Referenced models: Create a Payment Method — response body
Schemas
Section titled “Schemas”697 more schemas are linked from the tables above, on the schema pages.
Create a Payment Method — response body — zip
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root |
Create a charge — response body — billing details
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
address | JSON | Optional | |
address (anyOf 1) | JSON | Alternative | Billing address. |
address (anyOf 1) (anyOf 1) | Model | Alternative | Expand Create a Location — response body — address |
address (anyOf 2) | null | Alternative | |
email | JSON | Optional | |
email (anyOf 1) | string | Alternative | Email address. Maximum length: 5000 |
email (anyOf 2) | null | Alternative | |
name | JSON | Optional | |
name (anyOf 1) | string | Alternative | Full name. Maximum length: 5000 |
name (anyOf 2) | null | Alternative | |
phone | JSON | Optional | |
phone (anyOf 1) | string | Alternative | Billing phone number (including extension). Maximum length: 5000 |
phone (anyOf 2) | null | Alternative | |
tax_id | JSON | Optional | |
tax_id (anyOf 1) | string | Alternative | Taxpayer identification number. Used only for transactions between LATAM buyers and non-LATAM sellers. Maximum length: 5000 |
tax_id (anyOf 2) | null | Alternative |
Referenced models: Create a Location — response body — address
Create a Payment Method — response body — acss debit
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
bank_name | JSON | Optional | |
bank_name (anyOf 1) | string | Alternative | Name of the bank associated with the bank account. Maximum length: 5000 |
bank_name (anyOf 2) | null | Alternative | |
fingerprint | JSON | Optional | |
fingerprint (anyOf 1) | string | Alternative | Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same. Maximum length: 5000 |
fingerprint (anyOf 2) | null | Alternative | |
institution_number | JSON | Optional | |
institution_number (anyOf 1) | string | Alternative | Institution number of the bank account. Maximum length: 5000 |
institution_number (anyOf 2) | null | Alternative | |
last4 | JSON | Optional | |
last4 (anyOf 1) | string | Alternative | Last four digits of the bank account number. Maximum length: 5000 |
last4 (anyOf 2) | null | Alternative | |
transit_number | JSON | Optional | |
transit_number (anyOf 1) | string | Alternative | Transit number of the bank account. Maximum length: 5000 |
transit_number (anyOf 2) | null | Alternative |
Create a Payment Method — response body — au becs debit
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
bsb_number | JSON | Optional | |
bsb_number (anyOf 1) | string | Alternative | Six-digit number identifying bank and branch associated with this bank account. Maximum length: 5000 |
bsb_number (anyOf 2) | null | Alternative | |
fingerprint | JSON | Optional | |
fingerprint (anyOf 1) | string | Alternative | Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same. Maximum length: 5000 |
fingerprint (anyOf 2) | null | Alternative | |
last4 | JSON | Optional | |
last4 (anyOf 1) | string | Alternative | Last four digits of the bank account number. Maximum length: 5000 |
last4 (anyOf 2) | null | Alternative |
Create a Payment Method — response body — bacs debit
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
fingerprint | JSON | Optional | |
fingerprint (anyOf 1) | string | Alternative | Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same. Maximum length: 5000 |
fingerprint (anyOf 2) | null | Alternative | |
last4 | JSON | Optional | |
last4 (anyOf 1) | string | Alternative | Last four digits of the bank account number. Maximum length: 5000 |
last4 (anyOf 2) | null | Alternative | |
sort_code | JSON | Optional | |
sort_code (anyOf 1) | string | Alternative | Sort code of the bank account. (e.g., `10-20-30`) Maximum length: 5000 |
sort_code (anyOf 2) | null | Alternative |
Create a Payment Method — response body — bizum
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
buyer_id | JSON | Optional | |
buyer_id (anyOf 1) | string | Alternative | A unique identifier for the buyer as determined by the local payment processor. Maximum length: 5000 |
buyer_id (anyOf 2) | null | Alternative |
Create a Payment Method — response body — blik
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
buyer_id | JSON | Optional | |
buyer_id (anyOf 1) | string | Alternative | A unique and immutable identifier assigned by BLIK to every buyer. Maximum length: 5000 |
buyer_id (anyOf 2) | null | Alternative |
Create a Payment Method — response body — boleto
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
tax_id | string | Required within parent | Uniquely identifies the customer tax id (CNPJ or CPF) Maximum length: 5000 |
Create a Payment Method — response body — cashapp
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
buyer_id | JSON | Optional | |
buyer_id (anyOf 1) | string | Alternative | A unique and immutable identifier assigned by Cash App to every buyer. Maximum length: 5000 |
buyer_id (anyOf 2) | null | Alternative | |
cashtag | JSON | Optional | |
cashtag (anyOf 1) | string | Alternative | A public identifier for buyers using Cash App. Maximum length: 5000 |
cashtag (anyOf 2) | null | Alternative |
Create a Payment Method — response body — custom
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
display_name | JSON | Optional | |
display_name (anyOf 1) | string | Alternative | Display name of the Dashboard-only CustomPaymentMethodType. Maximum length: 5000 |
display_name (anyOf 2) | null | Alternative | |
logo | JSON | Optional | |
logo (anyOf 1) | JSON | Alternative | Contains information about the Dashboard-only CustomPaymentMethodType logo. |
logo (anyOf 1) (anyOf 1) | Model | Alternative | Expand Create a Payment Method — response body — custom logo value content type, url |
logo (anyOf 2) | null | Alternative | |
type | string | Required within parent | ID of the Dashboard-only CustomPaymentMethodType. Not expandable. Maximum length: 5000 |
Referenced models: Create a Payment Method — response body — custom logo value content type, url
Create a Payment Method — response body — eps
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
bank | JSON | Optional | |
bank (anyOf 1) | string | Alternative | The customer's bank. Should be one of `arzte_und_apotheker_bank`, `austrian_anadi_bank_ag`, `bank_austria`, `bankhaus_carl_spangler`, `bankhaus_schelhammer_und_schattera_ag`, `bawag_psk_ag`, `bks_bank_ag`, `brull_kallmus_bank_ag`, `btv_vier_lander_bank`, `capital_bank_grawe_gruppe_ag`, `deutsche_bank_ag`, `dolomitenbank`, `easybank_ag`, `erste_bank_und_sparkassen`, `hypo_alpeadriabank_international_ag`, `hypo_noe_lb_fur_niederosterreich_u_wien`, `hypo_oberosterreich_salzburg_steiermark`, `hypo_tirol_bank_ag`, `hypo_vorarlberg_bank_ag`, `hypo_bank_burgenland_aktiengesellschaft`, `marchfelder_bank`, `oberbank_ag`, `raiffeisen_bankengruppe_osterreich`, `schoellerbank_ag`, `sparda_bank_wien`, `volksbank_gruppe`, `volkskreditbank_ag`, or `vr_bank_braunau`. Known values: arzte_und_apotheker_bank, austrian_anadi_bank_ag, bank_austria, bankhaus_carl_spangler, bankhaus_schelhammer_und_schattera_ag, bawag_psk_ag, bks_bank_ag, brull_kallmus_bank_ag, btv_vier_lander_bank, capital_bank_grawe_gruppe_ag, deutsche_bank_ag, dolomitenbank, easybank_ag, erste_bank_und_sparkassen, hypo_alpeadriabank_international_ag, hypo_bank_burgenland_aktiengesellschaft, hypo_noe_lb_fur_niederosterreich_u_wien, hypo_oberosterreich_salzburg_steiermark, hypo_tirol_bank_ag, hypo_vorarlberg_bank_ag, marchfelder_bank, oberbank_ag, raiffeisen_bankengruppe_osterreich, schoellerbank_ag, sparda_bank_wien, volksbank_gruppe, volkskreditbank_ag, vr_bank_braunau |
bank (anyOf 2) | null | Alternative |
Create a Payment Method — response body — klarna
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
dob | JSON | Optional | |
dob (anyOf 1) | JSON | Alternative | The customer's date of birth, if provided. |
dob (anyOf 1) (anyOf 1) | Model | Alternative | Expand Create a person — accounts post Accounts Account People — response body — dob |
dob (anyOf 2) | null | Alternative |
Referenced models: Create a person — accounts post Accounts Account People — response body — dob
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: stripe.postpaymentmethodspaymentmethodattach. Catalog operation: PostPaymentMethodsPaymentMethodAttach. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.
Pinned headers: {"Stripe-Version": "2026-09-30.endive"}