我尝试使用PayPal REST API而不是PayPal Classic API,但似乎REST API缺少Classic API具有的两个功能:
所以我的问题是:是否可以在不使用REST API查询送货地址的情况下立即执行付款?我是否必须回到Classic API?
我在这里提供了一些关于我如何使用PayPal REST API的更多信息。 我正在使用PayPal REST Java SDK。 这是一个示例请求:
{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"currency": "USD",
"total": "5",
"details": {
"subtotal": "5"
}
},
"description": "This is the payment transaction description.",
"item_list": {
"items": [
{
"quantity": "1",
"name": "Item 1",
"price": "5",
"currency": "USD"
}
]
}
}
],
"redirect_urls": {
"return_url": "http://XXX/handlePayment.jsp?guid\u003dXXX",
"cancel_url": "http://XXX/cancelPayment.jsp?guid\u003dXXX"
}
}
及其答复:
{
"id": "XXX",
"create_time": "2014-06-29T08:52:55Z",
"update_time": "2014-06-29T08:52:55Z",
"state": "created",
"intent": "sale",
"payer": {
"payment_method": "paypal",
"payer_info": {
"shipping_address": {}
}
},
"transactions": [
{
"amount": {
"total": "5.00",
"currency": "USD",
"details": {
"subtotal": "5.00"
}
},
"description": "This is the payment transaction description.",
"item_list": {
"items": [
{
"name": "Item 1",
"price": "5.00",
"currency": "USD",
"quantity": "1"
}
]
}
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/XXX",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=XXX",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/XXX/execute",
"rel": "execute",
"method": "POST"
}
]
}
答案 0 :(得分:5)
在深入研究REST API时,我遇到了this
我相信这意味着您不必创建任何"个人资料"因此,可以将它们与付款电话一起传递......
按要求进一步解释:)
以下是使用快速结账的客户端JS方法传递PayPal体验参数以及特定付款调用的示例。
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '1.00', currency: 'USD' }
}
]
},
experience: {
input_fields: {
no_shipping: 1
}
}
});
},
希望这对你们有足够的意义! :)
答案 1 :(得分:3)
不幸的是,REST API仍然远远落后于它提供的功能的Classic API。你提到的这些功能是我看到的相当多的东西,据我所知,它们尚未提供REST服务。
我个人已经坚持使用Classic,因为他们提供了所有内容,我真的认为自己使用REST没有任何优势。如果您正在使用PHP(我一直这样做),您可能会对我的class library for PayPal感兴趣。它使您可以非常快速,轻松地完成所有Classic API调用,它是available on Packagist,因此您可以轻松地使用Composer。
答案 2 :(得分:2)
现在,REST API支持Payment Experience APIs无法发货。
您需要创建Web体验配置文件并将no_shipping作为输入字段提供。然后在创建付款时使用个人资料ID。
每次都不需要重新创建配置文件ID。
答案 3 :(得分:2)
感谢这篇文章暂时没有任何活动但是...
我遇到了完全相同的问题,并将此帖作为我自己问题的起点:
paypal api: take immediate payment without a shipping address
这需要一些试验和错误,但我可以创建一个关闭的网页个人资料,其中'no_shipping'设置为1,存储它创建的ID,然后将其传入以后付款,不需要运费地址。
仍然没有弄清楚如何摆脱'你差不多完成了。您将在xxx上确认付款。'但是我的付款流程比以前好得多!
希望这可以帮助那里的人,因为这个没有运输问题是许多人似乎用paypal api打... ...
答案 4 :(得分:0)
对于Paypal上的'立即付款'而不是'继续',我在审批网址中使用了一个特殊的参数:
$approvalUrl = $payment->getApprovalLink().'&useraction=commit';
结果:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN&useraction=commit
答案 5 :(得分:0)
我尝试使用API的“体验”部分,除了仍然无法强制执行区域设置代码外,还可以禁用送货并直接进行结算:
payment: {
transactions: [{
invoice_number: document.getElementById("ReqTxt").value,
amount: {
total: document.getElementById("InvoiceAmt").innerText,
currency: document.getElementById("Currency").innerText
}
}]
},
experience: {
input_fields: {
no_shipping: 1
},
flow_config: {
landing_page_type:'billing'
}
}
you can also see this page。也可以在flow_config
部分中设置用户操作