gpt4 book ai didi

.net - 远程服务器返回错误 : (401) Unauthorized with paypal

转载 作者:太空宇宙 更新时间:2023-11-03 15:44:29 24 4
gpt4 key购买 nike

场景

这里我用paypal用信用卡直接支付,我在paypal账户中存储CC详细信息,paypal返回信用卡 token ,我保存这个 token 我的数据库中的数字进行直接付款,并且通过使用此 token ,我可以使用沙盒帐户进行直接付款但是当我对真实帐户执行相同操作时,会出现如下错误。

The remote server returned an error: (401) Unauthorized.

这是我的错误响应:

{"name":"UNAUTHORIZED_PAYMENT","message":"Unauthorized payment.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#UNAUTHORIZED_PAYMENT","debug_id":"be6ad614a3843"}

这是代码

try
{
Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
sdkConfig.Add("mode", "live");
string accessToken = new OAuthTokenCredential(PayPalConfig.PaypalClientId, PayPalConfig.PaypalClientSecret, sdkConfig).GetAccessToken();
APIContext apiContext = new APIContext(accessToken);
apiContext.Config = sdkConfig;

// Items within a transaction.
var item = new Item()
{
name = "Item Name",
currency = "USD",
price = "1",
quantity = "8",
sku = "sku"
};

// A resource representing a credit card that can be used to fund a payment.
var credCardToken = new CreditCardToken()
{
credit_card_id = "Here CC Token Number"
};

var amnt = new Amount()
{
currency = "USD",
total = "10",
details = new Details()
{
shipping = "1",
subtotal = "8",
tax = "1"
}
};

// A transaction defines the contract of a
// payment - what is the payment for and who
// is fulfilling it.
var tran = new Transaction()
{
amount = amnt,
description = "This is the payment transaction description.",
item_list = new ItemList() { items = new List<Item>() { item } }
};

// A resource representing a Payer's funding instrument. For stored credit card payments, set the CreditCardToken field on this object.
var fundInstrument = new FundingInstrument()
{
credit_card_token = credCardToken
};

// A Payment Resource; create one using the above types and intent as 'sale'
var pymnt = new Payment()
{
intent = "sale",
payer = new Payer()
{
funding_instruments = new List<FundingInstrument>() { fundInstrument },
payment_method = "credit_card"
},
transactions = new List<Transaction>() { tran }
};

// Create a payment using a valid APIContext
var createdPayment = pymnt.Create(apiContext);
}
catch (Exception ex)
{
throw;
}

如果有人对这个问题有任何想法,请告诉我。或者建议我哪里做错了。

最佳答案

很高兴在一个月后解决了这个问题,

原因: 我的代码方面没有问题,一切都正确,但 Paypal 方面有问题。在“我的帐户”中,我无法更改Direct credit cards 权限选项“启用绿色勾号”。但经过与 Paypal 团队的长期讨论,现在已经解决了。您可以在下图中看到。希望这个答案也能帮助其他人。 enter image description here

关于.net - 远程服务器返回错误 : (401) Unauthorized with paypal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38891337/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com