Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Transaction Details breakdown: rename labels and add fee breakdown tooltip when disputed #7118

Merged

Conversation

Jinksi
Copy link
Member

@Jinksi Jinksi commented Sep 4, 2023

Fixes #6974

Warning
This PR is NOT behind a feature flag

Changes proposed in this Pull Request

This PR updates the Transaction Details screen with the following changes:

  • Update transaction breakdown labels:
    • Refunded → Deducted
      • only for disputed transactions where a dispute fee has been applied and not reversed
    • Fee → Fees
    • Change style to uppercase
  • A click tooltip that only shows if there is a Dispute fee in addition to the transaction fee. Tooltip content includes fee breakdown:
    • Transaction fee
    • Dispute fee
    • Total fee

Note: HorizontalList uppercase labels were updated in #7126

Before: (develop)
image

After:
image

Fees tooltip content, multi-currency enabled:
image

Design:
image

Additionally, some other code improvements:

  • Add the reporting_category property to the BalanceTransaction type.
  • Fix a ClickTooltip bug preventing the className prop from being applied to the tooltip content element.

Testing instructions

  • Create a disputed transaction using the card 4000000000000259.
  • Navigate to this disputed via the Payments → Transactions list screen.
  • Ensure the Fees tooltip renders, along with the correct fee breakdown.
    • Ensure the Transaction fee matches the Fee total found on the timeline further down this transaction details screen:
      image
  • View a non-disputed transaction details screen.
  • Ensure the Fees tooltip does not render.

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@botwoo
Copy link
Collaborator

botwoo commented Sep 4, 2023

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 7118 or branch name update/6974-transaction-details-breakdown-labels-and-fees in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: 4c24b59
  • Build time: 2023-09-20 21:00:30 UTC

Note: the build is updated when a new commit is pushed to this PR.

in order to filter balance transactions by 'dispute' and get the dispute fee
@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

Size Change: +271 B (0%)

Total Size: 1.41 MB

Filename Size Change
release/woocommerce-payments/dist/index-rtl.css 36.3 kB +50 B (0%)
release/woocommerce-payments/dist/index.css 36.3 kB +52 B (0%)
release/woocommerce-payments/dist/index.js 281 kB +169 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.03 kB
release/woocommerce-payments/assets/css/success.css 158 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 1.51 kB
release/woocommerce-payments/dist/blocks-checkout.css 1.51 kB
release/woocommerce-payments/dist/blocks-checkout.js 73.7 kB
release/woocommerce-payments/dist/checkout-rtl.css 440 B
release/woocommerce-payments/dist/checkout.css 441 B
release/woocommerce-payments/dist/checkout.js 28.7 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.05 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 2.88 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.1 kB
release/woocommerce-payments/dist/multi-currency.css 2.88 kB
release/woocommerce-payments/dist/multi-currency.js 54.7 kB
release/woocommerce-payments/dist/order-rtl.css 676 B
release/woocommerce-payments/dist/order.css 679 B
release/woocommerce-payments/dist/order.js 40.9 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 690 B
release/woocommerce-payments/dist/payment-gateways.css 692 B
release/woocommerce-payments/dist/payment-gateways.js 38.4 kB
release/woocommerce-payments/dist/payment-request-rtl.css 146 B
release/woocommerce-payments/dist/payment-request.css 146 B
release/woocommerce-payments/dist/payment-request.js 11.6 kB
release/woocommerce-payments/dist/product-details.js 789 B
release/woocommerce-payments/dist/settings-rtl.css 8.9 kB
release/woocommerce-payments/dist/settings.css 8.91 kB
release/woocommerce-payments/dist/settings.js 231 kB
release/woocommerce-payments/dist/subscription-edit-page.js 669 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 519 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 519 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.3 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 693 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 117 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 117 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.4 kB
release/woocommerce-payments/dist/tos-rtl.css 230 B
release/woocommerce-payments/dist/tos.css 231 B
release/woocommerce-payments/dist/tos.js 21.9 kB
release/woocommerce-payments/dist/upe_checkout-rtl.css 440 B
release/woocommerce-payments/dist/upe_checkout.css 441 B
release/woocommerce-payments/dist/upe_checkout.js 34 kB
release/woocommerce-payments/dist/upe_split_checkout-rtl.css 440 B
release/woocommerce-payments/dist/upe_split_checkout.css 441 B
release/woocommerce-payments/dist/upe_split_checkout.js 34.6 kB
release/woocommerce-payments/dist/upe_with_deferred_intent_creation_checkout.js 36.6 kB
release/woocommerce-payments/dist/upe-blocks-checkout-rtl.css 1.51 kB
release/woocommerce-payments/dist/upe-blocks-checkout.css 1.51 kB
release/woocommerce-payments/dist/upe-blocks-checkout.js 39.5 kB
release/woocommerce-payments/dist/upe-split-blocks-checkout-rtl.css 1.51 kB
release/woocommerce-payments/dist/upe-split-blocks-checkout.css 1.51 kB
release/woocommerce-payments/dist/upe-split-blocks-checkout.js 41 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 146 B
release/woocommerce-payments/dist/woopay-express-button.css 146 B
release/woocommerce-payments/dist/woopay-express-button.js 50.6 kB
release/woocommerce-payments/dist/woopay-rtl.css 3.85 kB
release/woocommerce-payments/dist/woopay.css 3.85 kB
release/woocommerce-payments/dist/woopay.js 71.6 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 633 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 720 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.43 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.01 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 522 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 581 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 160 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.32 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.8 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.32 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 291 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 403 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.56 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 299 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 742 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 572 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 411 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.63 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.8 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.83 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 502 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 355 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 429 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 781 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.27 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 392 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.06 kB

