Skip to content

Commit ca83288

Browse files
Merge pull request #243 from Samarth-22-dev/webhookChanges
IPPPI-2688:Support for new Webhooks payload
2 parents ab99cfb + fd0a7d7 commit ca83288

File tree

14 files changed

+179
-12
lines changed

14 files changed

+179
-12
lines changed

ipp-v3-java-data/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.intuit.quickbooks-online</groupId>
66
<artifactId>ipp-v3-java-devkit-pom</artifactId>
7-
<version>6.5.1</version>
7+
<version>6.5.2</version>
88
</parent>
99

1010
<artifactId>ipp-v3-java-data</artifactId>
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Intuit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
******************************************************************************/
16+
package com.intuit.ipp.data;
17+
18+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import java.util.Map;
21+
22+
/**
23+
* New CloudEvents-based webhook event item.
24+
*/
25+
@JsonIgnoreProperties(ignoreUnknown = true)
26+
public class WebhooksCloudEvents {
27+
28+
@JsonProperty("specversion")
29+
private String specVersion;
30+
31+
@JsonProperty("id")
32+
private String id;
33+
34+
@JsonProperty("source")
35+
private String source;
36+
37+
@JsonProperty("type")
38+
private String type;
39+
40+
@JsonProperty("datacontenttype")
41+
private String dataContentType;
42+
43+
@JsonProperty("time")
44+
private String time;
45+
46+
@JsonProperty("intuitentityid")
47+
private String intuitEntityId;
48+
49+
@JsonProperty("intuitaccountid")
50+
private String intuitAccountId;
51+
52+
@JsonProperty("data")
53+
private Map<String, Object> data;
54+
55+
public String getSpecVersion() {
56+
return specVersion;
57+
}
58+
59+
public void setSpecVersion(String specVersion) {
60+
this.specVersion = specVersion;
61+
}
62+
63+
public String getId() {
64+
return id;
65+
}
66+
67+
public void setId(String id) {
68+
this.id = id;
69+
}
70+
71+
public String getSource() {
72+
return source;
73+
}
74+
75+
public void setSource(String source) {
76+
this.source = source;
77+
}
78+
79+
public String getType() {
80+
return type;
81+
}
82+
83+
public void setType(String type) {
84+
this.type = type;
85+
}
86+
87+
public String getDataContentType() {
88+
return dataContentType;
89+
}
90+
91+
public void setDataContentType(String dataContentType) {
92+
this.dataContentType = dataContentType;
93+
}
94+
95+
public String getTime() {
96+
return time;
97+
}
98+
99+
public void setTime(String time) {
100+
this.time = time;
101+
}
102+
103+
public String getIntuitEntityId() {
104+
return intuitEntityId;
105+
}
106+
107+
public void setIntuitEntityId(String intuitEntityId) {
108+
this.intuitEntityId = intuitEntityId;
109+
}
110+
111+
public String getIntuitAccountId() {
112+
return intuitAccountId;
113+
}
114+
115+
public void setIntuitAccountId(String intuitAccountId) {
116+
this.intuitAccountId = intuitAccountId;
117+
}
118+
119+
public Map<String, Object> getData() {
120+
return data;
121+
}
122+
123+
public void setData(Map<String, Object> data) {
124+
this.data = data;
125+
}
126+
}
127+
128+

ipp-v3-java-devkit/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>ipp-v3-java-devkit-pom</artifactId>
77
<groupId>com.intuit.quickbooks-online</groupId>
8-
<version>6.5.1</version>
8+
<version>6.5.2</version>
99
</parent>
1010
<artifactId>ipp-v3-java-devkit</artifactId>
1111
<packaging>jar</packaging>
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>com.intuit.quickbooks-online</groupId>
2222
<artifactId>ipp-v3-java-data</artifactId>
23-
<version>6.5.1</version>
23+
<version>6.5.2</version>
2424
<exclusions>
2525
<exclusion>
2626
<groupId>javax.xml.bind</groupId>

ipp-v3-java-devkit/src/main/java/com/intuit/ipp/services/WebhooksService.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919
import java.io.UnsupportedEncodingException;
2020
import java.security.InvalidKeyException;
2121
import java.security.NoSuchAlgorithmException;
22+
import java.util.List;
2223

2324
import javax.crypto.Mac;
2425
import javax.crypto.spec.SecretKeySpec;
2526
import javax.xml.bind.DatatypeConverter;
2627

2728
import com.fasterxml.jackson.core.JsonParseException;
29+
import com.fasterxml.jackson.core.type.TypeReference;
2830
import com.fasterxml.jackson.databind.JsonMappingException;
2931
import com.fasterxml.jackson.databind.ObjectMapper;
32+
import com.intuit.ipp.data.WebhooksCloudEvents;
3033
import com.intuit.ipp.util.StringUtils;
3134

