首页 > 解决方案 > 无法解析参考:Xamarin 中的“条纹”

问题描述

我正在尝试将 Stripe 付款合并到我的 Xamarin 应用程序中。我已经安装了最新的 Stripe NuGet 包,并在我的 .cs 中包含了以下代码:

using System;
using System.Collections.Generic;
using Stripe;
using Xamarin.Forms;

namespace CampaignFinanceNew
{
    public partial class CreditCardProcess : ContentPage
    {

    StripeClient paymentClient = new StripeClient("[test key here]");

    public CreditCardProcess()
    {
        InitializeComponent();

        CreditCard currentCard = new CreditCard();
        currentCard.Number = creditCardNumber.Text;
        currentCard.ExpMonth = Convert.ToInt32(ccExpiryMonth.Text);
        currentCard.ExpYear = Convert.ToInt32(ccExpiryYear.Text);

        StripeObject newToken = paymentClient.CreateCardToken(currentCard);

    }

}
}

当我构建项目时,它给了我以下错误:

错误 XA2002:无法解析引用:Stripe,由 引用CampaignFinanceNew。请为 . 添加 NuGet 包或程序集引用Stripe,或删除对CampaignFinanceNew. (XA2002) (CampaignFinanceNew.Android)

我尝试将 Stripe 包添加到我的 iOS 和 Android 项目中,但它告诉我它不兼容。我该怎么办?我会更好地为 iOS 和 Android 单独实现它,然后通过 DependencyService 访问它吗?

标签: androidiosxamarinmobilestripe-payments

解决方案


经过进一步研究,似乎有 2 种不同的 Stripe NuGet 包,一种是专门为 .NET 应用程序编写的(与我使用的相反)。我已经下载了新的软件包,现在一切似乎都很好。


推荐阅读