2016-06-30 10 views
1

ich benutze paypal rest api zahlungsressource, um die zahl und die artikelinformation einer zahlung zu aktualisieren; ich will nur den Preis und die Steuer des Einzelteils ändern; und Versandkostenmenge; aber gib MALFORMED_REQUEST zurück; machen mich betrunken ...paypal rest api update zahlungsgegenstand

die request_data ist:

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

und zurück: { "name": "MALFORMED_REQUEST", "message": "MALFORMED_REQUEST", "information_link ":" https://developer.paypal.com/docs/api/#MALFORMED_REQUEST“, "debug_id": "78c05f9b4f21"}

i sicherstellen möchten, dass:
1 kann mit paypal 01.238.007 Zahlung Stück Info aktualisieren 2, ist der Pfad "/ transactions/0/item_list/items/0" rechts
vielen Dank!

Antwort

0

Ich benutze PayPal Java SDK und habe den unten stehenden Code verwendet, um die Warenkorb-Artikel und den Gesamtwert zu aktualisieren.

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); 

    ... 
} ....