Create Payment

Create a one-time payment for a customer.

Request

use dodopayments_rust::{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()?;

    println!("Note: create payment API is deprecated. Use checkout sessions instead.");
    println!("See create_checkout.rs example");

    Ok(())
}

Body

FieldTypeDescription
allowed_payment_method_typesobjectList of payment methods allowed during checkout. Customers will never see payment methods that are not in this list. However, adding a method here does not guarantee customers will see it. Availability still depends on other factors (e.g., customer location, merchant settings).
billingBillingAddressBilling address details for the payment
billing_currencyobject
customerCustomerRequestCustomer information for the payment
discount_codeobjectDiscount Code to apply to the transaction
force_3dsobjectOverride merchant default 3DS behaviour for this payment
metadataMetadataAdditional metadata associated with the payment. Defaults to empty if not provided.
payment_linkobjectWhether to generate a payment link. Defaults to false if not specified.
payment_method_idobjectOptional payment method ID to use for this payment. If provided, customer_id must also be provided. The payment method will be validated for eligibility with the payment's currency.
product_cartarray<OneTimeProductCartItemReq>List of products in the cart. Must contain at least 1 and at most 100 items.
redirect_immediatelybooleanIf true, redirects the customer immediately after payment completion False by default
return_urlobjectOptional URL to redirect the customer after payment. Must be a valid URL if provided.
short_linkobjectIf true, returns a shortened payment link. Defaults to false if not specified.
show_saved_payment_methodsbooleanDisplay saved payment methods of a returning customer False by default
tax_idobjectTax ID in case the payment is B2B. If tax id validation fails the payment creation will fail

Responses

200 Status

FieldTypeDescription
client_secretstringClient secret used to load Dodo checkout SDK NOTE : Dodo checkout SDK will be coming soon
customerCustomerLimitedDetailsResponseLimited details about the customer making the payment
discount_idobjectThe discount id if discount is applied
expires_onobjectExpiry timestamp of the payment link
metadataMetadataAdditional metadata associated with the payment
payment_idstringUnique identifier for the payment
payment_linkobjectOptional URL to a hosted payment page
product_cartobjectOptional list of products included in the payment
total_amountintegerTotal amount of the payment in smallest currency unit (e.g. cents)

One Time payment successfully initiated

422 Status

Invalid Request Object or Parameters

500 Status

Something went wrong :(