Use this file to discover all available pages before exploring further.
El SDK de C# proporciona acceso conveniente a la API REST de Dodo Payments desde aplicaciones escritas en C#. Presenta una API basada en Tareas asíncronas con tipado fuerte, reintentos automáticos y manejo integral de errores.
using System;using DodoPayments.Client;using DodoPayments.Client.Models.CheckoutSessions;// Configured using the DODO_PAYMENTS_API_KEY and DODO_PAYMENTS_BASE_URL environment variablesDodoPaymentsClient client = new();CheckoutSessionCreateParams parameters = new(){ ProductCart = [ new() { ProductID = "product_id", Quantity = 1, }, ],};var checkoutSessionResponse = await client.CheckoutSessions.Create(parameters);Console.WriteLine(checkoutSessionResponse.SessionId);
Guarda siempre tus claves de API de forma segura usando variables de entorno, secretos de usuario o Azure Key Vault. Nunca las codifiques directamente en tu código fuente ni las comprometas al control de versiones.
El SDK vuelve a intentar automáticamente 2 veces por defecto con retroceso exponencial. Reintenta en errores de conexión y códigos de estado 408, 409, 429 y 5xx.
using DodoPayments.Client.Models.Payments;using DodoPayments.Client.Models.Subscriptions;// Create a subscriptionvar subscription = await client.Subscriptions.Create(new SubscriptionCreateParams{ Billing = new BillingAddress { Country = "US", City = "San Francisco", State = "CA", Street = "1 Market St", Zipcode = "94105", }, Customer = new AttachExistingCustomer { CustomerID = "cus_123" }, ProductID = "pdt_456", Quantity = 1,});// Charge an on-demand subscription// ProductPrice is in the lowest currency denomination (e.g., 2500 = $25.00 USD)var charge = await client.Subscriptions.Charge( subscription.SubscriptionId, new SubscriptionChargeParams { ProductPrice = 2500 });
Billing requiere al menos el código Country ISO de dos letras. Use AttachExistingCustomer para adjuntar un cliente existente, o NewCustomer para crear uno. ProductPrice está en la denominación más baja de la moneda.