Langsung ke konten utama
POST
/
credit-entitlements
/
{credit_entitlement_id}
/
balances
/
{customer_id}
/
ledger-entries
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 response = await client.creditEntitlements.balances.createLedgerEntry('customer_id', {
  credit_entitlement_id: 'credit_entitlement_id',
  amount: 'amount',
  entry_type: 'credit',
});

console.log(response.id);
{
  "amount": "<string>",
  "balance_after": "<string>",
  "balance_before": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "credit_entitlement_id": "<string>",
  "customer_id": "<string>",
  "entry_type": "credit",
  "id": "<string>",
  "is_credit": true,
  "overage_after": "<string>",
  "overage_before": "<string>",
  "grant_id": "<string>",
  "reason": "<string>"
}

Otorisasi

Authorization
string
header
wajib

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

Parameter Path

credit_entitlement_id
string
wajib

Credit Entitlement ID

customer_id
string
wajib

Customer ID

Body

application/json

Request to create a ledger entry (credit or debit)

amount
string
wajib

Amount to credit or debit

entry_type
enum<string>
wajib

Entry type: credit or debit

Opsi yang tersedia:
credit,
debit
expires_at
string<date-time> | null

Expiration for credited amount (only for credit type)

idempotency_key
string | null

Idempotency key to prevent duplicate entries

metadata
object

Optional metadata (max 50 key-value pairs, key max 40 chars, value max 500 chars)

reason
string | null

Human-readable reason for the entry

Respons

Ledger entry created successfully

Response for creating a ledger entry

amount
string
wajib
balance_after
string
wajib
balance_before
string
wajib
created_at
string<date-time>
wajib
credit_entitlement_id
string
wajib
customer_id
string
wajib
entry_type
enum<string>
wajib
Opsi yang tersedia:
credit,
debit
id
string
wajib
is_credit
boolean
wajib
overage_after
string
wajib
overage_before
string
wajib
grant_id
string | null
reason
string | null