Hoppa till huvudinnehåll
POST
/
checkouts
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 checkoutSessionResponse = await client.checkoutSessions.create({
  product_cart: [{ product_id: 'product_id', quantity: 0 }],
});

console.log(checkoutSessionResponse.session_id);
{
  "session_id": "<string>",
  "checkout_url": "<string>"
}

Auktoriseringar

Authorization
string
header
obligatorisk

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

Kropp

application/json
product_cart
Product Item Request · object[]
obligatorisk
allowed_payment_method_types
enum<string>[] | null

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

Disclaimar: Always provide 'credit' and 'debit' as a fallback. If all payment methods are unavailable, checkout session will fail.

Tillgängliga alternativ:
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,
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
billing_address
Checkout Session Billing Address · object

Billing address information for the session

billing_currency
null | enum<string>

This field is ingored if adaptive pricing is disabled

Tillgängliga alternativ:
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
confirm
boolean

If confirm is true, all the details will be finalized. If required data is missing, an API error is thrown.

customer
Attach Existing Customer · object

Customer details for the session

customization
Checkout Session Customization · object

Customization for the checkout session page

discount_code
string | null
feature_flags
Checkout Session Flags · object
force_3ds
boolean | null

Override merchant default 3DS behaviour for this session

metadata
object

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

minimal_address
boolean

If true, only zipcode is required when confirm is true; other address fields remain optional

payment_method_id
string | null

Optional payment method ID to use for this checkout session. Only allowed when confirm is true. If provided, existing customer id must also be provided.

return_url
string | null

The url to redirect after payment failure or success.

If true, returns a shortened checkout URL. Defaults to false if not specified.

show_saved_payment_methods
boolean

Display saved payment methods of a returning customer False by default

subscription_data
Subscription Data · object

Svar

Checkout session successfully created

session_id
string
obligatorisk

The ID of the created checkout session

checkout_url
string | null

Checkout url (None when payment_method_id is provided)