c# - 错误 : PayPal: Prop is required: payment

标签 c# model-view-controller paypal

我遇到了一个我不完全理解的问题。遵循来自 PayPal 开发者网站的演示:https://developer.paypal.com/demo/checkout/#/pattern/server

我遇到了这篇文章标题中的错误。

下面是一些代码示例 客户端: 付款:功能(){

        // Make a call to the merchant server to set up the payment

        return paypal.request.post('My/api/call').then(function (res) {

            return res.token;
        });
    },

服务器端(我的/api/调用)

var createdPayment = payment.Create(apiContext);

return createdPayment;

我正在使用 PayPal-NET-SDK 创建这些对象并将它们返回到 PayPal 似乎可以接受的对象,直到返回响应为止。我认为来自 PayPal 的演示代码暗示返回了一个支付对象。这就是我从服务器返回的内容(PayPal 从 api 调用中给它一个 ID、一个 token 等),授予 token 的属性名称是不同的。有没有人知道可能发生的事情?

谢谢

编辑:根据请求,这里是 payment.Create 方法

/// <summary>
    /// Creates and processes a payment. In the JSON request body, include a `payment` object with the intent, payer, and transactions. For PayPal payments, include redirect URLs in the `payment` object.
    /// </summary>
    /// <param name="apiContext">APIContext used for the API call.</param>
    /// <returns>Payment</returns>
    public Payment Create(APIContext apiContext)
    {
        return Payment.Create(apiContext, this);
    }

    /// <summary>
    /// Creates (and processes) a new Payment Resource.
    /// </summary>
    /// <param name="apiContext">APIContext used for the API call.</param>
    /// <param name="payment">Payment object to be used in creating the PayPal resource.</param>
    /// <returns>Payment</returns>
    public static Payment Create(APIContext apiContext, Payment payment)
    {
        // Validate the arguments to be used in the request
        ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

        // Configure and send the request
        var resourcePath = "v1/payments/payment";
        var resource = PayPalResource.ConfigureAndExecute<Payment>(apiContext, HttpMethod.POST, resourcePath, payment.ConvertToJson());
        resource.token = resource.GetTokenFromApprovalUrl();
        return resource;
    }

最佳答案

您需要以字符串的形式返回 EC-XXXXXXX token 或 PAY-XXXXXX id,而不是整个支付对象。

关于c# - 错误 : PayPal: Prop is required: payment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43683788/

相关文章:

c# - 使用 LINQ 分组数据不起作用

asp.net-mvc - 在 View 中生成列表并将其传递给 Controller

java - servlet 不显示连接两个表的所有匹配结果

php - paypal IPN 有效,但停留在 paypal 的感谢页面!

php - 如何获取业务电子邮件 ID 以响应 paypal api

c# - 从字符串中删除字符

c# - 尝试使用 Expression<Func<..>> 从方法调用 Any() 时出现类型错误

paypal - 在 IPN 争议通知中识别用户或其订单

c# - 如何使用 C# 和 Office Interop 获取 Office 文档的完整文件名?

javascript - 简单的backbone.js模型连接