Vai al contenuto principale
GET
/
credit-entitlements
/
{credit_entitlement_id}
/
balances
/
{customer_id}
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 customerCreditBalance = await client.creditEntitlements.balances.retrieve(
  'cus_TV52uJWWXt2yIoBBxpjaa',
  { credit_entitlement_id: 'cde_ztxm5XJsKxWucRWA3rjdM' },
);

console.log(customerCreditBalance.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
)
customer_credit_balance = client.credit_entitlements.balances.retrieve(
    customer_id="cus_TV52uJWWXt2yIoBBxpjaa",
    credit_entitlement_id="cde_ztxm5XJsKxWucRWA3rjdM",
)
print(customer_credit_balance.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"),
	)
	customerCreditBalance, err := client.CreditEntitlements.Balances.Get(
		context.TODO(),
		"cde_ztxm5XJsKxWucRWA3rjdM",
		"cus_TV52uJWWXt2yIoBBxpjaa",
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", customerCreditBalance.ID)
}
package com.dodopayments.api.example;

import com.dodopayments.api.client.DodoPaymentsClient;
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
import com.dodopayments.api.models.creditentitlements.balances.BalanceRetrieveParams;
import com.dodopayments.api.models.creditentitlements.balances.CustomerCreditBalance;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

        BalanceRetrieveParams params = BalanceRetrieveParams.builder()
            .creditEntitlementId("cde_ztxm5XJsKxWucRWA3rjdM")
            .customerId("cus_TV52uJWWXt2yIoBBxpjaa")
            .build();
        CustomerCreditBalance customerCreditBalance = client.creditEntitlements().balances().retrieve(params);
    }
}
package com.dodopayments.api.example

import com.dodopayments.api.client.DodoPaymentsClient
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
import com.dodopayments.api.models.creditentitlements.balances.BalanceRetrieveParams
import com.dodopayments.api.models.creditentitlements.balances.CustomerCreditBalance

fun main() {
    val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

    val params: BalanceRetrieveParams = BalanceRetrieveParams.builder()
        .creditEntitlementId("cde_ztxm5XJsKxWucRWA3rjdM")
        .customerId("cus_TV52uJWWXt2yIoBBxpjaa")
        .build()
    val customerCreditBalance: CustomerCreditBalance = client.creditEntitlements().balances().retrieve(params)
}
require "dodopayments"

dodo_payments = Dodopayments::Client.new(
  bearer_token: "My Bearer Token",
  environment: "test_mode" # defaults to "live_mode"
)

customer_credit_balance = dodo_payments.credit_entitlements.balances.retrieve(
  "cus_TV52uJWWXt2yIoBBxpjaa",
  credit_entitlement_id: "cde_ztxm5XJsKxWucRWA3rjdM"
)

puts(customer_credit_balance)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Dodopayments\Client;
use Dodopayments\Core\Exceptions\APIException;

$client = new Client(
  bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
  environment: 'test_mode',
);

try {
  $customerCreditBalance = $client->creditEntitlements->balances->retrieve(
    'cus_TV52uJWWXt2yIoBBxpjaa',
    creditEntitlementID: 'cde_ztxm5XJsKxWucRWA3rjdM',
  );

  var_dump($customerCreditBalance);
} catch (APIException $e) {
  echo $e->getMessage();
}
using System;
using DodoPayments.Client;
using DodoPayments.Client.Models.CreditEntitlements.Balances;

DodoPaymentsClient client = new();

BalanceRetrieveParams parameters = new()
{
    CreditEntitlementID = "cde_ztxm5XJsKxWucRWA3rjdM",
    CustomerID = "cus_TV52uJWWXt2yIoBBxpjaa",
};

var customerCreditBalance = await client.CreditEntitlements.Balances.Retrieve(parameters);

Console.WriteLine(customerCreditBalance);
use dodopayments::Client;

#[tokio::main]
async fn main() -> dodopayments::Result<()> {
    let client = Client::from_env()?;
    let credit_entitlement_id = "credit_entitlement_id";
    let customer_id = "customer_id";
    let result = client
        .credit_entitlements()
        .balances()
        .retrieve()
        .credit_entitlement_id(credit_entitlement_id)
        .customer_id(customer_id)
        .await?;
    println!("{result:?}");
    Ok(())
}
curl --request GET \
  --url https://test.dodopayments.com/credit-entitlements/{credit_entitlement_id}/balances/{customer_id} \
  --header 'Authorization: Bearer <token>'
{
  "balance": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "credit_entitlement_id": "<string>",
  "customer_id": "<string>",
  "id": "<string>",
  "overage": "<string>",
  "updated_at": "2023-11-07T05:31:56Z",
  "last_transaction_at": "2023-11-07T05:31:56Z"
}

Autorizzazioni

Authorization
string
header
obbligatorio

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

Parametri del percorso

credit_entitlement_id
string
obbligatorio

Credit Entitlement ID

customer_id
string
obbligatorio

Customer ID

Risposta

Customer balance details

Response for a customer's credit balance

balance
string
obbligatorio
created_at
string<date-time>
obbligatorio
credit_entitlement_id
string
obbligatorio
customer_id
string
obbligatorio
id
string
obbligatorio
overage
string
obbligatorio
updated_at
string<date-time>
obbligatorio
last_transaction_at
string<date-time> | null
Ultima modifica il 1 aprile 2026