PayPal REST API获取总金额

时间:2015-08-30 14:15:41

标签: php json paypal

我正在使用PayPal rest-api-sdk-php最新版本。在创建付款和执行付款以及获取所有相关数据方面,一切都运行良好,但已决定我希望通过paypal支付的总金额。它返回一个JSON对象,例如

"transactions": [
    {
        "amount": {
            "total": "20.00",
            "currency": "GBP",
            "details": {
                "subtotal": "17.50",
                "tax": "1.30",
                "shipping": "1.20"
            }
        },
        "description": "Payment description",
        "invoice_number": "55e30dbd55cea",
        "item_list": {
            "items": [
                {
                    "name": "Ground Coffee 40 oz",
                    "price": "7.50",
                    "currency": "GBP",
                    "quantity": "1",
                    "description": "Ground Coffee 40 oz",
                    "tax": "0.30"
                },
                {
                    "name": "Granola bars",
                    "price": "2.00",
                    "currency": "USD",
                    "quantity": "5",
                    "description": "Granola Bars with Peanuts",
                    "tax": "0.20"
                }
            ]
        },
    }
],

我尝试过调用$ payment-> transactions-> amount-> total但收到错误。只是想知道是否有人可以解决问题。感谢

1 个答案:

答案 0 :(得分:6)

"记录"是一个数组,所以你需要遍历它。 如果您想要第一笔总金额,请尝试$ payment-> transactions [0] - > amount-> total;