title: Unable to store stripe webhook data in mysql database
body: <p>I have set webhook in my <code>stripe</code> account and while doing test webhook from stripe dashboard, I am getting success result from the stripe. I can see the response in preview.</p>
  
  <p>But while doing that thing from the browser and hitting the same webhook url, I am getting nothing in my response .</p>
  
  <p>Here is the code that I am using to make it work.</p>
  
  <p>=======================================</p>
  
  <pre><code>include('config.php');
  
  function searchArrayValueByKey(array $array, $search) 
  {
      foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key =&gt; $value) 
      {
          if ($search === $key)
          return $value;
      }
      return false;
  }
  
  require_once('vendor/autoload.php');
  
  \Stripe\Stripe::setApiKey("Stripe Key");
  
  // This function is leveraged to search through the JSON for specific values
  
  $input = @file_get_contents("php://input");         
  // this gets the POST data provided when the webhook pings this page
  $event_json = json_decode($input, TRUE);    
  // decode the JSON, and TRUE turns it into a multidimensional array
  
  if(isset($type))
  {
      $type = searchArrayValueByKey($event_json, 'customer.subscription.updated'); 
  }
  else
  {
      $type = "";
  }
  // Check the type of event sent from Stripe.com - example "charge.succeeded"
  
  switch ($type) 
  {                                   
      // depending on the event fired by Stripe, do something different. 
      case "account.updated":
          // do something
          break;
      case "balance.available":
          // do something
          break;
      case "charge.captured":
          // do something
          break;
      case "charge.refunded":
          // do something
          break;
      case "charge.succeeded":
          // do something
          break;
      case "charge.updated":
          // do something
          break;
      case "charge.failed":
          // do something
          break;
      case "charge.dispute.created":
          // do something
          break;
      case "charge.dispute.updated":
          // do something
          break;
      case "charge.dispute.closed":
          // do something
          break;
      case "coupon.created":
          // do something
          break;
      case "coupon.deleted":
          // do something
          break;
      case "customer.created":
          // do something
          break;
      case "customer.updated":
          // do something
          break;
      case "customer.deleted":
          // do something
          break;
      case "customer.card.created":
          // do something
          break;
      case "customer.card.updated":
          // do something
          break;
      case "customer.card.deleted":
          // do something
          break;
      case "customer.discount.created":
          // do something
          break;
      case "customer.discount.updated":
          // do something
          break;
      case "customer.discount.deleted":
          // do something
          break;
      case "customer.subscription.created":
          // do something
          break;
      case "customer.subscription.updated":
  
          $id = searchArrayValueByKey($event_json, 'id'); 
          $customer_id = searchArrayValueByKey($event_json, 'customer'); 
          $created = searchArrayValueByKey($event_json, 'created'); 
          $subscription = searchArrayValueByKey($event_json, 'subscription'); 
          $period_start = searchArrayValueByKey($event_json, 'period_start'); 
          $period_end = searchArrayValueByKey($event_json, 'period_end'); 
  
          $insert_into = mysqli_query($conn,"insert into ext_payment_data set
                                          subscription = '".$subscription."',
                                          add_date = '".$created."',
                                          subscr_id = '".$subscription."',
                                          subscribe_from_date = '".$period_start."',
                                          subscribe_to_date = '".$period_end."',
                                          response = '".json_encode($event_json)."'
              ");     
  
          break;
      case "customer.subscription.deleted":
          // do something
          break;
      case "customer.subscription.trial_will_end":
          // do something
          break;
      case "invoice.created":
          // do something
          break;
      case "invoice.updated":
          // do something
          break;
      case "invoice.payment_succeeded":
          // do something
          break;
      case "invoice.payment_failed":
          // do something
          break;
      case "invoiceitem.created":
          // do something
          break;
      case "invoiceitem.updated":
          // do something
          break;
      case "invoiceitem.deleted":
          // do something
          break;
      case "plan.created":
          // do something
          break;
      case "plan.updated":
          // do something
          break;
      case "plan.deleted":
          // do something
          break;
      case "transfer.created":
          // do something
          break;
      case "transfer.updated":
          // do something
          break;
      case "transfer.paid":
          // do something
          break;
      case "transfer.failed":
          // do something
          break;
      default:
          echo "Error";
  
  }
  
  $myfile = fopen("auto_response.txt", "a+") or die("Unable to open file!");
  file_put_contents('auto_response.txt', print_r($event_json,true),FILE_APPEND | LOCK_EX);
  fclose($myfile);
  </code></pre>
  
  <p>==================</p>
  
  <p>Here while writing the response in <code>auto_response.txt</code> file, I am able to store that data in the file, but while storing that data in database I am getting nothing.</p>
  
  <p>So is any one have any solution for that, as I am not able to store the stripe response in my mysql database.</p>