Skip to main content
POST
/
payments
JavaScript
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);
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)
package main

import (
"context"
"fmt"

"github.com/dodopayments/dodopayments-go"
"github.com/dodopayments/dodopayments-go/option"
)

func main() {
client := dodopayments.NewClient(
option.WithBearerToken("My Bearer Token"),
)
payment, err := client.Payments.New(context.TODO(), dodopayments.PaymentNewParams{
Billing: dodopayments.F(dodopayments.BillingAddressParam{
Country: dodopayments.F(dodopayments.CountryCodeAf),
}),
Customer: dodopayments.F[dodopayments.CustomerRequestUnionParam](dodopayments.AttachExistingCustomerParam{
CustomerID: dodopayments.F("customer_id"),
}),
ProductCart: dodopayments.F([]dodopayments.OneTimeProductCartItemParam{{
ProductID: dodopayments.F("product_id"),
Quantity: dodopayments.F(int64(0)),
}}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", payment.PaymentID)
}
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);
}
}
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)
}
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)
<?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();
}
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);
use dodopayments::Client;

#[tokio::main]
async fn main() -> dodopayments::Result<()> {
let client = Client::from_env()?;
let result = client
.payments()
.create()
.body(dodopayments::models::PaymentsCreateParams {
billing: Some(Box::new(dodopayments::models::BillingAddress {
country: Box::new(dodopayments::models::CountryCode::Af),
city: None,
state: None,
street: None,
zipcode: None,
})),
customer: Some(Box::new(dodopayments::models::CustomerRequest::AttachExistingCustomer(Box::new(dodopayments::models::AttachExistingCustomer {
customer_id: "customer_id".to_string(),
})))),
product_cart: Some(vec![dodopayments::models::OneTimeProductCartItem {
product_id: "product_id".to_string(),
quantity: 0,
amount: None,
}]),
..Default::default()
})
.await?;
println!("{result:?}");
Ok(())
}
curl --request POST \
--url https://test.dodopayments.com/payments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"billing": {
"city": "<string>",
"state": "<string>",
"street": "<string>",
"zipcode": "<string>"
},
"customer": {
"customer_id": "<string>"
},
"product_cart": [
{
"product_id": "<string>",
"quantity": 1,
"amount": 123
}
],
"adaptive_currency_fees_inclusive": true,
"allowed_payment_method_types": [],
"customer_business_name": "<string>",
"discount_code": "<string>",
"discount_codes": [
"<string>"
],
"force_3ds": true,
"metadata": {},
"payment_link": true,
"payment_method_id": "<string>",
"redirect_immediately": true,
"require_phone_number": true,
"return_url": "<string>",
"short_link": true,
"show_saved_payment_methods": true,
"tax_id": "<string>"
}
'
{
  "client_secret": "<string>",
  "customer": {
    "customer_id": "<string>",
    "email": "<string>",
    "name": "<string>",
    "metadata": {},
    "phone_number": "<string>"
  },
  "metadata": {},
  "payment_id": "<string>",
  "total_amount": 1,
  "discount_id": "<string>",
  "discount_ids": [
    "<string>"
  ],
  "expires_on": "2023-11-07T05:31:56Z",
  "payment_link": "<string>",
  "product_cart": [
    {
      "product_id": "<string>",
      "quantity": 1,
      "amount": 123
    }
  ]
}
Deprecated API: This API will be deprecated soon. We recommend using Checkout Sessions instead, which provides a more powerful and customizable API to create payment links for one-time payments and subscriptions.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
billing
object
required

Billing address details for the payment

customer
Attach Existing Customer · object
required

Customer information for the payment

product_cart
One-Time Product Cart Item · object[]
required

List of products in the cart. Must contain at least 1 and at most 100 items.

adaptive_currency_fees_inclusive
boolean | null

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
enum<string>[] | null

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).

All supported payment method types.

Used for disabled-payment-methods filtering and validation.

Available options:
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,
satispay
billing_currency
null | enum<string>

Fix the currency in which the end customer is billed. If Dodo Payments cannot support that currency for this transaction, it will not proceed

Available options:
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
customer_business_name
string | null

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
string | null
deprecated

DEPRECATED: Use discount_codes instead. Cannot be used together with discount_codes.

discount_codes
string[] | null

Stacked discount codes to apply, in order of application. Max 20. Cannot be used together with discount_code.

force_3ds
boolean | null

Override merchant default 3DS behaviour for this payment

metadata
Metadata · object

Additional metadata associated with the payment. Defaults to empty if not provided.

Whether to generate a payment link. Defaults to false if not specified.

payment_method_id
string | null

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.

redirect_immediately
boolean

If true, redirects the customer immediately after payment completion False by default

require_phone_number
boolean

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
string | null

Optional URL to redirect the customer after payment. Must be a valid URL if provided.

If true, returns a shortened payment link. Defaults to false if not specified.

show_saved_payment_methods
boolean

Display saved payment methods of a returning customer False by default

tax_id
string | null

Tax ID in case the payment is B2B. If tax id validation fails the payment creation will fail

Response

One Time payment successfully initiated

client_secret
string
required

Client secret used to load Dodo checkout SDK NOTE : Dodo checkout SDK will be coming soon

customer
object
required

Limited details about the customer making the payment

metadata
Metadata · object
required

Additional metadata associated with the payment

payment_id
string
required

Unique identifier for the payment

total_amount
integer<int32>
required

Total amount of the payment in the currency's smallest unit (cents for USD, yen for JPY, fils for KWD)

Required range: x >= 0
discount_id
string | null
deprecated

DEPRECATED: Use discount_ids instead. Returns the first discount's ID if present.

discount_ids
string[] | null

All stacked discount IDs applied, in order of application

expires_on
string<date-time> | null

Expiry timestamp of the payment link

Optional URL to a hosted payment page

product_cart
One-Time Product Cart Item · object[] | null

Optional list of products included in the payment

Last modified on March 25, 2026