Create Subscription Charge

Create an on-demand charge for a subscription.

Request

use dodopayments_rust::{
    models::CreateSubscriptionChargeRequest, to_pretty_json, DodoPaymentsClientBuilder,
};

#[tokio::main]

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = std::env::var("DODO_API_KEY")?;

    let client = DodoPaymentsClientBuilder::new()
        .bearer_token(&api_key)
        .enviroment("test_mode")
        .build()?;

    let subscription_id = "sub_xxxxxxxxxx";

    let resp = client
        .subscriptions()
        .id(subscription_id)
        .charge()
        .body(CreateSubscriptionChargeRequest {
            ..Default::default()
        })
        .send()
        .await?;

    println!("{}", to_pretty_json(&resp)?);

    Ok(())
}

Path Parameters

ParameterTypeDescription
subscription_idstringSubscription Id

Body

FieldTypeDescription
adaptive_currency_fees_inclusiveobjectWhether adaptive currency fees should be included in the product_price (true) or added on top (false). This field is ignored if adaptive pricing is not enabled for the business.
customer_balance_configobject
metadataobject
product_currencyobject
product_descriptionobjectOptional product description override for billing and line items. If not specified, the stored description of the product will be used.
product_priceintegerThe product price. Represented in the lowest denomination of the currency (e.g., cents for USD). For example, to charge $1.00, pass 100.

Responses

200 Status

FieldTypeDescription
payment_idstring

Subscription Charge successfully created

422 Status

Invalid Request Object or Parameters

500 Status

Something went wrong :(