Buy Now
Sign in

Using JSON data in form

szabob , May 22 2019, 17:58
S
szabob 74
May 22 2019, 17:58 #387014
Hi Everyone,
I am using CF5. I have the following data in JSON. How can I access the "amount" value in line 21 from a form ?
S
szabob 74
May 22 2019, 18:10 #387015
{
"created": 000000000,
"livemode": false,
"id": "evt_00000000000000",
"type": "checkout.session.completed",
"object": "event",
"request": null,
"pending_webhooks": 1,
"api_version": "2019-03-14",
"data": {
"object": {
"id": "cs_00000000000000",
"object": "checkout.session",
"billing_address_collection": null,
"cancel_url": "https://example.com/cancel",
"client_reference_id": null,
"customer": null,
"customer_email": null,
"display_items": [
{
"amount": 1500,
"currency": "usd",
"custom": {
"description": "Comfortable cotton t-shirt",
"images": null,
"name": "T-shirt"
},
"quantity": 2,
"type": "custom"
}
],
"livemode": false,
"locale": null,
"payment_intent": "pi_00000000000000",
"payment_method_types": [
"card"
],
"subscription": null,
"success_url": "https://example.com/success"
}
}
}
S
szabob 74
May 23 2019, 16:31 #387024
Any clue? I am trying the following code but it does not work:
$event->data->object->display_items["amount"];
healyhatman 7
May 23 2019, 22:04 #387026
Need to use json_decode on display_items first
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
S
szabob 74
May 24 2019, 03:52 #387028
 Answer
Thanks, I figured it out. This worked:
$event->data->object["display_items"][0]["amount"]