2016-06-30 117 views
1

我使用paypal rest api付款資源更新付款金額和項目信息;我只是想改變物品的價格和稅收;和運費;但返回MALFORMED_REQUEST;讓我喝醉...paypal rest api更新付款項目

的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" 
 
     } 
 
    } 
 
    }

,並返回: { 「名」: 「MALFORMED_REQUEST」, 「消息」: 「MALFORMED_REQUEST」,「information_link 「:」 https://developer.paypal.com/docs/api/#MALFORMED_REQUEST」, 「debug_id」: 「78c05f9b4f21」}

我想確保:
1,可以使用PayPal更新支付的項目信息 2,是路徑「/ transactions/0/item_list/items/0」right
非常感謝!

回答

0

我正在使用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); 

    ... 
} ....