## Payment Methods

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.

Related guides: [Payment Methods](https://docs.stripe.com/payments/payment-methods.md) and [More Payment Scenarios](https://docs.stripe.com/payments/more-payment-scenarios.md).

## Create a PaymentMethod

`stripe.createPaymentMethod(paymentMethodData: object)`

Use `stripe.createPaymentMethod` to convert payment information collected by elements into a [PaymentMethod](https://docs.stripe.com/api/payment_methods.md) object that you safely pass to your server to use in an API call.

**NOTE:** In most integrations, you will not need to use this method. Instead, use methods like [stripe.confirmCardPayment](https://docs.stripe.com/js/payment_intents/confirm_card_payment.md), which will automatically create a PaymentMethod when you confirm a [PaymentIntent](https://docs.stripe.com/api/payment_intents.md).

- `paymentMethodData`
  Refer to the [PaymentMethod API](https://docs.stripe.com/api/payment_methods/create.md) for a full list of parameters.
  - `type`
    The type of the [PaymentMethod](https://docs.stripe.com/api/payment_methods/create.md) to create. Refer to the [PaymentMethod API](https://docs.stripe.com/api/payment_methods/create.md#create_payment_method-type) for all possible values.
  - `card`
    A `card` or `cardNumber` Element.
  - `au_becs_debit`
    An `auBankAccount` Element.
  - `fpx`
    An `fpx` Element.
    - `fpx[bank]`
      The customer's [bank](https://docs.stripe.com/payments/fpx/accept-a-payment.md#bank-reference).
  - `netbanking[bank]`
    The customer's bank.
  - `ideal`
    An `idealBank` Element.
    - `ideal[bank]`
      The customer's [bank](https://docs.stripe.com/sources/ideal.md#specifying-customer-bank).
  - `sepa_debit`
    An `iban` Element.
    - `sepa_debit[iban]`
      An IBAN account number.
  - `upi[vpa]`
    The customer's VPA.
  - `billing_details`
    [Billing information](https://docs.stripe.com/api/payment_methods/create.md#create_payment_method-billing_details) associated with the PaymentMethod that may be used or required by particular types of payment methods.

### Example

```javascript
const stripe = Stripe('pk_test_...');

const elements = stripe.elements();
const cardElement = elements.create('card');
cardElement.mount('#card-element');

// Handle form submission.
const form = document.getElementById('payment-form');
form.addEventListener('submit', async (event) => {
  event.preventDefault();

  const {paymentMethod} = await stripe.createPaymentMethod({
    elements,
    params: {
      billing_details: {
        name: 'Jenny Rosen',
      },
    },
  });
});
```

## Create a PaymentMethod with Elements

`stripe.createPaymentMethod(options: object)`

Use `stripe.createPaymentMethod` to convert payment information collected by elements into a [PaymentMethod](https://docs.stripe.com/api/payment_methods.md) object that you safely pass to your server to use in an API call.

**NOTE:** In most integrations, you will not need to use this method. Instead, use methods like [stripe.confirmPayment](https://docs.stripe.com/js/payment_intents/confirm_payment.md), which will automatically create a PaymentMethod when you confirm a [PaymentIntent](https://docs.stripe.com/api/payment_intents.md).

- `options`
  - `elements`
    The [Elements](#payment_element_create) instance that was used to create the Payment Element. It will be used to pull payment method and billing address data from.
  - `params`
    Parameters that will be passed on to the Stripe API. Refer to the [PaymentMethod API](https://docs.stripe.com/api/payment_methods/create.md) for a full list of parameters.
  - `billing_details`
    [Billing information](https://docs.stripe.com/api/payment_methods/create.md#create_payment_method-billing_details) associated with the PaymentMethod that may be used or required by particular types of payment methods.

### Example

```javascript
const stripe = Stripe('pk_test_...');

const elements = stripe.elements();
const paymentElement = elements.create('payment');
paymentElement.mount('#payment-element');

// Handle form submission.
const form = document.getElementById('payment-form');
form.addEventListener('submit', async (event) => {
  event.preventDefault();

  const {paymentMethod} = await stripe.createPaymentMethod({
    elements,
    params: {
      billing_details: {
        name: 'Jenny Rosen',
      },
    },
  });
});
```