修补程序请求更新付款时收到格式错误的错误

时间:2017-11-24 05:58:59

标签: python-2.7 api paypal

我想减少付款的部分订单。这就是为什么我使用PayPal python API的替换方法,允许在创建支付对象后更新或添加数据。

错误:

{u'message': u'Incoming JSON request does not map to API request', u'debug_id': u'd57742e9d3b03', u'name': u'MALFORMED_REQUEST', u'information_link': u'https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST'}

代码:

创建付款:

我在创建付款对象时添加了两个产品。

payment = Payment({
    "intent": "sale",

    "payer": {
        "payment_method": "paypal"},

    "redirect_urls": {
        "return_url": "http://localhost:3000/payment/execute",
        "cancel_url": "http://localhost:3000/"},

    "transactions": [{

        "item_list": {
            "items": [{
                "name": "Ice-cream",
                "sku": "I10001",
                "price": "50.00",
                "currency": "USD",
                "quantity": 12},
                {
                "name": "Ice-cream12",
                "sku": "I100012",
                "price": "60.00",
                "currency": "USD",
                "quantity": 12}
                      ]},

        "amount": {
            "total": "1320.00",
            "currency": "USD"},
        "description": "This is the payment transaction description."}]})
payment.create()

更新付款:

update_payment_json = [

                {
                "op":"replace",
                "path":"/transactions/0/item_list",
                "values":{"items":[{
                      "name": "Ice-cream",
                        "sku": "I10001",
                        "price": "50.00",
                        "currency": "USD",
                        "quantity": 12,
                      },]}

            },
                {
                    "op":"replace",
                     "path":"/transactions/0/amount",
                     "value":
                         {
                        "total": "600.00",
                        "currency": "USD",
                        "details":{

                                    "subtotal": "600.00",
                                   "shipping":"0.0",

                            }},

                },
            ]
payment.replace(update_payment_json)

0 个答案:

没有答案