braintree / braintree_java

Braintree Java library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
158 stars 99 forks source link

WebhookTestingGateway allow configurable notifications #73

Closed mike-ruane closed 2 years ago

mike-ruane commented 5 years ago

I'm using the WebhookTestingGateway to generate test Notifications. My programme does something depending on values of the kind on a Dispute. I want to be able to generate Disputes where I can give in different values. For example:

gateway.webhookTesting().sampleNotification(WebhookNotification.Kind.DISPUTE_OPENED, "my_id") could maybe take other parameters that would set values in the xml appropriately.

Thanks

hollabaq86 commented 5 years ago

Hi @mike-ruane, thanks for reaching out. Can you elaborate on your use case? What additional attributes of the dispute webhooks would you want to be able to specify in the sampleNotification request?

mike-ruane commented 5 years ago

Yes sure, sorry it was a bit thin on detail.

So, my use case is I want to filter out a particular Dispute kind - namely RETRIEVAL. So I want to mock up a notification that has Dispute.getKind as RETRIEVAL. At current, for a DISPUTE_OPENEDmock notification, the kind of dispute is hard coded. I'd want to be able to set this value to retrieval.

I hope that's clearer.

crookedneighbor commented 5 years ago

We're brainstorming some solutions.

In the meantime, since the sample notification is a simple hash map, you should be able to get the value of the payload, base64decode it, do a string replacement of chargeback with retrieval, then base64 encode it again, and replace the old payload with the new payload.

(yes, this is extremely hacky, but it should get you unstuck)

hollabaq86 commented 2 years ago

Closing this issue, as we've forwarded this feature request on to another team for investigation.