woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.3k stars 10.74k forks source link

[Enhancement]: Support recording transaction fees with a standardized `_transaction_fee` meta key (`transaction_fee` in HPOS) #36028

Open melek opened 1 year ago

melek commented 1 year ago

Describe the solution you'd like

Credit card and other payment method per-transaction fees are important for accurately reporting on revenue for modern shops. It is important enough that gateways like PayPal Payments (with _ppcp_paypal_fees), Stripe (with _stripe_fee), and many others already add their own meta fields on orders to record transaction fees.

There would be obvious benefits to a standardized total transaction fee field:

I imagine the fee format should mirror the transaction_id field's design, probably as transaction_fee (and _transaction_fee on non-HPOS orders).

Minimum needed functionality

Nice-to-have functionality

Describe alternatives you've considered

Individual gateways already implement a meta field like this, but it is always up to the developer how to implement it and what to name it. Without a standard API, this isn't that useful for reports or extensibility.

This approach doesn't touch current gateway implementations unless they have their own _transaction_fee meta field that doesn't contain a fitting data type. Even in that case, we can handle that by ignoring the field if the value is an unexpected type (and warn folks ahead of time to check their plugins if they use that field, since it is a common-sense name).

Additional context

Ultimately, there may be room in the future for a one-to-many Order → Transactions data structure, as hinted in this blog comment. That would be great for lots of reasons outside the scope of this request. In general, keeping the data structures flexible / extendable is nice for a system that needs to accommodate so many kinds of business as Woo does.

Similarly, with how complex payments have become I could imagine scenarios where multiple transaction fees should be recorded separately even for the same transaction. Maybe eventually an API similar to regular order fees would be useful to store such information.

That said, I think considering a 'base case' of a simple total in the field is a fine starting point, however, since if transactions are more comprehensively updated in the future, that'll likely introduce an opportunity to also extend how transaction fees would be handled. Transaction fees are such a normal issue for shops to think about, I really think they need to have a place in WooCommerce's core implementation.

To loop in an existing issue, #26991 is an existing discussion of showing PayPal Standard transaction fees. Not sure the status of this request with PayPal Standard being hidden in new installations.

There is some discussion on that issue from a community member on how this would help them with budgeting and reporting with PayPal.

github-actions[bot] commented 1 year ago

Hi @melek,

Thank you for opening the issue! It requires further feedback from the WooCommerce Core team.

We are adding the needs developer feedback label to this issue so that the Core team could take a look.

Please note it may take a few days for them to get to this issue. Thank you for your patience.

barryhughes commented 1 year ago

Thank you, this seems like a sensible idea and we'll look into next steps :+1:

piinthecloud commented 1 year ago

Adding a comment from the Community Slack by @pmgarman about what an ideal transaction ledger system might look like

https://shopify.dev/docs/api/admin-rest/2023-07/resources/transaction#resource-object << my dream for WC transactions

Luc45 commented 9 months ago

Just dropping a comment here to say that during my weekly support rotation, a client wanted to see how much she was paying for PayPal/Stripe transaction fees, and this information wasn't available in her reportings. I believe it's because they are not standardized. So just dropping a thumbs up for this feature. :+1:

masteradhoc commented 4 days ago

Thumbs up from my side as well, just had a usecase that would have been great to have this data.