Migrating from api/cards to /payment_methods

As of April 2020, our payment service has been updated to leverage Stripe's Payment Methods instead of Tokens using Card Sources. The following guide details the change and subsequent steps to update your code.

Background

PaymentMethod objects represent your customer's payment instruments. They can be used with PaymentIntents to collect payments or saved to Customer objects to store instrument details for future payments.

πŸ‘

If you currently create cards and are using stripeClient.createPaymentMethod, read through the following information detailed below.

🚧

Guide recommendation

:warning: If you need to create cards and bank accounts for the first time, follow the guide in Collecting payment information

:warning: If you are still using Stripe tokens, follow this guide migrating from Stripe token to Stripe payment method

Card endpoint changed in favor of PaymentMethod

Instead of directing to /cards you will need to direct your code to /payment_methods. Here is the full resource payment method resource.

Changes in the request

Hint will only require stripe_id to be sent in the body parameters.

Changes in the response

{
  "id": "card-ab12C345DeF6",
    "default": false,
    "last_four": "4123",
    "name": "Visa",
    "type": "card",
  "bank_account": null,
  "card": {
    "id": "card-ab12C345DeF6",
    "card_type": "visa",
    "exp_month": 7,
    "exp_year": 2017,
    "last_four": "4123",
    "name": "Visa",
   "type": "Card"
  }
}

id, default, last_four, name and type attributes are shared between cards and banks. type attribute indicates the type of payment method and specific attributes can be accessed by using said type into the response.

response = {
  "id": "card-ab12C345DeF6",
  "default": false,
  "last_four": "4123",
  "name": "Visa",
    "type": "card",
    "bank_account": null,
    "card": {
      "id": "card-ab12C345DeF6",
      "card_type": "visa",
      "exp_month": 7,
      "exp_year": 2017,
      "last_four": "4123",
      "name": "Visa",
      "type": "Card"
    }
}

# For example, in order to get "exp_month" we could do
response[response["type"]]["exp_month"]