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

时间:2015-12-07 13:22:02

标签: c# .net api paypal

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

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

        // 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,则其工作正常。如果我发送credit_card,我会收到错误500.

debug_id:30e0f1bb08d3f

配置:直播

1 个答案:

答案 0 :(得分:0)

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