【问题标题】:PayPal REST API get total amountPayPal REST API 获取总金额
【发布时间】:2015-11-24 16:11:30
【问题描述】:

我正在使用最新版本的 PayPal rest-api-sdk-php。在创建付款和执行付款以及取回所有相关数据方面一切正常,但我决定我想要通过贝宝支付的总金额。它返回一个 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 但出现错误。只是想知道是否有人可以提供一些启示。谢谢

【问题讨论】:

    标签: php json paypal


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2015-02-05
      • 2018-10-31
      • 2016-03-26
      • 2016-08-22
      • 2013-10-11
      • 2021-01-20
      • 2013-01-08
      • 1970-01-01
      相关资源
      最近更新 更多