gpt4 book ai didi

c# - PayPal:创建付款时出现内部服务器错误

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

我正在使用 .NET 的 paypal API 来创建付款。

我在控制台应用程序中的确切代码:

        // Get a reference to the config
var config = ConfigManager.Instance.GetProperties();

// Use OAuthTokenCredential to request an access token from PayPal
var accessToken = new OAuthTokenCredential(config).GetAccessToken();

var apiContext = new APIContext(accessToken);

var p = new Payment();
p.intent = "sale";

p.payer = new Payer();
p.payer.payment_method = "credit_card"; //paypal or credit_card

var t = new Transaction();
t.amount = new Amount();
t.amount.currency = "GBP";
t.amount.total = "10.00";

t.amount.details = new Details();
t.amount.details.subtotal = "6.00";
t.amount.details.tax = "2.00";
t.amount.details.shipping = "2.00";

t.item_list = new ItemList();
t.item_list.items = new List<Item>();

var i1 = new Item();

i1.quantity = "1";
i1.name = "OBJETO TESTE";
i1.price = "6.00";
i1.currency = "GBP";

i1.sku = "TESTE";

t.item_list.items.Add(i1);

var a = new ShippingAddress();
a.recipient_name = "ADDRESS";
a.line1 = "LINE1";
a.line2 = "LINE2";
a.city = "LONDOM";
a.country_code = "GB";
a.postal_code = "NW19EA";

t.item_list.shipping_address = a;

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

p.redirect_urls = new RedirectUrls();
p.redirect_urls.cancel_url = string.Format("{0}{1}", "http://localhost:3161/", "Order/CancelPayment");
p.redirect_urls.return_url = string.Format("{0}{1}", "http://localhost:3161/", "Order/CompletePayment");

var payment = Payment.Create(apiContext, p);

如果我将付款方式更改为 paypal,它会起作用。如果我发送信用卡,我会收到错误 500。

调试编号:30e0f1bb08d3f

配置:直播

最佳答案

来自英国的商家无法使用 REST API 进行直接(信用卡)支付。您需要将您的帐户升级到 PRO 才能使用直接卡支付。只有美国商家可以在没有 PRO 帐户的情况下使用 REST API 进行直接卡支付。

关于c# - PayPal:创建付款时出现内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34134610/

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