Stripe supports meta data and further transaction data that is not supported in this module. See https://stripe.com/blog/adding-context-with-metadata and https://stripe.com/docs/api#metadata. Please see the attached patch.
It adds an event dispatcher to allow event subscribers to add both transaction and metadata.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | 2949311-22.patch | 9.2 KB | mglaman |
| #20 | 2949311-20.patch | 8.87 KB | mglaman |
| #15 | Screen Shot 2018-11-26 at 1.46.40 PM.png | 33.89 KB | mglaman |
| #14 | Screen Shot 2018-11-26 at 1.41.52 PM.png | 38.36 KB | mglaman |
| #13 | 2949311-13.patch | 8.3 KB | mglaman |
Comments
Comment #2
jamiehollernComment #3
jamiehollernComment #4
thejacer87 commentedpatch applied cleanly, but was missing some `use` statements for me and a couple other minor things
Comment #5
thejacer87 commentedya, that previous one isn't gunna work lol
Comment #6
thejacer87 commentedhere's the interdiff
Comment #7
thejacer87 commentedsorry for the mess. those patches were for the beta branches. re-roll for -dev branch
Comment #8
jamiehollern#7 was good but missing a single `use` statement. See attached.
Comment #9
mglamanThis makes sense. However it needs clean up.
Metadata does not need to be camelcase (see getCacheableMetadata)
Incorrect type hint / return value.
These do not need to be instantiated before firing the event - which could just be passed empty array values, because they are immediately overwritten.
Not quite following. But this is trying to prevent any existing data in
$transaction_datafrom being overwritten?We could do $transaction_data += $extra_transaction_data then, probably. Existing keys will not be overridden.
Does Stripe throw an error if the
metadatais empty? Otherwise we could just simplify this.Comment #10
mglamanHere is an updated patch. It needs some testing, per changes mentioned in #9 (points 9.4 and 9.5.)
I also renamed the event to CollectTransactionDataEvent, because the purpose of the event is to collect additional information. I'm still not sold on that name, however.
Comment #11
mglamanNaming.
TransactionDataEvent. Collects additional transaction details + metadata
Comment #12
mglamanNaming. Doing tests, now.
Comment #13
mglamanHere is a patch with a test module. This was used to post a transaction which supplied a description and metadata, as shown in the screenshot.
Comment #14
mglamanUploaded the wrong screenshot.
Comment #15
mglamanI also tested with an empty metadata, and there were no errors.
Comment #16
mglamanComment #17
mglamanComment #18
bojanz commentedApproach seems fine.
It's odd that the getters and setters are not together here, like usual.
Missing docblocks (inheritdoc for the first one, something sensible for the second one).
Would be great to document when this data is sent (when creating a payment? refunding a payment? creating a payment method?), and what data could be added as an example. Our test adds the order ID, but isn't that something we usually send anyway? If not, why not?
Comment #19
mglamanBah, yeah. I thought I had fixed that.
Thanks. The second one should link to the links in the summary, so people understand the usefulness.
Okay, we'll need to document it is when a Charge transaction is created. One reason I added
commerce_strip_testwas an example, we can mention that.Should we add an issue to always add the order_id and store_id to metadata, since it is supported? I wasn't sure how opinionated we should be out of the gate.
Comment #20
mglamanAddresses #18
All for a follow up issue which passes store_id and order_id as metadata by default.
Comment #21
mglamanLet's add order_id and store_id by default in this patch. That way we just add payment_uuid and maybe add some use case comments.
"Add payment_uuid because another service queries payments over JSON API via Stripe data"
Comment #22
mglamanThis moves order_id and store_id to always exist in the metadata. The example in the test module now shows
Comment #24
bojanz commentedThanks, everyone!