#Fubaibai-webhook
1 messages ยท Page 1 of 1 (latest)
Hello, what origin are you limiting here?
I think the error is coming from us sending the event encoded as UTF-8 but your code is trying to decode it as something slightly different.
In my NGINX Server i received this :
54.187.216.72 - - [03/Oct/2022:13:13:18 +0000] "POST /api/webhook HTTP/1.1" 404 0 "-" "Stripe/1.0 (+https://stripe.com/docs/webhooks)" "-"
My backend is developped in Java Spring
And I've limit origin to my REST API to my domain
It's weird because, in my QLF env I've no problem about decoding WH event
I'll try to allow Stripe WH IPs that I found here
And I'll tell you if it's ok
Sounds good. Since it is a 404, it also sounds like your server might not have recognized the URL that Stripe was trying to reach
Can you reach the URL that Stripe is reaching out to if you make a POST to that same URL yourself?
Yea using postman I can reach the URL
But got 500 because I can't simulate Stripe headers using postman
So It's seems to be a pb with encoding/decoding
Hello ๐
Taking over as Pompey needs to step away
Yeah certainly looks like an issue with the encoding
Can you try changing the encoding config for your nginx server and see if it produces a different error?
or just a different behavior
Hello,
Thanks Pompey ๐
Ok I will try changing encoding conf
๐
Same error :/
@PostMapping(value = "/webhook")
public ResponseEntity<String> handleWebHook(@RequestBody final String json, HttpServletRequest request)
throws StripeException {
final String header = request.getHeader("Stripe-Signature");
Event event;
try {
event = Webhook.constructEvent(json, header, this.webHookService.getSecret());
} catch (SignatureVerificationException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
// Deserialize the nested object inside the event
final EventDataObjectDeserializer dataObjectDeserializer = event.getDataObjectDeserializer();
StripeObject stripeObject;
if (dataObjectDeserializer.getObject().isPresent()) {
stripeObject = dataObjectDeserializer.getObject().get();
} else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
// Handle the event
if (event.getType().equalsIgnoreCase("payment_intent.succeeded")) {
this.stripeService.handlePaymentIntentSucceeded((PaymentIntent) stripeObject);
return ResponseEntity.status(HttpStatus.OK).body("");
} else if (event.getType().equalsIgnoreCase("account.updated")) {
final ServiceResponse<Void> response = this.stripeService.handleAccountUpdated((Account) stripeObject);
if (response.getCode().equals(ECodeResponse.NOT_FOUND)) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("");
} else {
return ResponseEntity.status(HttpStatus.OK).body("");
}
} else if (event.getType().equalsIgnoreCase("checkout.session.completed")) {
this.stripeService.handleCheckoutCompleted((Session) stripeObject);
}
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
This is my webhook in my application, if it can help you
It doesn't look like its the code though.
As you mentioned earlier that you don't have such issue in your QLF env.
I'd recommend comparing the configuration for both and see if anything jumps out.
oh
I think I've found
In my Stripe dashboard I got this
If you read my code you will see return ResponseEntity.status(HttpStatus.NOT_FOUND).body("");
In fact, I got the answer from my server, it's normal, This event is triggered when I've configured my Stripe live account
But why Stripe is sending a webhook to my server ? I only want to use webhook for handling connected account update etc..
Ah I see.
But why Stripe is sending a webhook to my server ? I only want to use webhook for handling connected account update etc..
Sorry can you clarify what you mean here?
Are you receiving non-connect events on your connect webhook?
Stripe sent to my server webhook, the account updated event about my company informations updated on Stripe
Can you share your account ID?
Where can i have my account ID ?
If you go to your profile and scroll down
https://dashboard.stripe.com/settings/user
You should find it there. It looks like acct_xxxxxx
Fubaibai-webhook
acct_1LQ5vLKgYp82lmK8
It's weird, so I confirm my theory
Stripe sent my company account updated event to my webhook server
But not connected account
So it seems like your webhook endpoint is registered as account/direct type and NOT connect type webhook.
In order to listen to only connected account webhook events, you'd need a connect type webhook endpoint.
https://stripe.com/docs/connect/webhooks
Ooooooh
Ok so it's worked ! thx a lot
I've try a payment in production mode
and I don't know why but Stripe did not sent the payment_intent.succeeded event
Any idea ?
do you have a payment intent ID I can take a look at?
Damn I think I know why, It's because payment_intent.succeeded is for account webhook type
damn pretty sure that is the pb ๐
Are you using Direct charges or destination charges?
I'm collecting the payment and then creating transfer
ah gotcha.
In that case yes, It would be generated on the platform account so you'd need an account/direct type webhook endpoint ๐
damn ahah
And is it possible to use the same WH or different WH is better ?
I mean same endpoint or different endpoint
I'd say having different endpoint would be easier to maintain
NP! ๐ Good luck