#pankaj-webhooks
1 messages ยท Page 1 of 1 (latest)
hi there! can you share more on what isn't working? Are you receiving an error message?
are you following the sample here for php : https://stripe.com/docs/webhooks/quickstart?
are you using a webhook endpoint defined in the Dashboard or via the API? Or are you using the Stripe CLI to test webhooks?
whsec_...
did you define your webhook endpoint via the Dashboard? I'll need to know the answer to this to be able to help you
No I did not set
what about the Stripe CLI - are you planning to use the Stripe CLI to test webhooks?
https://stripe.com/docs/stripe-cli
please don't share your code with the secret key
I was trying to get payment intent
ok
\Stripe\Stripe::setApiKey();
$payload = file_get_contents('php://input');
$event = null;
try {
$event = \Stripe\Event::constructFrom(
json_decode($payload, true)
);
\Drupal::logger('stripe_description')->warning('<pre><code>' . print_r($payload, TRUE) . '</code></pre>');
//\Drupal::logger->debug('<pre>@payload</pre>', ['@payload' => $payload]);
} catch(UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
exit();
}
// Handle the event
switch ($event->type) {
case 'payment_intent.succeeded':
$paymentIntent = $event->data->object; // contains a \Stripe\PaymentIntent
handlePaymentIntentSucceeded($paymentIntent);
\Drupal::logger('stripe_description')->notice("111");
break;
case 'payment_method.attached':
$paymentMethod = $event->data->object; // contains a \Stripe\PaymentMethod
handlePaymentMethodAttached($paymentMethod);
\Drupal::logger('stripe_description')->notice("222");
break;
// ... handle other event types
default:
echo 'Received unknown event type ' . $event->type;
\Drupal::logger('stripe_description')->notice("d");
}
This is the code that I was trying
If you define the webhook endpoint via the Dashboard, then you'll be able to find the webhook secret by clicking into the webhook endpoint in the Dashboard : https://dashboard.stripe.com/test/webhooks
If you're using the Stripe CLI to test webhooks, when you start listening/forwarding events, the webhook secret will be listed out in the terminal : https://stripe.com/docs/webhooks/test
No i dont have created endpoint
Endpoint URL
URL where I need to get the call?
like my webste page abc.com/endpoint
Alex??
it's up to you where you want to define the endpoint URL. You may want to take a look at this page for a basic understanding of webhooks: https://stripe.com/docs/webhooks?
if you've created it in the Dashboard, click into the endpoint, you should be able to see a section that looks like
click on Reveal and you'll be able to see the endpoint secret
are you following the sample here for php : https://stripe.com/docs/webhooks/quickstart?
I used quick start
are you following the sample here for php : https://stripe.com/docs/webhooks/quickstart?
if you're using that guide, it looks like you're planning to use the Stripe CLI - you'll see the webhook secret when you run stripe listen --forward-to localhost:4242/webhook
then you've created your webhook endpoint here https://dashboard.stripe.com/test/webhooks?
Can you share your account id so that I can take a closer look at your endpoint? You can find your account id by logging in to https://dashboard.stripe.com/settings/account. It'll be in the upper right hand corner and looks like acct_123
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
acct_102dHa2svt92FOo9
๐ stepping in and catching up
Ok I see you have https://dev-inscopixstore.pantheonsite.io/webhook setup, correct?
And you have taken its secret and use in your code?
which part isn't working? the $_SERVER['HTTP_STRIPE_SIGNATURE'];?
๐ Are you sure $_SERVER has other values?
I doubt that maybe your framework or your web hosting service stripped out HTTP_STRIPE_SIGNATURE
ok LMC
Is it required to use libratry
Yes but maybe the library striped out some header