#Gustavo-Webhooks

1 messages · Page 1 of 1 (latest)

vague marlin
#

Hi there! How are you testing the endpoint?

#

Are you using the CLI?

latent furnace
vague marlin
#

Ah okay so you have an https endpoint set up

#

Can you share your full webhook code?

latent furnace
#

yes

#

wait

#

<?php
require_once 'vendor/autoload.php';
header('Content-Type: application/json');

$mk = new MemberKit\Client('cg1bw8WaUh64oN9E7i9yo5Py');

$payload = file_get_contents('php://input');
$endpoint_secret = 'whsec_ABjfYAvIDT2eQ79aJDlrJF855mKsSyCE';
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];

try {
$event = \Stripe\Webhook::constructEvent(
$payload, $sig_header, $endpoint_secret
);
} catch(\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
echo $e;
exit();
} catch(\Stripe\Exception\SignatureVerificationException $e) {
// Invalid signature
http_response_code(500);
echo $e;
exit();
}

$payload = json_decode($payload);

$customer = $payload->data->object->charges->data[0]->billing_details;
$test = $mk->newUser($customer->name, $customer->email, $status='active', $blocked=false, $classroom_ids=array(78126), $unlimited=false, $membership_level_id=null, $expires_at=null);
echo json_encode(['status' => 'success']);

vague marlin
#

Hmmm that all looks fine to me.

#

Can you share an Event ID that you tested with?

latent furnace
#

yes

#

wait

#

we_1L6FO3AwxDm9Wsfcxw93B7XL

#

this ?

vague marlin
#

That works, one moment.

#

Also I recommend editing your message above

#

And removing your endpoint secret

#

As that is sensitive data

#

And this is a public server

latent furnace
#

i remove my endpoint and create new ?

#

evt_3L6cT0AwxDm9Wsfc065f9gkQ

#

last event about webhooks

vague marlin
#

I'd recommend rolling your webhook signing secret for the endpoint

#

Since someone could now have access to the secret you provided

latent furnace
#

understand

#

creating new

vague marlin
#

Can you comment out your header('Content-Type: application/json'); from your code and retry?

latent furnace
#

wiat

#

yes

#

wait

#

evt_3L6fGdAwxDm9Wsfc1PNQhsH6

#

errors

#

erros 550

#

500

vague marlin
#

Hmmm okay and I assume you updated the endpoint secret to the new secret?

latent furnace
#

yes

vague marlin
#

Let's make sure your server is getting hit at all.... can you add an error_log or an echo before the try/catch for the $payload

latent furnace
#

ok

#

wiat

#

why? C:\Users\Gustavo Santos\Downloads\stripe>stripe listen --print-secret
whsec_c63840f68d4313d9d1a9b8014b0c2bc843b4a08e95b53b13492a36fd4638eea4

cmd, why another information? this is test? having test for production ?

vague marlin
#

?

#

Are you using the CLI?

#

Doesn't look like you are to me... but if you are using stripe listen then that indicates the CLI

#

Which gives you its own secret

latent furnace
#

no, i'm simulate poducition.. without cli...

because, stripe cli works it

#

only simulate the process generate errors

#

error_log, dont generate log

#

i'm using docker, have problem ?

vague marlin
#

Yeah if you don't see the payload coming through at all then it doesn't seem to be a webhook signature issue

#

It sounds like the payload isn't hitting your server endpoint

latent furnace
#

only https?

vague marlin
#

Yes https is required

#

You can only test locally if you forward from the CLI

latent furnace
#

wait

latent furnace
#

wait pls

#

hey brow

#

i find errors

haughty aspen
#

Hi 👋 I'm stepping in as my teammate needed to step away, can you share details about the errors?