wallee-payment / java-sdk

The wallee Java SDK allows an easy integration of the wallee payment hub into Java applications.
Apache License 2.0
3 stars 1 forks source link

Example of how to use webhooks with payload signing is missing #10

Open franck102 opened 3 weeks ago

franck102 commented 3 weeks ago

Despite searching through the entire documentation and SDK source code I cannot figure out how to enable payload signing for webhooks with the SDK?

There is a WebhookIdentity entity that we can configure on a webhook create request, but no API to create or retrieve it? And the WebhookEncryptionService lets you retrieve a public key, but how do you create the key pair in the first place?

A complete example would be most useful...

thibault-mambour commented 3 weeks ago

hi @franck102 , thank you for your question but I am not sure we understand what is the problem you are running into or trying to achieve with it.

How the payload signing can be used is defined here https://github.com/wallee-payment/java-sdk?tab=readme-ov-file#integrating-webhook-payload-signing-mechanism-into-webhook-callback-handler

franck102 commented 2 days ago

Hi Thibault,

The sample you mention explains how to extract and verify the signature when receiving an event. I am not receiving a signature, and the state is always null... because I haven't found how to enable signatures.

[EDIT]: I found WebhookListenerCreate.enablePayloadSignatureAndState(true) which does enable signatures & state, problem solved.

franck102 commented 2 days ago

So another issue, I have two problems after using this code to create my listener:

 WebhookListenerCreate listenerCreate = new WebhookListenerCreate();
        listenerCreate.entity(entity.id).url(urlId)
            .name("passmate-" + tenantId + "-" + entity.name() + "-" + deploymentId)
            .enablePayloadSignatureAndState(true)
            .notifyEveryChange(false);

        try {
            listenerService.create(spaceId, listenerCreate);
        }
        catch (IOException e) {
            _log.error("Could not create Wallee listener for " + entity.name(), e);
        }
  1. in my space UI if I check the created listener it says "Every change to Transaction entities will be reported." - so notifyEveryChange(false) apparently had no effect

  2. I am receiving lots of duplicate events, with distinct IDs and timestamps - e.g. below 2 CONFIRMED, 3 PROCESSING, ...

15:26:03  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373733, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:02+0000', state='CONFIRMED'}
15:26:03  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373745, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:03+0000', state='CONFIRMED'}
15:26:03  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373749, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:03+0000', state='PROCESSING'}
15:26:03  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373752, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:03+0000', state='PROCESSING'}
15:26:04  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373760, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:04+0000', state='PROCESSING'}
15:26:06  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373773, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:06+0000', state='AUTHORIZED'}
15:26:08  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373771, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:08+0000', state='AUTHORIZED'}
15:26:08  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373779, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:08+0000', state='COMPLETED'}
15:26:09  RCVD Wallee webhook event WebhookEvent{tenantId='totem', eventId=464373805, entityId=267689861, listenerEntityId=1472041829003, listenerEntityTechnicalName='Transaction', spaceId=68607, webhookListenerId=500513, timestamp='2024-10-16T13:26:09+0000', state='FULFILL'}