【问题标题】:Generating token to use in Stripe payment using Xamarin Forms使用 Xamarin Forms 生成要在 Stripe 支付中使用的令牌
【发布时间】:2020-06-12 18:21:41
【问题描述】:

我正在尝试在 Xamarin Forms 中创建一个收集卡信息的 UI,然后通过以下示例代码获取令牌,我发现该代码引用了 in this post in from May 以及 this post from 2018 引用了一篇不错的帖子 https://xamarinhelp.com/stripe-in-xamarin/,这似乎是我正在使用的示例代码的来源。

我的问题是StripeTokenCreateOptions、StripeCreditCardOptions、StripeTokenService、StripeToken都报找不到类型或命名空间错误。

using Stripe;
...
public string CreateToken(string cardNumber, string cardExpMonth, string cardExpYear, string cardCVC)
{
    StripeConfiguration.SetApiKey("pk_test_xxxxxxxxxxxxxxxxx");

    var tokenOptions = new StripeTokenCreateOptions()
    {
        Card = new StripeCreditCardOptions()
        {
            Number = cardNumber,
            ExpirationYear = cardExpYear,
            ExpirationMonth = cardExpMonth,
            Cvc = cardCVC
        }
    };

    var tokenService = new StripeTokenService();
    StripeToken stripeToken = tokenService.Create(tokenOptions);

    return stripeToken.Id; // This is the token
}

【问题讨论】:

标签: xamarin.forms stripe-payments


【解决方案1】:

看起来这很可能是您的项目设置中缺少程序集引用。 using Stripe; 是在您的项目中使用 Stripe 的唯一必要条件。例如:https://github.com/stripe-samples/subscription-use-cases/blob/master/fixed-price-subscriptions/server/dotnet/Controllers/BillingController.cs#L48-L94

我会尝试在您的项目中重新添加/重新安装 Stripe 包,看看是否能解决问题:https://github.com/stripe/stripe-dotnet#installation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-18
    • 2016-11-08
    • 1970-01-01
    • 2018-08-15
    • 2015-01-05
    • 1970-01-01
    相关资源
    最近更新 更多