compressed-size-action

@Jinksi Jinksi changed the base branch from develop to update/horizontal-list-label-style-uppercase September 5, 2023 05:49
@Jinksi Jinksi marked this pull request as ready for review September 5, 2023 06:29
@Jinksi Jinksi requested a review from a team September 5, 2023 06:29
Base automatically changed from update/horizontal-list-label-style-uppercase to develop September 6, 2023 04:26
@Jinksi Jinksi changed the title Update Transaction Details breakdown: rename labels and add fee breakdown tooltip Update Transaction Details breakdown: rename labels and add fee breakdown tooltip when disputed Sep 6, 2023
@Jinksi
Copy link
Member Author

Jinksi commented Sep 14, 2023

Thanks for catching the issue with multi-currency transactions @shendy-a8c 🙏

I've addressed this in 8c9ef0e and b12f465 to now display the fee in the correct currency (the transaction fee's currency).

Tooltip Transaction Fee (kr41.60 in this case):
image

Now matches the Transaction timeline fee total (kr-41.60):

image

See example multi-currency transaction on Helix Demo Site

Copy link
Contributor

@haszari haszari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is working well and implements the design.

I did some brief testing with a couple of disputes, tested with feature flag on and off. Also tested an undisputed transaction and no issues/regressions.

The styling of the transaction breakdown row doesn't feel right to me. The labels and the data use the same styles, which I find hard to read – the data should stand out, the labels are there to "onboard" and orient users to the values they need to find. This could be handled as follow up since this PR adds a useful breakdown tooltip. Keen for input from @nikkivias.


It got me thinking about a few things that we might want to look into (likely as follow up):

  • Overall consistency / agreement on this page. Using the same terms/labels and breakdown in the header summary and the timeline.
  • Ensure we are using currency labels everywhere. There are some places these are left off and this is confusing. If a store only has 1 currency, no labels are needed, but if multicurrency is set up, every $$$ value should include currency IMO.
  • NET amount might need a breakdown tooltip too – but maybe there's a bigger confusion that we are trying to address with tooltips. I find it confusing that the deduction amount in the timeline includes the dispute fee but the summary NET / left number doesn't.
    • Actually that seems like a bug – NET should include all fees and deductions.
  • The first summary number is confusing without a label! I understand this is the purchase price after currency conversion.

Example transaction:

Screenshot 2023-09-18 at 10 27 09 AM

Specific suggested changes (happy to log issues for this after discussion):

  • Transaction summary NET should include dispute fee. In general, that line should add up to NET.
  • All transaction timeline values should have currency (for multicurrency stores): loan repayment, disputed amount, dispute fee.

Consider:

  • First value in summary line (purchase amount in store currency) - is this correct/confusing for disputes?
  • Timeline lists all items as will be added from future deposit will be subtracted from future deposit. Ideas:
    • Make timeline top-level sentence more descriptive, e.g.
      • $2.73 USD deducted for loan repayment (was $2.73 will be subtracted from a future deposit.)
      • $33.23 USD deducted due to dispute (was $33.23 USD was deducted from your Jun 13, 2023 deposit.)
  • Some timeline items link to a real deposit, others like loan repayments seem to just say Future deposit. I wonder if we need to complicate timeline items with deposit info.

