Skip to content

Commit

Permalink
Merge upstream and update generated code for v1471
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe-openapi[bot] committed Feb 7, 2025
2 parents 6aa3bb3 + 7c99196 commit 99947d8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1467
v1471
8 changes: 8 additions & 0 deletions src/main/java/com/stripe/net/Webhook.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.security.NoSuchAlgorithmException;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
Expand Down Expand Up @@ -72,6 +73,13 @@ public static Event constructEvent(
StripeObject.deserializeStripeObject(
payload, Event.class, ApiResource.getGlobalResponseGetter());
Signature.verifyHeader(payload, sigHeader, secret, tolerance, clock);
// StripeObjects source their raw JSON object from their last response, but constructed webhooks
// don't have that
// in order to make the raw object available on parsed events, we fake the response.
if (event.getLastResponse() == null) {
event.setLastResponse(
new StripeResponse(200, HttpHeaders.of(Collections.emptyMap()), payload));
}

return event;
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/com/stripe/net/WebhookTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stripe.net;

import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -325,4 +326,13 @@ public void testStripeClientConstructEventWithTolerance()

Mockito.verify(responseGetter).request(Mockito.any(), Mockito.any());
}

@Test
public void testConstructEventWithRawJson()
throws StripeException, NoSuchAlgorithmException, InvalidKeyException {

final Event event = Webhook.constructEvent(payload, generateSigHeader(), secret);

assertNotNull(event.getRawJsonObject());
}
}

0 comments on commit 99947d8

Please sign in to comment.