1. Payment Methods
Documentation
  • Back to home
  • StripeKit
  • Installation
  • Getting Started
  • Choosing a Mode
  • Type Reference
  • Setup
    • Configuration
    • Timezones
    • Storage Adapter
    • Money and Currency
    • Error Handling
  • Stripe
    • Elements
  • Modules
    • Overview
    • Customers
      • Overview
      • List
      • Retrieve
      • Find or Create by Email
      • Create
      • Update
      • Sync
      • Delete
    • Payment Methods
      • Overview
      • Create Setup Intent
      • List
      • Attach
      • Detach
      • Set Default
      • Sync
    • Payments
      • Overview
      • Pay With Saved Method
      • Create
      • Retrieve
      • Confirm
      • Cancel
      • Sync
    • Checkout
      • Overview
      • Get
      • Create
      • Submit Fields
      • Apply Coupon
      • Mark Complete
    • Subscriptions
      • Overview
      • Create
      • Retrieve
      • Cancel
      • Resume
      • Toggle Collection Method
      • Update Fields
      • Apply Promotion Code
      • List By Customer
      • Find By Metadata
      • Sync
    • Invoices
      • Overview
      • Retrieve
      • List By Customer
      • List By Subscription
      • Pay With Saved Method
      • Void
      • Finalize
      • Sync
    • Coupons
      • Overview
      • Create
      • Validate
      • Apply To Subscription
      • List
      • Deactivate
    • Webhooks
      • Overview
      • Process
      • Events Reference
    • Sync
      • Overview
  1. Payment Methods

Attach

$kit->paymentMethods->attach()#

Attaches a payment method that already exists in Stripe (typically created client-side by Stripe Elements or Stripe.js) to a customer, optionally making it the default.

Signature#

Parameters#

FieldTypeRequiredDescription
paymentMethodIdstringYesThe Stripe payment method ID to attach, for example pm_....
customerIdstringYesThe customer to attach it to.
setAsDefaultboolNo, defaults to falseIf true, also sets this payment method as the customer's default via invoice_settings.default_payment_method.

Example request#

Example response#

Errors#

ExceptionWhen
StripeOperationErrorThe payment method is already attached to a different customer, the ID does not exist, or Stripe otherwise rejects the request.

Notes#

This method does not create a payment method, it only attaches one that already exists. Payment methods are normally created on the frontend with Stripe.js or Stripe Elements, never with your secret key. See Stripe Elements.
isDefault in the response only reflects setAsDefault from this call, not the customer's actual current default in Stripe. Call list() if you need the true default status alongside every other saved method.
Previous
List
Next
Detach
Built with