Search code examples
stripe-paymentsrestangular10

Add Payment Method to an existing customer


In my angular app I want to use the stripe-API. I want to add a payment method to the customer. e.g. SEPA My first Problem is to choose the right endpoint. I think it is the "create source"-endpoint. My second problem is to pass the correct params. My postman body looks like

{
  type: 'sepa_debit',
  sepa_debit: {iban: 'DE12345678901234567890'},
  currency: 'eur',
  customer: 'cus_Jjg6mhSRHZuXYZ'
  owner: {
    name: 'Max Mustermann',
}

Response:

"error": {
    "code": "parameter_unknown",
    "doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
    "message": "Received unknown parameters: type, sepa_debit",
    "param": "type",
    "type": "invalid_request_error"
}

the docs says that type can be 'sepa_debit'...? Can someone pls hepl me?


Solution

  • You should use Payment Methods API instead of Sources API. If you have an existing Payment Method, you can attach it to a Customer.

    You can also create a Payment Method, attach it and start a new payment flow at the same time when creating a Payment Intent.