Commerce Stripe webhook I use the Drupal Commerce Stripe module to create subscription charges in a Drupal web, through the Stripe platform. Everything seems to work well, the clients are created, the charges are produced and appear in Stripe's Dashboard .... I also have a webhook that seems to work too. The problem I have is that I need to implement within the webhook itself the ability to complete certain fields with the response that Stripe sends to that webhook. These data must complete the profile of the user who made the payment. Any idea what this would be like?

I'm talking about Drupal 7

This is my webhook

&lt;?php


require_once('vendor/autoload.php');
\Stripe\Stripe::setApiKey("sk_test_*************");


$input = @file_get_contents("php://input");
$event_json = json_decode($input);


$event_id = $event_json -&gt;id;
$event_type = $event_json -&gt; type;
$customer_email = $event_json -&gt; receipt_email;

if ($event_type == "charge.succeeded") {
  $msg = "test webhook";
  mail($customer_email, "Test suscrip", $msg);

*/*Here I would like to be able to send certain data of the json object to certain fields of the user profile*/*

}


http_response_code(200);  





?&gt;
It sounds like you want to load the user object from the email address, set some field values, and save it again.

In code that would look something like this:

if ( ($account = user_load_by_mail($customer_email) ) {
  $account-&gt;field_foo[LANGUAGE_NONE][0]['value'] = $event_json-&gt;foo;
  $account-&gt;field_bar[LANGUAGE_NONE][0]['value'] = $event_json-&gt;bar;

  user_save($account);
}