> ## Documentation Index
> Fetch the complete documentation index at: https://developer.plugsurfing.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a new payment method

> Adds a new payment method to a user's account. Important notes: - A user can only have one payment method at a time.



## OpenAPI

````yaml reference/openapi.json POST /drive/v1/users/{userId}/payment-options
openapi: 3.1.0
info:
  title: Drive API
  version: 1.0.0
  description: >-
    The Drive API provides comprehensive access to Plugsurfing's charging
    infrastructure network. It enables you to manage users, charging keys,
    search for charging locations, handle payments, and control charging
    sessions.
servers:
  - url: https://{environment}.plugsurfing.com
    variables:
      environment:
        enum:
          - drive-api-stage
        default: drive-api-stage
        description: >-
          API environment - use drive-api-stage for testing and drive-api for
          production
security: []
tags:
  - name: Geosearch
    description: >-
      Search and retrieve detailed information about charging locations and
      stations
  - name: Users
    description: >-
      Manage user accounts including creation, retrieval, updates, and deletion.
      Handles user-specific data and preferences.
  - name: Charging Keys
    description: >-
      Manage physical and virtual charging keys including creation, activation,
      updates, and status management. Essential for user access to charging
      stations.
  - name: Sessions
    description: >-
      Access and manage charging session data including history, status, and
      detailed session information
  - name: Remote Charging
    description: >-
      Control charging sessions remotely including starting and stopping
      sessions, and monitoring session status
  - name: Payment Options
    description: >-
      Manage payment methods and handle transaction processing for charging
      services
  - name: User Groups
    description: Manage user group memberships
  - name: Vouchers
    description: Redeem vouchers
  - name: Charging Key Orders
    description: Handle the ordering and fulfillment process for physical charging keys
  - name: EMP Charging Keys
    description: E-Mobility Provider specific endpoints for managing charging keys
  - name: EMP Geosearch
    description: E-Mobility Provider specific endpoints for location search and information
  - name: EMP Orders
    description: E-Mobility Provider specific endpoints for managing orders
  - name: EMP Sessions
    description: E-Mobility Provider specific endpoints for managing charging sessions
  - name: EMP Fleets
    description: E-Mobility Provider specific endpoints for managing fleets
paths:
  /drive/v1/users/{userId}/payment-options:
    post:
      tags:
        - Payment Options
      summary: Add a new payment method
      description: |-
        Adds a new payment method to a user's account. Important notes:
        - A user can only have one payment method at a time.
      operationId: createPaymentOption
      parameters:
        - name: userId
          in: path
          description: The unique identifier of the user to add the payment method for
          example: 6f36dc9b-446f-462b-aae0-95c7636d5c6c
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/CreateStripeCreditCardRequest'
            example:
              paymentMethodId: pm_1N9KPP2eZvKYlo2CY8E0x92p
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/CreditCardPaymentOption'
              example:
                id: STRIPE-7844364278189399
                paymentMethod: CREDIT_CARD
                brand: visa
                displayBrand: visa
                countryCode: DE
                expMonth: 12
                expYear: 2025
                last4: '1234'
        '400':
          description: >-
            Bad Request - returned when payment method does not exist or it's
            already attached to any user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestErrorResponse'
              example:
                message: Invalid request payload
                details:
                  - field X is required
        '404':
          description: User not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Resource not found
        '409':
          description: >-
            Conflict - returned if a payment option is already assigned to the
            user, and can be resolved by deleting the existing payment option
            first
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Resource not found
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Resource not found
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreateStripeCreditCardRequest:
      allOf:
        - $ref: '#/components/schemas/CreatePaymentOptionRequest'
        - type: object
          required:
            - paymentMethodId
          properties:
            paymentMethodId:
              type: string
              description: Stripe provided payment method id
              example: pm_321aSdF567gHij
      description: Stripe-specific payload to register a credit card payment method.
    CreditCardPaymentOption:
      type: object
      required:
        - id
        - paymentMethod
        - brand
        - countryCode
        - expMonth
        - expYear
        - last4
      properties:
        id:
          type: string
          example: STRIPE-7844364278189399
          description: Unique identifier for this payment method in our system
        paymentMethod:
          type: string
          enum:
            - CREDIT_CARD
          example: CREDIT_CARD
          description: Payment method provider/type.
        brand:
          type: string
          example: visa
          description: Card network brand.
        displayBrand:
          type: string
          description: >-
            The brand to use when displaying the card, this accounts for
            customer's brand choice on dual-branded cards. Stripe documentation:
            [EU regulation: Co-badged cards
            compliance](https://docs.stripe.com/co-badged-cards-compliance) &
            [Stripe
            PaymentMethod.card.display_brand](https://docs.stripe.com/api/payment_methods/object#payment_method_object-card-display_brand)
          example: visa
        countryCode:
          type: string
          description: ISO 3166-1 alpha-2
          example: DE
        expMonth:
          type: integer
          format: int32
          example: 12
          description: Card expiration month (1-12).
        expYear:
          type: integer
          format: int32
          example: 2025
          description: Card expiration year (YYYY).
        last4:
          type: string
          example: '1234'
          description: Last four digits of the card number.
      description: Stored credit card payment option details.
    InvalidRequestErrorResponse:
      title: InvalidRequestErrorResponse
      type: object
      required:
        - message
        - fields
      properties:
        message:
          type: string
        fields:
          type: array
          items:
            title: InvalidField
            type: object
            required:
              - name
              - message
              - rejectedValue
            properties:
              name:
                type: string
              message:
                type: string
                example: UserId is not correct
              rejectedValue:
                type: string
    ErrorResponse:
      title: ErrorResponse
      type: object
      properties:
        message:
          type: string
    CreatePaymentOptionRequest:
      type: object
      description: Request payload to create a new payment option for a user.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.