简体   繁体   English

错误:PayPal:必须提供支持:付款

[英]ERROR: PayPal: Prop is required: payment

I am running into an issue that I do not completely understand. 我遇到了一个我不完全理解的问题。 Following this demo from the PayPal developer site: https://developer.paypal.com/demo/checkout/#/pattern/server 在PayPal开发人员网站上进行以下演示: https : //developer.paypal.com/demo/checkout/#/pattern/server

I am running into the error in the title of this post. 我在这篇文章的标题中遇到了错误。

Here are some code samples Client side: payment: function () { 以下是客户端的一些代码示例:付款:function(){

        // 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;
        });
    },

Server side (my/api/call) 服务器端(我/ api /通话)

var createdPayment = payment.Create(apiContext);

return createdPayment;

I am using the PayPal-NET-SDK to create these objects and return them to which PayPal seems to be OK with until the response is returned. 我正在使用PayPal-NET-SDK创建这些对象,并将它们返回到PayPal似乎还可以的状态,直到返回响应为止。 The demo code from PayPal, I think, implies that a payment object is returned. 我认为,贝宝(PayPal)的演示代码暗示返回了付款对象。 Which is what I am returning from the server (PayPal gives it an ID, a token, etc from the api call), granted the property name of the token is different. 这是我从服务器返回的结果(PayPal从api调用中为其提供了ID,令牌等),但授予的令牌的属性名称是不同的。 Does anyone have any insight into what may be going on? 是否有人对可能发生的事情有任何见解?

Thanks 谢谢

EDIT: Asa per request here is the payment.Create method 编辑:Asa每个请求在这里是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令牌或PAY-XXXXXX id,而不是整个支付对象。

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

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