我遇到了一个我不完全理解的问题。以下来自PayPal开发者网站的演示:https://developer.paypal.com/demo/checkout/#/pattern/server
我遇到了这篇文章标题中的错误。
以下是一些代码示例 客户端: 付款: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;
});
},
服务器端(my / api / call)
var createdPayment = payment.Create(apiContext);
return createdPayment;
我正在使用PayPal-NET-SDK创建这些对象,并将其返回到PayPal似乎没问题,直到返回响应为止。我认为,PayPal的演示代码意味着会返回付款对象。这是我从服务器返回的内容(PayPal从api调用给它一个ID,一个令牌等),授予令牌的属性名称是不同的。有没有人对可能发生的事情有任何见解?
由于
编辑:这里的每个请求是pay.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;
}
答案 0 :(得分:1)
您需要将EC-XXXXXXX令牌或PAY-XXXXXX ID作为字符串返回,而不是整个付款对象。