Thread: Access json

    #1
  1. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,095
    Rep Power
    220

    Access json


    Hi how can I access "receipt_email" and amount?

    Thanks
    PHP Code:
    $event_json json_decode($input); 
    .

    Since I can get type like this
    PHP Code:
    echo $event_json->type
    i thought I could do
    PHP Code:
    $event_json->data->object->amount
    But apparently no.
    Code:
    {
      "created": 1326853478,
      "livemode": false,
      "id": "evt_00000000000000",
      "type": "charge.succeeded",
      "object": "event",
      "request": null,
      "pending_webhooks": 1,
      "api_version": "2017-06-05",
      "data": {
        "object": {
          "id": "ch_00000000000000",
          "object": "charge",
          "amount": 100,
          "amount_refunded": 0,
          "application": null,
          "application_fee": null,
          "balance_transaction": "txn_00000000000000",
          "captured": false,
          "created": 1499872980,
          "currency": "aud",
          "customer": null,
          "description": "My First Test Charge (created for API docs)",
          "destination": null,
          "dispute": null,
          "failure_code": null,
          "failure_message": null,
          "fraud_details": {
          },
          "invoice": null,
          "livemode": false,
          "metadata": {
          },
          "on_behalf_of": null,
          "order": null,
          "outcome": null,
          "paid": true,
          "receipt_email": null,
          "receipt_number": null,
          "refunded": false,
          "refunds": {
            "object": "list",
            "data": [
            ],
            "has_more": false,
            "total_count": 0,
            "url": "/v1/charges/ch_edfgy55/refunds"
          },
          "review": null,
          "shipping": null,
          "source": {
            "id": "card_00000000000000",
            "object": "card",
            "address_city": "",
            "address_country": "",
            "address_line1": "",
            "address_line1_check": null,
            "address_line2": null,
            "address_state": "",
            "address_zip": "",
            "address_zip_check": null,
            "brand": "MasterCard",
            "country": "US",
            "customer": null,
            "cvc_check": "pass",
            "dynamic_last4": null,
            "exp_month": 2,
            "exp_year": 2020,
            "fingerprint": "E5s8VoEfJxNES0TE",
            "funding": "credit",
            "last4": "4444",
            "metadata": {
            },
            "name": "ben jaza",
            "tokenization_method": null
          },
          "source_transfer": null,
          "statement_descriptor": null,
          "status": "succeeded",
          "transfer_group": null
        }
      }
    }
    Last edited by English Breakfast Tea; July 12th, 2017 at 10:42 AM.
  2. #2
  3. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,095
    Rep Power
    220
    Never mind issue solved thanks.
  4. #3
  5. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,177
    Rep Power
    9644
    Must have been some other issue because what you tried there should have worked.

IMN logo majestic logo threadwatch logo seochat tools logo