Search code examples
c#asp.netapistripe-payments

How to get a List of valid currencies from Stripe


We provide to a bunch of customers a website so that their customers can make a booking and purchase services online using Stripe. I am in the process of Internationalizing but I have hit a barrier where some currencies are not valid for Stripe and we don't find out until we attempt to make the payment. I have tried to find a way of retrieving a list of valid currencies from Stripe so that our software can check against it before offering the option to purchase services and I can't find anything like that.

Does anybody know of a solution for automating the process?

I am curious to hear how other people have tackled this problem.


Solution

  • You can use country_specs endpoint - https://stripe.com/docs/api/country_specs

    CountrySpecService is available in Stripe.NET and returns this kind of objects (see model below). I think you are looking for SupportedBankAccountCurrencies or SupportedPaymentCurrencies

    // File generated from our OpenAPI spec
    namespace Stripe
    {
        using System.Collections.Generic;
        using Newtonsoft.Json;
    
        /// <summary>
        /// Stripe needs to collect certain pieces of information about each account created. These
        /// requirements can differ depending on the account's country. The Country Specs API makes
        /// these rules available to your integration.
        ///
        /// You can also view the information from this API call as <a
        /// href="https://stripe.com/docs/connect/required-verification-information">an online
        /// guide</a>.
        /// </summary>
        public class CountrySpec : StripeEntity<CountrySpec>, IHasId, IHasObject
        {
            /// <summary>
            /// Unique identifier for the object. Represented as the ISO country code for this country.
            /// </summary>
            [JsonProperty("id")]
            public string Id { get; set; }
    
            /// <summary>
            /// String representing the object's type. Objects of the same type share the same value.
            /// </summary>
            [JsonProperty("object")]
            public string Object { get; set; }
    
            /// <summary>
            /// The default currency for this country. This applies to both payment methods and bank
            /// accounts.
            /// </summary>
            [JsonProperty("default_currency")]
            public string DefaultCurrency { get; set; }
    
            /// <summary>
            /// Currencies that can be accepted in the specific country (for transfers).
            /// </summary>
            [JsonProperty("supported_bank_account_currencies")]
            public Dictionary<string, List<string>> SupportedBankAccountCurrencies { get; set; }
    
            /// <summary>
            /// Currencies that can be accepted in the specified country (for payments).
            /// </summary>
            [JsonProperty("supported_payment_currencies")]
            public List<string> SupportedPaymentCurrencies { get; set; }
    
            /// <summary>
            /// Payment methods available in the specified country. You may need to enable some payment
            /// methods (e.g., <a href="https://stripe.com/docs/ach">ACH</a>) on your account before
            /// they appear in this list. The <c>stripe</c> payment method refers to <a
            /// href="https://stripe.com/docs/connect/destination-charges">charging through your
            /// platform</a>.
            /// </summary>
            [JsonProperty("supported_payment_methods")]
            public List<string> SupportedPaymentMethods { get; set; }
    
            /// <summary>
            /// Countries that can accept transfers from the specified country.
            /// </summary>
            [JsonProperty("supported_transfer_countries")]
            public List<string> SupportedTransferCountries { get; set; }
    
            [JsonProperty("verification_fields")]
            public Dictionary<string, Dictionary<string, List<string>>> VerificationFields { get; set; }
        }
    }
    

    Source: https://github.com/stripe/stripe-dotnet/blob/3d8d1150c9136f3d5b78e8b9b803e858cda5fe53/src/Stripe.net/Entities/CountrySpecs/CountrySpec.cs