Skip to content

Commit 575952f

Browse files
committed
Merge remote-tracking branch 'origin/webhooks_api' into webhooks_api
2 parents 7197c23 + 327cc9e commit 575952f

2 files changed

Lines changed: 26 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[OST JAVA SDK v2.2.0](https://github.com/ostdotcom/ost-sdk-java/tree/v2.2.0)
22
---
33

4-
* Added webhooks module to call webhook management OST APIs
5-
* Support for verify webhook signature
4+
* Added webhooks module to call webhook management OST APIs.
5+
* Support for verify webhook signature.
66

77
[OST JAVA SDK v2.1.0](https://github.com/ostdotcom/ost-sdk-java/tree/v2.1.0)
88
---

README.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,6 @@ webhooks.
571571
com.ost.services.Webhooks webhooksService = services.webhooks;
572572
```
573573

574-
Get Webhooks Detail:
575-
576-
```java
577-
HashMap<String, Object> params = new HashMap<String, Object>();
578-
params.put("webhook_id", "4107e308-0146-4c6f-b2f3-617e2c0d2354");
579-
JsonObject response = webhooksService.get( params );
580-
System.out.println("response: " + response.toString() );
581-
```
582-
583574
Create Webhook:
584575

585576
```java
@@ -606,16 +597,16 @@ JsonObject response = webhooksService.update( params );
606597
System.out.println("response: " + response.toString() );
607598
```
608599

609-
Delete Webhook:
600+
Get Webhook:
610601

611602
```java
612603
HashMap<String, Object> params = new HashMap<String, Object>();
613604
params.put("webhook_id", "4107e308-0146-4c6f-b2f3-617e2c0d2354");
614-
JsonObject response = webhooksService.deleteWebhook( params );
605+
JsonObject response = webhooksService.get( params );
615606
System.out.println("response: " + response.toString() );
616607
```
617608

618-
List Webhooks Detail:
609+
Get Webhook List:
619610

620611
```java
621612
HashMap<String, Object> params = new HashMap<String, Object>();
@@ -625,14 +616,31 @@ JsonObject response = webhooksService.getList( params );
625616
System.out.println("response: " + response.toString() );
626617
```
627618

628-
Verify Signature for webhook:
619+
Delete Webhook:
620+
621+
```java
622+
HashMap<String, Object> params = new HashMap<String, Object>();
623+
params.put("webhook_id", "4107e308-0146-4c6f-b2f3-617e2c0d2354");
624+
JsonObject response = webhooksService.deleteWebhook( params );
625+
System.out.println("response: " + response.toString() );
626+
```
627+
628+
Verify webhook request signature:
629629

630630
```java
631-
String version = "v2"; // webhook response version should be here
632-
String stringifiedData = "YourStringifiedObjectData" // webhook response should be here
633-
String requestTimestamp = "1559902637"; // webhook response requested_timestamp should be here
631+
String webhookEventData = '{"id":"54e3cd1c-afd7-4dcf-9c78-137c56a53582","topic":"transactions/success","created_at":1560838772,"webhook_id":"0823a4ea-5d87-44cf-8ca8-1e5a31bf8e46","version":"v2","data":{"result_type":"transaction","transaction":{"id":"ddebe817-b94f-4b51-9227-f543fae4715a","transaction_hash":"0x7ee737db22b58dc4da3f4ea4830ca709b388d84f31e77106cb79ee09fc6448f9","from":"0x69a581096dbddf6d1e0fff7ebc1254bb7a2647c6","to":"0xc2f0dde92f6f3a3cb13bfff43e2bd136f7dcfe47","nonce":3,"value":"0","gas_price":"1000000000","gas_used":120558,"transaction_fee":"120558000000000","block_confirmation":24,"status":"SUCCESS","updated_timestamp":1560838699,"block_timestamp":1560838698,"block_number":1554246,"rule_name":"Pricer","meta_property":{},"transfers":[{"from":"0xc2f0dde92f6f3a3cb13bfff43e2bd136f7dcfe47","from_user_id":"acfdea7d-278e-4ffc-aacb-4a21398a280c","to":"0x0a754aaab96d634337aac6556312de396a0ca46a","to_user_id":"7bc8e0bd-6761-4604-8f8e-e33f86f81309","amount":"112325386","kind":"transfer"}]}}}' // webhook response should be here
632+
633+
// Get webhoook version from webhook events data.
634+
String version = "v2";
635+
636+
// Get ost-timestamp from the response received in event.
637+
String requestTimestamp = "1559902637";
638+
639+
// Get signature from the response received in event.
634640
String signature = "e9206f9feecccd8f9653a4bdb56ea74531e6528bae8f6de1797aa77dc5235923";
641+
635642
String webhookSecret = "09121ae7614856777fa36d63aca828e0ef14be77fb48fa149e0c0b50fec847a7";
643+
String stringifiedData = webhookEventData;
636644
Boolean response = webhooksService.verifySignature( version, stringifiedData, requestTimestamp, signature, webhookSecret );
637645
System.out.println("response: " + response );
638646
```

0 commit comments

Comments
 (0)