POST
/
payments
import DodoPayments from 'dodopayments';

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

async function main() {
  const payment = await client.payments.create({
    billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' },
    customer: { customer_id: 'customer_id' },
    product_cart: [{ product_id: 'product_id', quantity: 0 }],
  });

  console.log(payment.payment_id);
}

main();
{
  "client_secret": "<string>",
  "customer": {
    "customer_id": "<string>",
    "email": "<string>",
    "name": "<string>"
  },
  "discount_id": "<string>",
  "metadata": {},
  "payment_id": "<string>",
  "payment_link": "<string>",
  "product_cart": [
    {
      "amount": 123,
      "product_id": "<string>",
      "quantity": 1
    }
  ],
  "total_amount": 1
}

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
customer
object
required
product_cart
object[]
required

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

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

Available options:
credit,
debit,
upi_collect,
upi_intent,
apple_pay,
cashapp,
google_pay,
multibanco,
bancontact_card,
eps,
ideal,
przelewy24,
affirm,
klarna,
sepa,
ach,
amazon_pay
billing_currency
enum<string>
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
discount_code
string | null

Discount Code to apply to the transaction

metadata
object

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

return_url
string | null

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

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

200 - application/json
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
metadata
object
required
payment_id
string
required

Unique identifier for the payment

total_amount
integer
required

Total amount of the payment in smallest currency unit (e.g. cents)

Required range: x >= 0
discount_id
string | null

The discount id if discount is applied

Optional URL to a hosted payment page

product_cart
object[] | null

Optional list of products included in the payment