# Create a PaymentMethod

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/payment_methods:
    post:
      summary: Create a PaymentMethod
      deprecated: false
      description: >-
        Instead of creating a PaymentMethod directly, we recommend using the
        PaymentIntents API to accept a payment immediately or the SetupIntent
        API to collect payment method details ahead of a future payment.
      tags:
        - API Reference/Payment Methods
      parameters:
        - name: Accept
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              x-apifox-refs:
                01HARTXQ5AFQS1XZWAYYDYDBJT: &ref_0
                  $ref: '#/components/schemas/Payment%20Method'
                  x-apifox-overrides:
                    id: null
                    object: null
                    created: null
                    livemode: null
                    customer: null
              x-apifox-orders:
                - 01HARTXQ5AFQS1XZWAYYDYDBJT
              properties:
                metadata:
                  type: object
                  properties: {}
                  x-apifox-orders: []
                  description: >-
                    Set of key-value pairs  that you can attach to an object.
                    This can be useful for storing additional information about
                    the object in a structured format.
                  x-apifox-ignore-properties: []
                billing_details: &ref_1
                  $ref: '#/components/schemas/Billing%20Details'
                  properties:
                    address:
                      type: object
                      properties:
                        city:
                          type: string
                        country:
                          type: string
                        line1:
                          type: 'null'
                        line2:
                          type: 'null'
                        state:
                          type: string
                        postal_code:
                          type: string
                      required:
                        - city
                        - country
                        - line1
                        - line2
                        - state
                        - postal_code
                      x-apifox-orders:
                        - city
                        - country
                        - line1
                        - line2
                        - state
                        - postal_code
                    email:
                      type: string
                    name:
                      type: string
                    phone:
                      type: string
                  required:
                    - address
                    - email
                    - name
                    - phone
                  x-apifox-orders:
                    - address
                    - email
                    - name
                    - phone
                  description: >-
                    Billing information associated with the PaymentMethod that
                    may be used or required by particular types of payment
                    methods.
                type:
                  type: string
                  description: >-
                    The type of the PaymentMethod. An additional object is
                    included on the PaymentMethod with a name matching this
                    value. It contains additional information specific to the
                    PaymentMethod type. 
                  enum:
                    - card
                    - alipayplus
                    - alipay
                    - wechat_pay
                    - sepa_debit
                    - alipay_hk
                    - boost
                    - truemoney
                    - gcash
                    - kakaopay
                    - touchngo
                    - rabbit_line_pay
                    - dana
                    - klarna
                    - ideal
                    - giropay
                    - sofort
                    - eps
                    - trustly
                    - bancontact
                    - p24
                    - unionpay
                    - fpx
                    - mcash
                    - grabpay
                    - bank_transfer_id
                    - qris
                    - promptpay
                    - ovo
                    - shopeepay
                    - upi
                    - boleto
                    - paynow
                    - pix
                    - 9pay
                    - stitch
                    - bpi
                  x-apifox-enum:
                    - value: card
                      name: ''
                      description: To use value 'card', you must be PCI Compliant.
                    - value: alipayplus
                      name: ''
                      description: ''
                    - value: alipay
                      name: ''
                      description: ''
                    - value: wechat_pay
                      name: ''
                      description: ''
                    - value: sepa_debit
                      name: ''
                      description: ''
                    - value: alipay_hk
                      name: ''
                      description: ''
                    - value: boost
                      name: ''
                      description: ''
                    - value: truemoney
                      name: ''
                      description: ''
                    - value: gcash
                      name: ''
                      description: ''
                    - value: kakaopay
                      name: ''
                      description: ''
                    - value: touchngo
                      name: ''
                      description: ''
                    - value: rabbit_line_pay
                      name: ''
                      description: ''
                    - value: dana
                      name: ''
                      description: ''
                    - value: klarna
                      name: ''
                      description: ''
                    - value: ideal
                      name: ''
                      description: ''
                    - value: giropay
                      name: ''
                      description: ''
                    - value: sofort
                      name: ''
                      description: ''
                    - value: eps
                      name: ''
                      description: ''
                    - value: trustly
                      name: ''
                      description: ''
                    - value: bancontact
                      name: ''
                      description: ''
                    - value: p24
                      name: ''
                      description: ''
                    - value: unionpay
                      name: ''
                      description: ''
                    - value: fpx
                      name: ''
                      description: ''
                    - value: mcash
                      name: ''
                      description: ''
                    - value: grabpay
                      name: ''
                      description: ''
                    - value: bank_transfer_id
                      name: ''
                      description: ''
                    - value: qris
                      name: ''
                      description: ''
                    - value: promptpay
                      name: ''
                      description: ''
                    - value: ovo
                      name: ''
                      description: ''
                    - value: shopeepay
                      name: ''
                      description: ''
                    - value: upi
                      name: ''
                      description: ''
                    - value: boleto
                      name: ''
                      description: ''
                    - value: paynow
                      name: ''
                      description: ''
                    - value: pix
                      name: ''
                      description: ''
                    - value: 9pay
                      name: ''
                      description: ''
                    - value: stitch
                      name: ''
                      description: ''
                    - value: bpi
                      name: ''
                      description: ''
                card:
                  type: object
                  x-apifox-refs: {}
                  x-apifox-orders:
                    - brand
                    - checks
                    - country
                    - exp_month
                    - exp_year
                    - fingerprint
                    - funding
                    - last4
                    - metadata
                  properties:
                    brand:
                      type: string
                      description: >-
                        American Express, Diners Club, Discover, JCB,
                        MasterCard, UnionPay, Visa, or Unknown
                    checks:
                      type: object
                      properties:
                        address_line1_check:
                          type: string
                          description: "If a address line1 was provided, results of the check, one of\_pass,\_fail,\_unavailable, or\_unchecked."
                        address_zip_check:
                          type: string
                          description: "If a address postal code was provided, results of the check, one of\_pass,\_fail,\_unavailable, or\_unchecked."
                        cvc_check:
                          type: string
                      x-apifox-orders:
                        - address_line1_check
                        - address_zip_check
                        - cvc_check
                      x-apifox-ignore-properties: []
                    country:
                      type: string
                      description: >-
                        Two-letter ISO code representing the country of the
                        card. You could use this attribute to get a sense of the
                        international breakdown of cards you’ve collected.
                    exp_month:
                      type: integer
                      description: >-
                        Two-digit number representing the card’s expiration
                        month.
                    exp_year:
                      type: integer
                      description: >-
                        Four-digit number representing the card’s expiration
                        year.
                    fingerprint:
                      type: string
                      description: Uniquely identifies this particular card number.
                    funding:
                      type: string
                      description: Can be credit, debit, prepaid, or unknown.
                    last4:
                      type: string
                      description: The last four digits of the card.
                    metadata:
                      type: object
                      properties: {}
                      x-apifox-orders: []
                      description: >-
                        Set of key-value pairs that you can attach to an object.
                        This can be useful for storing additional information
                        about the object in a structured format.
                      x-apifox-ignore-properties: []
                  description: >-
                    If this is a card  PaymentMethod, this object contains the
                    user’s card details.
                  x-apifox-ignore-properties: []
              required:
                - type
              x-apifox-ignore-properties:
                - metadata
                - billing_details
                - type
                - card
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema: *ref_0
          headers: {}
          x-apifox-name: OK
      security:
        - basic: []
      x-apifox-folder: API Reference/Payment Methods
      x-apifox-status: developing
      x-run-in-apifox: https://app.apifox.com/web/project/1296482/apis/api-112149659-run
