#Zesh-charge-event

1 messages ยท Page 1 of 1 (latest)

coral tapir
#

Hi there ๐Ÿ‘‹ I don't think there is a good way to make that distinction, but am double checking.

maiden river
#

I have a service object that tries to check if I've created a record for the charge yet, and a listener that uses the same service. I end up with two records, and am trying to avoid using infrastructure (like caching) to resolve the race condition. If my listener could be aware of handling only charges made on the Dashboard it would be ideal.

coral tapir
#

I just created a test charge, and I'm not seeing any values on the event that are a good indicator that the charge was created from the dashboard.

To make sure I understand your flow though, do you have two possible paths for these objects to be created? One path being via the dashboard, and the other being another flow?

maiden river
#

Yes. So I have a service object that processes a charge on stripe, and uses another service object to create a record in charges; I also have a listener listening to charge.created that uses the same service object to store a charge. This service object looks for a charge in the database before it creates that charge, but somehow I keep getting duplicates.

#

It seems that my service object creating the charge through a workflow is creating a record simultaneously with the listener.

#

So to be clear, I only have one service object that can ever create that record, and it is shared between the listener and other service objects in the app

coral tapir
#

The reason I asked, is I'm wondering if you could add metadata to the objects created outside of the Dashboard, and then use that as a filter to determine whether your service should process the object.
https://stripe.com/docs/api/metadata

maiden river
#

Ah, yes of course, I can obviously create the environment I was hoping for myself. That makes sense. Thanks @coral tapir ๐Ÿ˜„

coral tapir
#

Any time, always happy to help!