paypal rest api 更新付款的项目
Posted
技术标签:
【中文标题】paypal rest api 更新付款的项目【英文标题】:paypal rest api update payment's item 【发布时间】:2016-11-01 23:59:33 【问题描述】:我使用 paypal rest api 付款资源来更新付款的金额和项目信息;我只想更改商品的价格和税金;和运费;但返回 MALFORMED_REQUEST;让我醉...
request_data 是:
"op": "replace",
"path": "/transactions/0/item_list/items/0",
"value":
"name": "hello",
"quantity": "2",
"price": "100",
"currency": "USD",
"tax": "12"
,
"op": "replace",
"path": "/transactions/0/amount",
"value":
"currency": "USD",
"total": "224",
"details":
"shipping": "12",
"subtotal": "200",
"tax": "12"
并返回: "name":"MALFORMED_REQUEST","message":"MALFORMED_REQUEST","information_link":"https://developer.paypal.com/docs/api/#MALFORMED_REQUEST","debug_id":"78c05f9b4f21"
我想确保: 1、可以用paypal更新付款的商品信息 2、是路径“/transactions/0/item_list/items/0”吧 非常感谢!
【问题讨论】:
【参考方案1】:我正在使用 PayPal Java SDK,并使用以下代码更新购物车商品和总价值。
APIContext context = new APIContext(clientId,clientSecret,environment);
List<Patch> patches = new ArrayList<Patch>();
Amount amount = new Amount();
amount.setCurrency("BRL");
amount.setTotal("100.00");
Patch patch1 = new Patch();
patch1.setOp("replace").setPath("/transactions/0/amount").setValue(amount);
patches.add(patch1);
ItemList items = getItens(order);
Patch patch2 = new Patch();
patch2.setOp("replace").setPath("/transactions/0/item_list").setValue(items);
patches.add(patch2);
try
Payment payment = Payment.get(context, id);
payment.update(context, patches);
...
....
【讨论】:
以上是关于paypal rest api 更新付款的项目的主要内容,如果未能解决你的问题,请参考以下文章