3235
import com.intuit.ipp.data.WebhooksEvent;
@@ -88,6 +91,31 @@ public WebhooksEvent getWebhooksEvent(String payload) {
8891
}
8992

9093
}
94+
95+
/**
96+
* Deserialize new CloudEvents-based webhook payloads which are arrays of events
97+
* PR parity: method name uses getWebhooksCloudEvents (typo preserved)
98+
* @param payload JSON array payload
99+
* @return list of WebhooksCloudEvents or null if payload empty/invalid
100+
*/
101+
public List<WebhooksCloudEvents> getWebhooksCloudEvents(String payload) {
102+
if (!StringUtils.hasText(payload)) {
103+
return null;
104+
}
105+
try {
106+
ObjectMapper mapper = new ObjectMapper();
107+
return mapper.readValue(payload, new TypeReference<List<WebhooksCloudEvents>>() {});
108+
} catch (JsonParseException e) {
109+
LOG.error("Error while parsing new webhooks payload", e);
110+
return null;
111+
} catch (JsonMappingException e) {
112+
LOG.error("Error while mapping new webhooks payload", e);
113+
return null;
114+
} catch (IOException e) {
115+
LOG.error("IO exception while parsing new webhooks payload", e);
116+
return null;
117+
}
118+
}
91119

92120
/**
93121
* Verifier key to validate webhooks payload

ipp-v3-java-devkit/src/main/resources/ippdevkit.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Devkit Version
44
# This version has to be updated according to the pom version
5-
version = 6.5.1
5+
version = 6.5.2
66

77
# This is to have the request source to be sent to IDS request header
88
request.source = V3JavaSDK

ipp-v3-java-devkit/src/test/java/com/intuit/ipp/services/WebhooksServiceTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*******************************************************************************/
1616
package com.intuit.ipp.services;
1717

18+
import com.intuit.ipp.data.WebhooksCloudEvents;
1819
import org.testng.Assert;
1920
import org.testng.annotations.BeforeClass;
2021
import org.testng.annotations.Test;
@@ -56,6 +57,16 @@ public void testGetWebhooksEvent() throws FMSException {
5657
Assert.assertNotNull(webhooksEvent);
5758
Assert.assertEquals(webhooksEvent.getEventNotifications().size(), 1);
5859
}
60+
61+
@Test
62+
public void testGetWebhooksCloudEvents() throws FMSException {
63+
String newPayload = "[{\"specversion\":\"1.0\",\"id\":\"d1a3aedd-9670-41bf-a4f9-c148a1cc4e03\",\"source\":\"intuit.dsnBgbseACLLRZNxo2dfc4evmEJdxde58xeeYcZliOU=\",\"type\":\"qbo.class.created.v1\",\"time\":\"2025-10-07T19:59:07.034359333Z\",\"intuitentityid\":\"1234\",\"intuitaccountid\":\"310687\"}]";
64+
java.util.List<WebhooksCloudEvents> events = webhooksService.getWebhooksCloudEvents(newPayload);
65+
Assert.assertNotNull(events);
66+
Assert.assertEquals(events.size(), 1);
67+
Assert.assertEquals(events.get(0).getSpecVersion(), "1.0");
68+
Assert.assertEquals(events.get(0).getId(), "d1a3aedd-9670-41bf-a4f9-c148a1cc4e03");
69+
}
5970

6071

6172
}

ipp-v3-java-devkit/src/test/resources/ippdevkit.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### IPP Dev Kit helper properties
22

33
## Devkit version
4-
version = 6.5.1
4+
version = 6.5.2
55

66
# This is to have the request source to be sent to IDS request header
77
request.source = V3JavaSDK

oauth2-platform-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>ipp-v3-java-devkit-pom</artifactId>
2222
<groupId>com.intuit.quickbooks-online</groupId>
23-
<version>6.5.1</version>
23+
<version>6.5.2</version>
2424
</parent>
2525
<artifactId>oauth2-platform-api</artifactId>
2626
<name>Quickbooks API Helper for OAuth2</name>

oauth2-platform-api/src/main/resources/oauthclient.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ EMAIL=email
3434
INTUIT_NAME=intuit_name
3535

3636
#Version
37-
version = 6.5.1
37+
version = 6.5.2
3838

3939
#MIGRATION SERVICE URL
4040
OAUTH_MIGRATION_URL_PRODUCTION=https://developer.api.intuit.com/v2/oauth2/tokens/migrate

oauth2-platform-api/src/test/resources/oauthclient.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ EMAIL=email
3434
INTUIT_NAME=intuit_name
3535

3636
#Version
37-
version = 6.5.1
37+
version = 6.5.2
3838

3939
#MIGRATION SERVICE URL
4040
OAUTH_MIGRATION_URL_PRODUCTION=https://developer.api.intuit.com/v2/oauth2/tokens/migrate

0 commit comments

Comments
 (0)