【问题标题】:paypal rest api update payment's itempaypal rest api 更新付款的项目
【发布时间】: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”吧
非常感谢!

【问题讨论】:

    标签: paypal-rest-sdk


    【解决方案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);
    
        ...
    } ....
    

    【讨论】:

      猜你喜欢
      • 2017-01-21
      • 2017-07-13
      • 2013-08-29
      • 2017-05-13
      • 2016-05-20
      • 2014-01-05
      • 2016-12-17
      • 2013-05-29
      • 2020-07-11
      相关资源
      最近更新 更多