Create Refund

Create a refund for a payment.

Request

use dodopayments_rust::{models::CreateRefundRequest, 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 resp = client
        .refunds()
        .create()
        .body(CreateRefundRequest {
            payment_id: "pay_xxxxxxxxxx".to_string(),
            ..Default::default()
        })
        .send()
        .await?;

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

    Ok(())
}

Body

FieldTypeDescription
itemsobjectPartially Refund an Individual Item
metadataMetadataAdditional metadata associated with the refund.
payment_idstringThe unique identifier of the payment to be refunded.
reasonobjectThe reason for the refund, if any. Maximum length is 3000 characters. Optional.

Responses

200 Status

FieldTypeDescription
amountobjectThe refunded amount.
business_idstringThe unique identifier of the business issuing the refund.
created_atstringThe timestamp of when the refund was created in UTC.
currencyobject
customerCustomerLimitedDetailsResponseDetails about the customer for this refund (from the associated payment)
is_partialbooleanIf true the refund is a partial refund
metadataMetadataAdditional metadata stored with the refund.
payment_idstringThe unique identifier of the payment associated with the refund.
reasonobjectThe reason provided for the refund, if any. Optional.
refund_idstringThe unique identifier of the refund.
statusRefundStatusThe current status of the refund.

Refund successfully initiated

400 Status

Invalid Request Parameters

422 Status

Invalid Request Object or Parameters

500 Status

Something went wrong :(