I have a webhook from fastSpring.

The webhook sends something like below and I want to know how can I create a webhook listener to use the inflammation passed by the webhook?

How can I create the listener to capture below information please?

{
   "order":"yzaP3EQAQtCOBLhYP2ZN-Q",
   "id":"yzaP3EQAQtCOBLhYP2ZN-Q",
   "reference":"MyDomain190418-3737-54184",
   "buyerReference":null,
   "completed":true,
   "changed":1555598658633,
   "changedValue":1555598658633,
   "changedInSeconds":1555598658,
   "changedDisplay":"4/18/19",
   "language":"en",
   "live":false,
   "currency":"USD",
   "payoutCurrency":"USD",
   "invoiceUrl":"https://MyDomain.test.onfastspring.com/account/order/MyDomain190418-3737-54184/invoice",
   "account":{
      "id":"qjY3pex6TH6rj6A2f71vVg",
      "account":"qjY3pex6TH6rj6A2f71vVg",
      "contact":{
         "first":"Jassim",
         "last":"Al Rahma",
         "email":"myemail@gmail.com",
         "company":null,
         "phone":"123456789"
      },
      "language":"en",
      "country":"AE",
      "lookup":{
         "global":"XNpsaeO3QLO906bY9HcusA"
      },
      "url":"https://MyDomain.test.onfastspring.com/account"
   },
   "total":29.99,
   "totalDisplay":"USD 29.99",
   "totalInPayoutCurrency":29.99,
   "totalInPayoutCurrencyDisplay":"USD 29.99",
   "tax":0.0,
   "taxDisplay":"USD 0.00",
   "taxInPayoutCurrency":0.0,
   "taxInPayoutCurrencyDisplay":"USD 0.00",
   "subtotal":29.99,
   "subtotalDisplay":"USD 29.99",
   "subtotalInPayoutCurrency":29.99,
   "subtotalInPayoutCurrencyDisplay":"USD 29.99",
   "discount":0.0,
   "discountDisplay":"USD 0.00",
   "discountInPayoutCurrency":0.0,
   "discountInPayoutCurrencyDisplay":"USD 0.00",
   "discountWithTax":0.0,
   "discountWithTaxDisplay":"USD 0.00",
   "discountWithTaxInPayoutCurrency":0.0,
   "discountWithTaxInPayoutCurrencyDisplay":"USD 0.00",
   "billDescriptor":"FS* fsprg.com",
   "payment":{
      "type":"test",
      "cardEnding":"4242"
   },
   "customer":{
      "first":"Jassim",
      "last":"Al Rahma",
      "email":"myemail@gmail.com",
      "company":null,
      "phone":"123456789"
   },
   "address":{
      "country":"AE",
      "display":"AE"
   },
   "recipients":[
      {
         "recipient":{
            "first":"Jassim",
            "last":"Al Rahma",
            "email":"myemail@gmail.com",
            "company":null,
            "phone":"123456789",
            "account":{
               "id":"qjY3pex6TH6rj6A2f71vVg",
               "account":"qjY3pex6TH6rj6A2f71vVg",
               "contact":{
                  "first":"Jassim",
                  "last":"Al Rahma",
                  "email":"myemail@gmail.com",
                  "company":null,
                  "phone":"123456789"
               },
               "language":"en",
               "country":"AE",
               "lookup":{
                  "global":"XNpsaeO3QLO906bY9HcusA"
               },
               "url":"https://MyDomain.test.onfastspring.com/account"
            },
            "address":{
               "country":"AE",
               "display":"AE"
            }
         }
      }
   ],
   "notes":[

   ],
   "items":[
      {
         "product":"featured-ad",
         "quantity":1,
         "display":"Featured Ad",
         "sku":null,
         "subtotal":29.99,
         "subtotalDisplay":"USD 29.99",
         "subtotalInPayoutCurrency":29.99,
         "subtotalInPayoutCurrencyDisplay":"USD 29.99",
         "discount":0.0,
         "discountDisplay":"USD 0.00",
         "discountInPayoutCurrency":0.0,
         "discountInPayoutCurrencyDisplay":"USD 0.00",
         "fulfillments":{

         }
      }
   ]
}

That's JSON (JavaScript Object Notation).

You can turn this into a PHP data structure (in this case a StdClass object) by using json_decode().

    jrahma "...the inflammation passed by the webhook..."

    This made my day. (Emphasis added by me.) 🙂

    NogDog jrahma "...the inflammation passed by the webhook..."

    This made my day. (Emphasis added by me.) 🙂

    Sounds like a case of unsanitised inputs. 🙂

      Write a Reply...