components:
  schemas:
    Billing Details:
      type: object
      properties:
        address:
          $ref: '#/components/schemas/Address'
        email:
          type: string
          description: Email address.
        name:
          type: string
          description: 'Full name. '
        phone:
          type: string
          description: Billing phone number (including extension).
      x-apifox-orders:
        - address
        - email
        - name
        - phone
      x-apifox-ignore-properties: []
      x-apifox-folder: ''
    Address:
      type: object
      properties:
        city:
          type: string
          description: City, district, suburb, town, or village.
        country:
          type: string
          description: Two-letter country code (ISO 3166-1 alpha-2 ).
        line1:
          type: string
          description: Address line 1 (e.g., street, PO Box, or company name).
        line2:
          type: string
          description: Address line 2 (e.g., apartment, suite, unit, or building).
        postal_code:
          type: string
          description: ZIP or postal code.
        state:
          type: string
          description: State, county, province, or region.
      x-apifox-orders:
        - city
        - country
        - line1
        - line2
        - postal_code
        - state
      x-apifox-ignore-properties: []
      x-apifox-folder: ''
    Payment Method:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the object, like 'pm_xxxxx'
        object:
          type: string
          description: '''payment method'''
        created:
          type: integer
          description: >-
            Time at which the object was created. Measured in seconds since the
            Unix epoch.
        customer:
          type: string
          description: >-
            The ID of the Customer to which this PaymentMethod is saved. This
            will not be set when the PaymentMethod has not been saved to a
            Customer.
        metadata:
          type: object
          properties: {}
          x-apifox-orders: []
          description: >-
            Set of key-value pairs  that you can attach to an object. This can
            be useful for storing additional information about the object in a
            structured format.
          x-apifox-ignore-properties: []
        livemode:
          type: boolean
          description: >-
            Has the value true  if the object exists in live mode or the value
            false  if the object exists in test mode.
        billing_details: *ref_1
        type:
          type: string
          description: >-
            The type of the PaymentMethod. An additional object is included on
            the PaymentMethod with a name matching this value. It contains
            additional information specific to the PaymentMethod type. 
          enum:
            - card
            - alipayplus
            - alipay
            - wechat_pay
            - sepa_debit
            - alipay_hk
            - boost
            - truemoney
            - gcash
            - kakaopay
            - touchngo
            - rabbit_line_pay
            - dana
            - klarna
            - ideal
            - giropay
            - sofort
            - eps
            - trustly
            - bancontact
            - p24
            - unionpay
            - fpx
            - mcash
            - grabpay
            - bank_transfer_id
            - qris
            - promptpay
            - ovo
            - shopeepay
            - upi
            - boleto
            - paynow
            - pix
            - 9pay
            - stitch
            - bpi
          x-apifox-enum:
            - value: card
              name: ''
              description: To use value 'card', you must be PCI Compliant.
            - value: alipayplus
              name: ''
              description: ''
            - value: alipay
              name: ''
              description: ''
            - value: wechat_pay
              name: ''
              description: ''
            - value: sepa_debit
              name: ''
              description: ''
            - value: alipay_hk
              name: ''
              description: ''
            - value: boost
              name: ''
              description: ''
            - value: truemoney
              name: ''
              description: ''
            - value: gcash
              name: ''
              description: ''
            - value: kakaopay
              name: ''
              description: ''
            - value: touchngo
              name: ''
              description: ''
            - value: rabbit_line_pay
              name: ''
              description: ''
            - value: dana
              name: ''
              description: ''
            - value: klarna
              name: ''
              description: ''
            - value: ideal
              name: ''
              description: ''
            - value: giropay
              name: ''
              description: ''
            - value: sofort
              name: ''
              description: ''
            - value: eps
              name: ''
              description: ''
            - value: trustly
              name: ''
              description: ''
            - value: bancontact
              name: ''
              description: ''
            - value: p24
              name: ''
              description: ''
            - value: unionpay
              name: ''
              description: ''
            - value: fpx
              name: ''
              description: ''
            - value: mcash
              name: ''
              description: ''
            - value: grabpay
              name: ''
              description: ''
            - value: bank_transfer_id
              name: ''
              description: ''
            - value: qris
              name: ''
              description: ''
            - value: promptpay
              name: ''
              description: ''
            - value: ovo
              name: ''
              description: ''
            - value: shopeepay
              name: ''
              description: ''
            - value: upi
              name: ''
              description: ''
            - value: boleto
              name: ''
              description: ''
            - value: paynow
              name: ''
              description: ''
            - value: pix
              name: ''
              description: ''
            - value: 9pay
              name: ''
              description: ''
            - value: stitch
              name: ''
              description: ''
            - value: bpi
              name: ''
              description: ''
        card:
          type: object
          x-apifox-refs: {}
          x-apifox-orders:
            - brand
            - checks
            - country
            - exp_month
            - exp_year
            - fingerprint
            - funding
            - last4
            - metadata
          properties:
            brand:
              type: string
              description: >-
                American Express, Diners Club, Discover, JCB, MasterCard,
                UnionPay, Visa, or Unknown
            checks:
              type: object
              properties:
                address_line1_check:
                  type: string
                  description: "If a address line1 was provided, results of the check, one of\_pass,\_fail,\_unavailable, or\_unchecked."
                address_zip_check:
                  type: string
                  description: "If a address postal code was provided, results of the check, one of\_pass,\_fail,\_unavailable, or\_unchecked."
                cvc_check:
                  type: string
              x-apifox-orders:
                - address_line1_check
                - address_zip_check
                - cvc_check
              x-apifox-ignore-properties: []
            country:
              type: string
              description: >-
                Two-letter ISO code representing the country of the card. You
                could use this attribute to get a sense of the international
                breakdown of cards you’ve collected.
            exp_month:
              type: integer
              description: Two-digit number representing the card’s expiration month.
            exp_year:
              type: integer
              description: Four-digit number representing the card’s expiration year.
            fingerprint:
              type: string
              description: Uniquely identifies this particular card number.
            funding:
              type: string
              description: Can be credit, debit, prepaid, or unknown.
            last4:
              type: string
              description: The last four digits of the card.
            metadata:
              type: object
              properties: {}
              x-apifox-orders: []
              description: >-
                Set of key-value pairs that you can attach to an object. This
                can be useful for storing additional information about the
                object in a structured format.
              x-apifox-ignore-properties: []
          description: >-
            If this is a card  PaymentMethod, this object contains the user’s
            card details.
          x-apifox-ignore-properties: []
      x-apifox-orders:
        - id
        - object
        - created
        - customer
        - metadata
        - livemode
        - billing_details
        - type
        - card
      required:
        - type
      x-apifox-ignore-properties: []
      x-apifox-folder: ''
  securitySchemes:
    basic:
      type: http
      scheme: basic
servers:
  - url: https://apitest.wooshpay.com
    description: 官网测试
security:
  - basic: []

```
