Subscriptions
Truy xuất Sử dụng Tín dụng
Truy xuất việc sử dụng tín dụng cho một đăng ký.
GET
/
subscriptions
/
{subscription_id}
/
credit-usage
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.subscriptions.retrieveCreditUsage('sub_Iuaq622bbmmfOGrVTqdXv');
console.log(response.subscription_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
)
response = client.subscriptions.retrieve_credit_usage(
"sub_Iuaq622bbmmfOGrVTqdXv",
)
print(response.subscription_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"),
)
response, err := client.Subscriptions.GetCreditUsage(context.TODO(), "sub_Iuaq622bbmmfOGrVTqdXv")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.SubscriptionID)
}package com.dodopayments.api.example;
import com.dodopayments.api.client.DodoPaymentsClient;
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
import com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageParams;
import com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();
SubscriptionRetrieveCreditUsageResponse response = client.subscriptions().retrieveCreditUsage("sub_Iuaq622bbmmfOGrVTqdXv");
}
}package com.dodopayments.api.example
import com.dodopayments.api.client.DodoPaymentsClient
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
import com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageParams
import com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageResponse
fun main() {
val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()
val response: SubscriptionRetrieveCreditUsageResponse = client.subscriptions().retrieveCreditUsage("sub_Iuaq622bbmmfOGrVTqdXv")
}require "dodopayments"
dodo_payments = Dodopayments::Client.new(
bearer_token: "My Bearer Token",
environment: "test_mode" # defaults to "live_mode"
)
response = dodo_payments.subscriptions.retrieve_credit_usage("sub_Iuaq622bbmmfOGrVTqdXv")
puts(response)<?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 {
$response = $client->subscriptions->retrieveCreditUsage(
'sub_Iuaq622bbmmfOGrVTqdXv'
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using DodoPayments.Client;
using DodoPayments.Client.Models.Subscriptions;
DodoPaymentsClient client = new();
SubscriptionRetrieveCreditUsageParams parameters = new()
{
SubscriptionID = "sub_Iuaq622bbmmfOGrVTqdXv"
};
var response = await client.Subscriptions.RetrieveCreditUsage(parameters);
Console.WriteLine(response);use dodopayments::Client;
#[tokio::main]
async fn main() -> dodopayments::Result<()> {
let client = Client::from_env()?;
let subscription_id = "subscription_id";
let result = client
.subscriptions()
.retrieve_credit_usage()
.subscription_id(subscription_id)
.await?;
println!("{result:?}");
Ok(())
}curl --request GET \
--url https://test.dodopayments.com/subscriptions/{subscription_id}/credit-usage \
--header 'Authorization: Bearer <token>'{
"items": [
{
"balance": "250.00",
"credit_entitlement_id": "<string>",
"credit_entitlement_name": "<string>",
"limit_reached": true,
"overage": "15.50",
"overage_enabled": true,
"unit": "<string>",
"overage_limit": "100.00",
"remaining_headroom": "84.50"
}
],
"subscription_id": "<string>"
}Ủy quyền
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Tham số đường dẫn
Subscription ID
Lần sửa đổi cuối 1 tháng 4, 2026
Trang này có hữu ích không?
Trước
Cập nhật phương thức thanh toánCập nhật phương thức thanh toán cho một đăng ký hiện có. Bạn có thể thêm một phương thức thanh toán mới hoặc sử dụng một phương thức đã có từ các phương thức thanh toán đã lưu của khách hàng.
Tiếp theo
⌘I
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.subscriptions.retrieveCreditUsage('sub_Iuaq622bbmmfOGrVTqdXv');
console.log(response.subscription_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
)
response = client.subscriptions.retrieve_credit_usage(
"sub_Iuaq622bbmmfOGrVTqdXv",
)
print(response.subscription_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"),
)
response, err := client.Subscriptions.GetCreditUsage(context.TODO(), "sub_Iuaq622bbmmfOGrVTqdXv")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.SubscriptionID)
}package com.dodopayments.api.example;
import com.dodopayments.api.client.DodoPaymentsClient;
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
import com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageParams;
import com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();
SubscriptionRetrieveCreditUsageResponse response = client.subscriptions().retrieveCreditUsage("sub_Iuaq622bbmmfOGrVTqdXv");
}
}package com.dodopayments.api.example
import com.dodopayments.api.client.DodoPaymentsClient
import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
import com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageParams
import com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageResponse
fun main() {
val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()
val response: SubscriptionRetrieveCreditUsageResponse = client.subscriptions().retrieveCreditUsage("sub_Iuaq622bbmmfOGrVTqdXv")
}require "dodopayments"
dodo_payments = Dodopayments::Client.new(
bearer_token: "My Bearer Token",
environment: "test_mode" # defaults to "live_mode"
)
response = dodo_payments.subscriptions.retrieve_credit_usage("sub_Iuaq622bbmmfOGrVTqdXv")
puts(response)<?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 {
$response = $client->subscriptions->retrieveCreditUsage(
'sub_Iuaq622bbmmfOGrVTqdXv'
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using DodoPayments.Client;
using DodoPayments.Client.Models.Subscriptions;
DodoPaymentsClient client = new();
SubscriptionRetrieveCreditUsageParams parameters = new()
{
SubscriptionID = "sub_Iuaq622bbmmfOGrVTqdXv"
};
var response = await client.Subscriptions.RetrieveCreditUsage(parameters);
Console.WriteLine(response);use dodopayments::Client;
#[tokio::main]
async fn main() -> dodopayments::Result<()> {
let client = Client::from_env()?;
let subscription_id = "subscription_id";
let result = client
.subscriptions()
.retrieve_credit_usage()
.subscription_id(subscription_id)
.await?;
println!("{result:?}");
Ok(())
}curl --request GET \
--url https://test.dodopayments.com/subscriptions/{subscription_id}/credit-usage \
--header 'Authorization: Bearer <token>'{
"items": [
{
"balance": "250.00",
"credit_entitlement_id": "<string>",
"credit_entitlement_name": "<string>",
"limit_reached": true,
"overage": "15.50",
"overage_enabled": true,
"unit": "<string>",
"overage_limit": "100.00",
"remaining_headroom": "84.50"
}
],
"subscription_id": "<string>"
}