【发布时间】: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
}
【问题讨论】:
-
你在这个项目中安装了 Stripe nuget 包吗?您是否查阅过官方文档,而不仅仅是第三方教程?
-
是的,使用最新的包 37.10.0。我在他们的文档 github.com/stripe/stripe-dotnet 或 API 文档 stripe.com/docs/api 中找不到一个很好的例子
-
我没有看到你在他们的仓库中提到的任何缺失的类,这让我相信你引用的样本已经过时了。见github.com/stripe/stripe-dotnet/issues/2015
标签: xamarin.forms stripe-payments