Skip to content

Commit c33965d

Browse files
add tolerance param to parseThinEvent (#1912)
1 parent 1f7295b commit c33965d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main/java/com/stripe/StripeClient.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,25 @@ protected StripeResponseGetter getResponseGetter() {
5454
*/
5555
public ThinEvent parseThinEvent(String payload, String sigHeader, String secret)
5656
throws SignatureVerificationException {
57-
Signature.verifyHeader(payload, sigHeader, secret, Webhook.DEFAULT_TOLERANCE);
57+
return parseThinEvent(payload, sigHeader, secret, Webhook.DEFAULT_TOLERANCE);
58+
}
59+
60+
/**
61+
* Returns an StripeEvent instance using the provided JSON payload. Throws a JsonSyntaxException
62+
* if the payload is not valid JSON, and a SignatureVerificationException if the signature
63+
* verification fails for any reason.
64+
*
65+
* @param payload the payload sent by Stripe.
66+
* @param sigHeader the contents of the signature header sent by Stripe.
67+
* @param secret secret used to generate the signature.
68+
* @param tolerance number of seconds that the event's timestamp can differ from the system time.
69+
* Passing `0` will disable the time check entirely and is **strongly discouraged**.
70+
* @return the StripeEvent instance
71+
* @throws SignatureVerificationException if the verification fails.
72+
*/
73+
public ThinEvent parseThinEvent(String payload, String sigHeader, String secret, long tolerance)
74+
throws SignatureVerificationException {
75+
Signature.verifyHeader(payload, sigHeader, secret, tolerance);
5876

5977
return ApiResource.GSON.fromJson(payload, ThinEvent.class);
6078
}

0 commit comments

Comments
 (0)