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

# Create One Time Payment

> Create a one-time payment for a customer.

<Warning>
  **Deprecated API**: This API will be deprecated soon. We recommend using [Checkout Sessions](/api-reference/checkout-sessions/create) instead, which provides a more powerful and customizable API to create payment links for one-time payments and subscriptions.
</Warning>


## OpenAPI

````yaml post /payments
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.105.0
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Entitlements
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Credit Entitlements
  - name: Credit Entitlement Balances
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /payments:
    post:
      tags:
        - Payments
      operationId: create_one_time_payment_handler
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOneTimePaymentRequest'
        required: true
      responses:
        '200':
          description: One Time payment successfully initiated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOneTimePaymentResponse'
        '422':
          description: Invalid Request Object or Parameters
        '500':
          description: Something went wrong :(
      deprecated: true
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import DodoPayments from 'dodopayments';

            const client = new DodoPayments({
              bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
            });

            const payment = await client.payments.create({
              billing: { country: 'AF' },
              customer: { customer_id: 'customer_id' },
              product_cart: [{ product_id: 'product_id', quantity: 0 }],
            });

            console.log(payment.payment_id);
        - lang: Python
          source: |-
            import os
            from dodopayments import DodoPayments

            client = DodoPayments(
                bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),  # This is the default and can be omitted
            )
            payment = client.payments.create(
                billing={
                    "country": "AF"
                },
                customer={
                    "customer_id": "customer_id"
                },
                product_cart=[{
                    "product_id": "product_id",
                    "quantity": 0,
                }],
            )
            print(payment.payment_id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/dodopayments/dodopayments-go\"\n\t\"github.com/dodopayments/dodopayments-go/option\"\n)\n\nfunc main() {\n\tclient := dodopayments.NewClient(\n\t\toption.WithBearerToken(\"My Bearer Token\"),\n\t)\n\tpayment, err := client.Payments.New(context.TODO(), dodopayments.PaymentNewParams{\n\t\tBilling: dodopayments.F(dodopayments.BillingAddressParam{\n\t\t\tCountry: dodopayments.F(dodopayments.CountryCodeAf),\n\t\t}),\n\t\tCustomer: dodopayments.F[dodopayments.CustomerRequestUnionParam](dodopayments.AttachExistingCustomerParam{\n\t\t\tCustomerID: dodopayments.F(\"customer_id\"),\n\t\t}),\n\t\tProductCart: dodopayments.F([]dodopayments.OneTimeProductCartItemParam{{\n\t\t\tProductID: dodopayments.F(\"product_id\"),\n\t\t\tQuantity:  dodopayments.F(int64(0)),\n\t\t}}),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", payment.PaymentID)\n}\n"
        - lang: Java
          source: |-
            package com.dodopayments.api.example;

            import com.dodopayments.api.client.DodoPaymentsClient;
            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
            import com.dodopayments.api.models.misc.CountryCode;
            import com.dodopayments.api.models.payments.AttachExistingCustomer;
            import com.dodopayments.api.models.payments.BillingAddress;
            import com.dodopayments.api.models.payments.OneTimeProductCartItem;
            import com.dodopayments.api.models.payments.PaymentCreateParams;
            import com.dodopayments.api.models.payments.PaymentCreateResponse;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    PaymentCreateParams params = PaymentCreateParams.builder()
                        .billing(BillingAddress.builder()
                            .country(CountryCode.AF)
                            .build())
                        .customer(AttachExistingCustomer.builder()
                            .customerId("customer_id")
                            .build())
                        .addProductCart(OneTimeProductCartItem.builder()
                            .productId("product_id")
                            .quantity(0)
                            .build())
                        .build();
                    PaymentCreateResponse payment = client.payments().create(params);
                }
            }
        - lang: Kotlin
          source: |-
            package com.dodopayments.api.example

            import com.dodopayments.api.client.DodoPaymentsClient
            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
            import com.dodopayments.api.models.misc.CountryCode
            import com.dodopayments.api.models.payments.AttachExistingCustomer
            import com.dodopayments.api.models.payments.BillingAddress
            import com.dodopayments.api.models.payments.OneTimeProductCartItem
            import com.dodopayments.api.models.payments.PaymentCreateParams
            import com.dodopayments.api.models.payments.PaymentCreateResponse

            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val params: PaymentCreateParams = PaymentCreateParams.builder()
                    .billing(BillingAddress.builder()
                        .country(CountryCode.AF)
                        .build())
                    .customer(AttachExistingCustomer.builder()
                        .customerId("customer_id")
                        .build())
                    .addProductCart(OneTimeProductCartItem.builder()
                        .productId("product_id")
                        .quantity(0)
                        .build())
                    .build()
                val payment: PaymentCreateResponse = client.payments().create(params)
            }
        - lang: Ruby
          source: |-
            require "dodopayments"

            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )

            payment = dodo_payments.payments.create(
              billing: {country: :AF},
              customer: {customer_id: "customer_id"},
              product_cart: [{product_id: "product_id", quantity: 0}]
            )

            puts(payment)
        - lang: PHP
          source: |-
            <?php

            require_once dirname(__DIR__) . '/vendor/autoload.php';

            use Dodopayments\Client;
            use Dodopayments\Core\Exceptions\APIException;
            use Dodopayments\Misc\CountryCode;
            use Dodopayments\Misc\Currency;
            use Dodopayments\Payments\PaymentMethodTypes;

            $client = new Client(
              bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
              environment: 'test_mode',
            );

            try {
              $payment = $client->payments->create(
                billing: [
                  'country' => CountryCode::AF,
                  'city' => 'city',
                  'state' => 'state',
                  'street' => 'street',
                  'zipcode' => 'zipcode',
                ],
                customer: ['customerID' => 'customer_id'],
                productCart: [
                  ['productID' => 'product_id', 'quantity' => 0, 'amount' => 0]
                ],
                adaptiveCurrencyFeesInclusive: true,
                allowedPaymentMethodTypes: [PaymentMethodTypes::ACH],
                billingCurrency: Currency::AED,
                customerBusinessName: 'customer_business_name',
                discountCode: 'discount_code',
                discountCodes: ['string'],
                force3DS: true,
                metadata: ['foo' => 'string'],
                paymentLink: true,
                paymentMethodID: 'payment_method_id',
                redirectImmediately: true,
                requirePhoneNumber: true,
                returnURL: 'return_url',
                shortLink: true,
                showSavedPaymentMethods: true,
                taxID: 'tax_id',
              );

              var_dump($payment);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: |-
            using System;
            using DodoPayments.Client;
            using DodoPayments.Client.Models.Misc;
            using DodoPayments.Client.Models.Payments;

            DodoPaymentsClient client = new();

            PaymentCreateParams parameters = new()
            {
                Billing = new()
                {
                    Country = CountryCode.Af,
                    City = "city",
                    State = "state",
                    Street = "street",
                    Zipcode = "zipcode",
                },
                Customer = new AttachExistingCustomer("customer_id"),
                ProductCart =
                [
                    new()
                    {
                        ProductID = "product_id",
                        Quantity = 0,
                        Amount = 0,
                    },
                ],
            };

            var payment = await client.Payments.Create(parameters);

            Console.WriteLine(payment);
components:
  schemas:
    CreateOneTimePaymentRequest:
      type: object
      title: Create One-Time Payment Request
      required:
        - product_cart
        - customer
        - billing
      properties:
        adaptive_currency_fees_inclusive:
          type:
            - boolean
            - 'null'
          description: >-
            Whether adaptive currency fees should be included in the price
            (true) or added on top (false).

            If not specified, defaults to the business-level setting.
        allowed_payment_method_types:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/PaymentMethodTypes'
          description: >-
            List of payment methods allowed during checkout.


            Customers will **never** see payment methods that are **not** in
            this list.

            However, adding a method here **does not guarantee** customers will
            see it.

            Availability still depends on other factors (e.g., customer
            location, merchant settings).
          uniqueItems: true
        billing:
          $ref: '#/components/schemas/BillingAddress'
          description: Billing address details for the payment
        billing_currency:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Currency'
              description: >-
                Fix the currency in which the end customer is billed.

                If Dodo Payments cannot support that currency for this
                transaction, it will not proceed
        customer:
          $ref: '#/components/schemas/CustomerRequest'
          description: Customer information for the payment
        customer_business_name:
          type:
            - string
            - 'null'
          description: >-
            Optional business / legal name associated with the tax id. When
            provided

            together with a valid tax id for a B2B purchase, this name is
            rendered

            on the invoice instead of the customer's personal name.
        discount_code:
          type:
            - string
            - 'null'
          description: >-
            DEPRECATED: Use discount_codes instead. Cannot be used together with
            discount_codes.
          deprecated: true
          x-stainless-deprecation-message: Use `discount_id` instead.
        discount_codes:
          type:
            - array
            - 'null'
          items:
            type: string
          description: |-
            Stacked discount codes to apply, in order of application. Max 20.
            Cannot be used together with discount_code.
        force_3ds:
          type:
            - boolean
            - 'null'
          description: Override merchant default 3DS behaviour for this payment
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: |-
            Additional metadata associated with the payment.
            Defaults to empty if not provided.
        payment_link:
          type:
            - boolean
            - 'null'
          description: >-
            Whether to generate a payment link. Defaults to false if not
            specified.
        payment_method_id:
          type:
            - string
            - 'null'
          description: >-
            Optional payment method ID to use for this payment.

            If provided, customer_id must also be provided.

            The payment method will be validated for eligibility with the
            payment's currency.
        product_cart:
          type: array
          items:
            $ref: '#/components/schemas/OneTimeProductCartItemReq'
          description: >-
            List of products in the cart. Must contain at least 1 and at most
            100 items.
        redirect_immediately:
          type: boolean
          description: |-
            If true, redirects the customer immediately after payment completion
            False by default
        require_phone_number:
          type: boolean
          description: >-
            If true, the customer's phone number is required to create this
            payment.

            Typically set alongside `payment_link=true` so merchants can enforce
            phone

            collection on the hosted payment page. Defaults to false.
        return_url:
          type:
            - string
            - 'null'
          description: |-
            Optional URL to redirect the customer after payment.
            Must be a valid URL if provided.
        short_link:
          type:
            - boolean
            - 'null'
          description: |-
            If true, returns a shortened payment link.
            Defaults to false if not specified.
        show_saved_payment_methods:
          type: boolean
          description: |-
            Display saved payment methods of a returning customer
            False by default
        tax_id:
          type:
            - string
            - 'null'
          description: >-
            Tax ID in case the payment is B2B. If tax id validation fails the
            payment creation will fail
    CreateOneTimePaymentResponse:
      type: object
      title: Create One-Time Payment Response
      required:
        - payment_id
        - total_amount
        - client_secret
        - customer
        - metadata
      properties:
        client_secret:
          type: string
          description: |-
            Client secret used to load Dodo checkout SDK
            NOTE : Dodo checkout SDK will be coming soon
        customer:
          $ref: '#/components/schemas/CustomerLimitedDetailsResponse'
          description: Limited details about the customer making the payment
        discount_id:
          type:
            - string
            - 'null'
          description: >-
            DEPRECATED: Use discount_ids instead. Returns the first discount's
            ID if present.
          deprecated: true
          x-stainless-deprecation-message: Use `discounts` instead.
        discount_ids:
          type:
            - array
            - 'null'
          items:
            type: string
          description: All stacked discount IDs applied, in order of application
        expires_on:
          type:
            - string
            - 'null'
          format: date-time
          description: Expiry timestamp of the payment link
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Additional metadata associated with the payment
        payment_id:
          type: string
          description: Unique identifier for the payment
        payment_link:
          type:
            - string
            - 'null'
          description: Optional URL to a hosted payment page
        product_cart:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/OneTimeProductCartItemReq'
          description: Optional list of products included in the payment
        total_amount:
          type: integer
          format: int32
          description: |-
            Total amount of the payment in the currency's smallest unit
            (cents for USD, yen for JPY, fils for KWD)
          minimum: 0
    PaymentMethodTypes:
      type: string
      description: |-
        All supported payment method types.

        Used for disabled-payment-methods filtering and validation.
      enum:
        - ach
        - affirm
        - afterpay_clearpay
        - alfamart
        - ali_pay
        - ali_pay_hk
        - alma
        - amazon_pay
        - apple_pay
        - atome
        - bacs
        - bancontact_card
        - becs
        - benefit
        - bizum
        - blik
        - boleto
        - bca_bank_transfer
        - bni_va
        - bri_va
        - card_redirect
        - cimb_va
        - classic
        - credit
        - crypto_currency
        - cashapp
        - dana
        - danamon_va
        - debit
        - duit_now
        - efecty
        - eft
        - eps
        - fps
        - evoucher
        - giropay
        - givex
        - google_pay
        - go_pay
        - gcash
        - ideal
        - interac
        - indomaret
        - klarna
        - kakao_pay
        - local_bank_redirect
        - mandiri_va
        - knet
        - mb_way
        - mobile_pay
        - momo
        - momo_atm
        - multibanco
        - online_banking_thailand
        - online_banking_czech_republic
        - online_banking_finland
        - online_banking_fpx
        - online_banking_poland
        - online_banking_slovakia
        - oxxo
        - pago_efectivo
        - permata_bank_transfer
        - open_banking_uk
        - pay_bright
        - paypal
        - paze
        - pix
        - pay_safe_card
        - przelewy24
        - prompt_pay
        - pse
        - red_compra
        - red_pagos
        - samsung_pay
        - sepa
        - sepa_bank_transfer
        - sofort
        - sunbit
        - swish
        - touch_n_go
        - trustly
        - twint
        - upi_collect
        - upi_intent
        - vipps
        - viet_qr
        - venmo
        - walley
        - we_chat_pay
        - seven_eleven
        - lawson
        - mini_stop
        - family_mart
        - seicomart
        - pay_easy
        - local_bank_transfer
        - mifinity
        - open_banking_pis
        - direct_carrier_billing
        - instant_bank_transfer
        - billie
        - zip
        - revolut_pay
        - naver_pay
        - payco
    BillingAddress:
      type: object
      required:
        - country
      properties:
        city:
          type:
            - string
            - 'null'
          description: City name
        country:
          $ref: '#/components/schemas/CountryCodeAlpha2'
          description: Two-letter ISO country code (ISO 3166-1 alpha-2)
        state:
          type:
            - string
            - 'null'
          description: State or province name
        street:
          type:
            - string
            - 'null'
          description: >-
            Street address including house number and unit/apartment if
            applicable
        zipcode:
          type:
            - string
            - 'null'
          description: Postal code or ZIP code
    Currency:
      type: string
      enum:
        - AED
        - ALL
        - AMD
        - ANG
        - AOA
        - ARS
        - AUD
        - AWG
        - AZN
        - BAM
        - BBD
        - BDT
        - BGN
        - BHD
        - BIF
        - BMD
        - BND
        - BOB
        - BRL
        - BSD
        - BWP
        - BYN
        - BZD
        - CAD
        - CHF
        - CLP
        - CNY
        - COP
        - CRC
        - CUP
        - CVE
        - CZK
        - DJF
        - DKK
        - DOP
        - DZD
        - EGP
        - ETB
        - EUR
        - FJD
        - FKP
        - GBP
        - GEL
        - GHS
        - GIP
        - GMD
        - GNF
        - GTQ
        - GYD
        - HKD
        - HNL
        - HRK
        - HTG
        - HUF
        - IDR
        - ILS
        - INR
        - IQD
        - JMD
        - JOD
        - JPY
        - KES
        - KGS
        - KHR
        - KMF
        - KRW
        - KWD
        - KYD
        - KZT
        - LAK
        - LBP
        - LKR
        - LRD
        - LSL
        - LYD
        - MAD
        - MDL
        - MGA
        - MKD
        - MMK
        - MNT
        - MOP
        - MRU
        - MUR
        - MVR
        - MWK
        - MXN
        - MYR
        - MZN
        - NAD
        - NGN
        - NIO
        - NOK
        - NPR
        - NZD
        - OMR
        - PAB
        - PEN
        - PGK
        - PHP
        - PKR
        - PLN
        - PYG
        - QAR
        - RON
        - RSD
        - RUB
        - RWF
        - SAR
        - SBD
        - SCR
        - SEK
        - SGD
        - SHP
        - SLE
        - SLL
        - SOS
        - SRD
        - SSP
        - STN
        - SVC
        - SZL
        - THB
        - TND
        - TOP
        - TRY
        - TTD
        - TWD
        - TZS
        - UAH
        - UGX
        - USD
        - UYU
        - UZS
        - VES
        - VND
        - VUV
        - WST
        - XAF
        - XCD
        - XOF
        - XPF
        - YER
        - ZAR
        - ZMW
    CustomerRequest:
      oneOf:
        - $ref: '#/components/schemas/AttachExistingCustomer'
        - $ref: '#/components/schemas/NewCustomer'
      title: Customer Request
    Metadata:
      type: object
      additionalProperties:
        type: string
      propertyNames:
        type: string
    OneTimeProductCartItemReq:
      type: object
      title: One-Time Product Cart Item
      required:
        - product_id
        - quantity
      properties:
        amount:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Amount the customer pays if pay_what_you_want is enabled. If
            disabled then amount will be ignored

            Represented in the lowest denomination of the currency (e.g., cents
            for USD).

            For example, to charge $1.00, pass `100`.
        product_id:
          type: string
        quantity:
          type: integer
          format: int32
          minimum: 0
    CustomerLimitedDetailsResponse:
      type: object
      required:
        - customer_id
        - name
        - email
      properties:
        customer_id:
          type: string
          description: Unique identifier for the customer
        email:
          type: string
          description: Email address of the customer
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Additional metadata associated with the customer
        name:
          type: string
          description: Full name of the customer
        phone_number:
          type:
            - string
            - 'null'
          description: Phone number of the customer
    CountryCodeAlpha2:
      type: string
      description: ISO country code alpha2 variant
      enum:
        - AF
        - AX
        - AL
        - DZ
        - AS
        - AD
        - AO
        - AI
        - AQ
        - AG
        - AR
        - AM
        - AW
        - AU
        - AT
        - AZ
        - BS
        - BH
        - BD
        - BB
        - BY
        - BE
        - BZ
        - BJ
        - BM
        - BT
        - BO
        - BQ
        - BA
        - BW
        - BV
        - BR
        - IO
        - BN
        - BG
        - BF
        - BI
        - KH
        - CM
        - CA
        - CV
        - KY
        - CF
        - TD
        - CL
        - CN
        - CX
        - CC
        - CO
        - KM
        - CG
        - CD
        - CK
        - CR
        - CI
        - HR
        - CU
        - CW
        - CY
        - CZ
        - DK
        - DJ
        - DM
        - DO
        - EC
        - EG
        - SV
        - GQ
        - ER
        - EE
        - ET
        - FK
        - FO
        - FJ
        - FI
        - FR
        - GF
        - PF
        - TF
        - GA
        - GM
        - GE
        - DE
        - GH
        - GI
        - GR
        - GL
        - GD
        - GP
        - GU
        - GT
        - GG
        - GN
        - GW
        - GY
        - HT
        - HM
        - VA
        - HN
        - HK
        - HU
        - IS
        - IN
        - ID
        - IR
        - IQ
        - IE
        - IM
        - IL
        - IT
        - JM
        - JP
        - JE
        - JO
        - KZ
        - KE
        - KI
        - KP
        - KR
        - KW
        - KG
        - LA
        - LV
        - LB
        - LS
        - LR
        - LY
        - LI
        - LT
        - LU
        - MO
        - MK
        - MG
        - MW
        - MY
        - MV
        - ML
        - MT
        - MH
        - MQ
        - MR
        - MU
        - YT
        - MX
        - FM
        - MD
        - MC
        - MN
        - ME
        - MS
        - MA
        - MZ
        - MM
        - NA
        - NR
        - NP
        - NL
        - NC
        - NZ
        - NI
        - NE
        - NG
        - NU
        - NF
        - MP
        - 'NO'
        - OM
        - PK
        - PW
        - PS
        - PA
        - PG
        - PY
        - PE
        - PH
        - PN
        - PL
        - PT
        - PR
        - QA
        - RE
        - RO
        - RU
        - RW
        - BL
        - SH
        - KN
        - LC
        - MF
        - PM
        - VC
        - WS
        - SM
        - ST
        - SA
        - SN
        - RS
        - SC
        - SL
        - SG
        - SX
        - SK
        - SI
        - SB
        - SO
        - ZA
        - GS
        - SS
        - ES
        - LK
        - SD
        - SR
        - SJ
        - SZ
        - SE
        - CH
        - SY
        - TW
        - TJ
        - TZ
        - TH
        - TL
        - TG
        - TK
        - TO
        - TT
        - TN
        - TR
        - TM
        - TC
        - TV
        - UG
        - UA
        - AE
        - GB
        - UM
        - US
        - UY
        - UZ
        - VU
        - VE
        - VN
        - VG
        - VI
        - WF
        - EH
        - YE
        - ZM
        - ZW
    AttachExistingCustomer:
      type: object
      title: Attach Existing Customer
      required:
        - customer_id
      properties:
        customer_id:
          type: string
    NewCustomer:
      type: object
      title: New Customer
      required:
        - email
      properties:
        email:
          type: string
          description: Email is required for creating a new customer
        name:
          type:
            - string
            - 'null'
          description: >-
            Optional full name of the customer. If provided during session
            creation,

            it is persisted and becomes immutable for the session. If omitted
            here,

            it can be provided later via the confirm API.
        phone_number:
          type:
            - string
            - 'null'
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````