如何从 Stripe 获取有效货币列表

问题描述 投票:0回答:1

我们为大量客户提供一个网站,以便他们的客户可以使用 Stripe 在线预订和购买服务。我正在国际化过程中,但我遇到了一个障碍,即某些货币对 Stripe 无效,直到我们尝试付款时我们才发现。我试图找到一种从 Stripe 检索有效货币列表的方法,以便我们的软件可以在提供购买服务的选项之前对其进行检查,但我找不到类似的东西。

有人知道自动化流程的解决方案吗?

我很好奇其他人是如何解决这个问题的。

c# asp.net stripe-payments
1个回答
3
投票

您可以使用country_specs端点 - https://stripe.com/docs/api/country_specs

CountrySpecService
在 Stripe.NET 中可用并返回此类对象(请参见下面的模型)。我认为您正在寻找
SupportedBankAccountCurrencies
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; }
    }
}

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

© www.soinside.com 2019 - 2024. All rights reserved.