मुख्य सामग्री पर जाएं
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);
{
  "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>",
  "expires_on": "2023-11-07T05:31:56Z",
  "payment_link": "<string>",
  "product_cart": [
    {
      "product_id": "<string>",
      "quantity": 1,
      "amount": 123
    }
  ]
}
पुराना API: यह API जल्द ही पुरानी हो जाएगी। हम इसके बजाय Checkout Sessions का उपयोग करने की सिफारिश करते हैं, जो एक बार के भुगतानों और सब्सक्रिप्शन के लिए भुगतान लिंक बनाने के लिए एक अधिक शक्तिशाली और अनुकूलन योग्य API प्रदान करता है।

प्राधिकरण

Authorization
string
header
आवश्यक

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

बॉडी

application/json
billing
object
आवश्यक

Billing address details for the payment

customer
Attach Existing Customer · object
आवश्यक

Customer information for the payment

product_cart
One-Time Product Cart Item · object[]
आवश्यक

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

उपलब्ध विकल्प:
credit,
debit,
upi_collect,
upi_intent,
apple_pay,
cashapp,
google_pay,
multibanco,
bancontact_card,
eps,
ideal,
przelewy24,
paypal,
affirm,
klarna,
sepa,
ach,
amazon_pay,
afterpay_clearpay
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

उपलब्ध विकल्प:
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

force_3ds
boolean | null

Override merchant default 3DS behaviour for this payment

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.

redirect_immediately
boolean

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

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

प्रतिक्रिया

One Time payment successfully initiated

client_secret
string
आवश्यक

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

customer
object
आवश्यक

Limited details about the customer making the payment

metadata
object
आवश्यक

Additional metadata associated with the payment

payment_id
string
आवश्यक

Unique identifier for the payment

total_amount
integer<int32>
आवश्यक

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

आवश्यक सीमा: x >= 0
discount_id
string | null

The discount id if discount is applied

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