@@ -177,6 +186,16 @@ const PaymentDetailsSummary: React.FC< PaymentDetailsSummaryProps > = ( {

const isFraudOutcomeReview = isOnHoldByFraudTools( charge, paymentIntent );

const disputeFee =
charge.dispute &&
charge.dispute.status !== 'won' &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this logic could be moved to an accessor, e.g. getDisputeFeeCharged. What I read from this is that getDisputeFee is confusing. Could rename it getDisputeBalanceTransaction or something more technical/accurate.

const disputeFee = dispute.balance_transactions.find(
( transaction ) => transaction.reporting_category === 'dispute'
);
return disputeFee;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this find ever return multiple items? Do we expect a single item returned from this function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a description to the Dispute TS interface explaining what states the balance_transactions could represent, based on the Stripe docs.

/**
* List of zero, one, or two balance transactions that show funds withdrawn and reinstated to the Stripe account as a result of this dispute.
* One balance transaction with `reporting_category: 'dispute'` will be present if funds have been withdrawn from the account.
* A second balance transaction with the `reporting_category: 'dispute_reversal'` will be present if funds have been reinstated to the account.
*/
balance_transactions: BalanceTransaction[];

I'm adjusting the getDisputeFee function to help make more sense of this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the getDisputeFee logic to clarify some things here.

/**
* Returns the dispute fee balance transaction for a dispute if it exists
* and the deduction has not been reversed.
*/
const getDisputeDeductedBalanceTransaction = (
dispute: Dispute
): BalanceTransaction | undefined => {
// Note that there will only be two balance transactions for a given dispute:
// One balance transaction with reporting_category: 'dispute' will be present if funds have been withdrawn from the account.
const disputeFee = dispute.balance_transactions.find(
( transaction ) => transaction.reporting_category === 'dispute'
);
// A second balance transaction with the reporting_category: 'dispute_reversal' will be present if funds have been reinstated to the account.
const disputeFeeReversal = dispute.balance_transactions.find(
( transaction ) => transaction.reporting_category === 'dispute_reversal'
);
if ( disputeFeeReversal ) {
return undefined;
}
return disputeFee;
};
/**
* Returns the dispute fee formatted as a currency string if it exists
* and the deduction has not been reversed.
*/
export const getDisputeFeeFormatted = (
dispute: Dispute
): string | undefined => {
const disputeFee = getDisputeDeductedBalanceTransaction( dispute );
return (
disputeFee &&
formatExplicitCurrency( disputeFee.fee, disputeFee.currency )
);
};

@haszari do the comments and function names help to clarify the logic here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crystal clear, nice work!

</>
}
/>
) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding currency to all currency values for clarity. (We should probably review all recent changes to ensure we're consistently showing currency.)

This tooltip has similar information to the timeline, should we make them more consistent?

Screenshot 2023-09-18 at 10 27 09 AM

For example:

  • Fee => Dispute fee in timeline
  • $n USD deducted (add deducted to line item in timeline)
  • What's the $33.08 headline number in timeline 🤔?

Copy link
Member Author

@Jinksi Jinksi Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the $33.08 headline number in timeline 🤔?

This I can answer: $18.08 USD disputed amount + $15 USD dispute fee.

Although, the current state of the UI doesn't make this clear. This could be moved to a new issue.

Related to this is the open PR that will change the Transaction Details headline amount to display in the store's currency instead of the customer's currency: #7159

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me – we can iterate on these details over time.

margin: 0.25rem 1rem 0 0;
text-transform: uppercase;
font-weight: 600;
font-size: 12px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it hard to read with the data in the same all caps style as the headings/labels. @nikkivias what do you think about using different style to distinguish the labels from the data?

For example bold small caps for labels, regular weight for data. Mockup:

Screenshot 2023-09-18 at 10 45 36 AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an engineering perspective, this is not a completely straightforward change (these are all rendered as strings, e.g. Deducted: $-18.08 USD, so no separate elements to style).

Therefore, I'll leave this as is for this PR and we can iterate on this in a separate issue after the feedback session.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. I also think we need to discuss this idea with design / other stakeholders before proceeding (though we could maybe prototype at appropriate priority).

@Jinksi Jinksi dismissed shendy-a8c’s stale review September 20, 2023 02:42

Issue with transaction fee tooltip currency has been resolved.

@Jinksi Jinksi enabled auto-merge September 20, 2023 20:57
@Jinksi Jinksi added this pull request to the merge queue Sep 20, 2023
Merged via the queue into develop with commit b88b01f Sep 20, 2023
@Jinksi Jinksi deleted the update/6974-transaction-details-breakdown-labels-and-fees branch September 20, 2023 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transaction Details > Update labels and add fees tooltip when disputed
4 participants