【发布时间】:2018-05-24 07:28:24
【问题描述】:
我想知道如何将发货信息发送到 Paypal,以便当用户被重定向到 Paypal 进行付款时,用户不必再次填写发货信息。用户已经填写了运输信息,数据存储在我的数据库中。问题是存储在数据库中的运输信息很可能与下订单的人的地址不同。用户很可能会使用另一个送货地址,而不是他们自己的。现在我可以通过这种方式正常操作,但我在想:如果我在 Paypal 的记录中没有存储正确的送货地址,客户很容易说我从未运送过他们的产品并要求退款。在这一点上,我只会在我的数据库中存储地址的跟踪号,而不是在 Paypal 的记录中,从而使我很容易受到这类 paypal 诈骗的攻击。如果我错了任何人,请纠正我。
以下是 Paypals 示例,说明在订购过程中向他们发送了哪些数据: https://github.com/paypal/PayPal-node-SDK/blob/master/samples/order/create.js
var create_payment_json = { "intent": "order", "payer": { "payment_method": "paypal" }, "redirect_urls": { "return_url": "http://return.url", "cancel_url": "http://cancel.url" }, "transactions": [{ "item_list": { "items": [{ "name": "item", "sku": "item", "price": "1.00", "currency": "USD", "quantity": 1 }] }, "amount": { "currency": "USD", "total": "1.00" }, "description": "This is the payment description." }] };我添加了一个运输对象,请参见下面的示例。
var create_payment_json = { "intent": "sale", "payer": { "payment_method": "paypal" }, "redirect_urls": { "return_url": "https://website.com/thankyou", "cancel_url": "https://website.com" }, "transactions": [{ "item_list": { "items": [{ "name": name, "sku": "item", "price": total_price, "currency": "USD", "quantity": 1 }] }, "shipping_address": { "recipient_name":recipient_name, "line1":line_1, "city": city, "state":state, "postal_code":zipcode, "country_code":"US" }, "amount": { "currency": "USD", "total": total_price }, "description": description }] };
但我收到此错误:
"response": {
"name":"MALFORMED REQUEST",
"message":"Incoming JSON request",
"information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST",
"debug_id":"cb2ecc213218b",
"httpStatusCode":400
},
"httpStatusCode":400
}
我不只是在装运物品。在成功的 Paypal 付款时,PayPal 返回一个包含送货地址对象的交易对象。我完全按照我看到的方式复制了它,假设我可以将运输信息发送到 Paypal。
在创建 Paypal 订单时,如何通过 REST API / node.js 将运输信息发送到 Paypal。请记住,当您在任何商店结账并登录 Paypal 时,收货地址将自动成为您在 Paypal 中设置的收货地址。如何通过 API 更改它?如果不能,商店通常如何处理这些情况?例如,给朋友买礼物。感谢您的宝贵时间,非常感谢您的帮助。
【问题讨论】:
标签: node.js paypal paypal-sandbox paypal-rest-sdk