gpt4 book ai didi

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

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

我遇到了一个我不完全理解的问题。遵循来自 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/

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