简体   繁体   English

ASP.NET MVC C#PayPal Rest API-UNAUTHORIZED_PAYMENT

[英]ASP.NET MVC C# PayPal Rest API - UNAUTHORIZED_PAYMENT

I'm trying to integrate the paypal rest api to my web application. 我正在尝试将Paypal Rest API集成到我的Web应用程序中。 After digging through all available sources I'm stuck. 在浏览了所有可用资源之后,我陷入了困境。

I'm using the paypal rest api example from here: GitHub-PayPal-DotNet-Sample 我在这里使用Paypal Rest API示例: GitHub-PayPal-DotNet-Sample

I updated the nuget to the latest sdk version and replaced the cliendId and secret with my own live keys. 我将nuget更新为最新的sdk版本,并用自己的活动密钥替换了cliendId和secret。

Now my problem is, always I choose "credit_card" I get an 401 error response: 现在我的问题是,总是选择“ credit_card”,得到401错误响应:

{ "name": "UNAUTHORIZED_PAYMENT", "message": "Unauthorized payment", "information_link": " https://developer.paypal.com/webapps/developer/docs/api/#UNAUTHORIZED_PAYMENT ", "debug_id": "1d25a990be5db" } {“名称”:“ UNAUTHORIZED_PAYMENT”,“消息”:“未经授权的付款”,“ information_link”:“ https://developer.paypal.com/webapps/developer/docs/api/#UNAUTHORIZED_PAYMENT ”,“ debug_id”:“ 1d25a990be5db“}

I set the currency to "CHF" (application runs in Switzerland) and the amount to "0.05" for testing purposes. 我将货币设置为“ CHF”(应用程序在瑞士运行),并将金额设置为“ 0.05”以进行测试。 I also retrieve a valid access token! 我还检索了有效的访问令牌!

Tried various credit cards some belongs to my merchant account some not, still the same error. 尝试过各种信用卡,有些属于我的商人帐户,有些不属于我,仍然是同样的错误。

With the option "paypal" it seems to work, but I want to offer credit cards directly within the application. 使用“贝宝”选项似乎可行,但是我想直接在应用程序中提供信用卡。

Is something not available in Switzerland? 瑞士没有什么东西吗? Any suggestions for this problem? 对这个问题有什么建议吗? Did I overlook something? 我有事吗

Thanks in advance! 提前致谢!

Sample Code: 样例代码:

        Payment pay = null;

        Amount amount = new Amount();
        amount.currency = "CHF";
        amount.total = "0.05";

        Transaction transaction = new Transaction();
        transaction.amount = amount;
        transaction.description = orderDescription;

        List<Transaction> transactions = new List<Transaction>();
        transactions.Add(transaction);

        FundingInstrument fundingInstrument = new FundingInstrument();
        CreditCardToken creditCardToken = new CreditCardToken();
        creditCardToken.credit_card_id = GetSignedInUserCreditCardID(email);
        fundingInstrument.credit_card_token = creditCardToken;

        List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
        fundingInstrumentList.Add(fundingInstrument);

        Payer payer = new Payer();
        payer.funding_instruments = fundingInstrumentList;
        payer.payment_method = paymntMethod.ToString(); //credit_card

        Payment pyment = new Payment();
        pyment.intent = "sale";
        pyment.payer = payer;
        pyment.transactions = transactions;

        pay = pyment.Create(AccessToken);

        return pay;

按照这种方式,仅美国,英国支持直接卡付款(请参阅页面以了解英国的更多要求)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM