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

Add dispute steps to resolve to the transaction details page. #7206

Merged
merged 33 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bb6ba35
Pass store name in wcpaySettings because it will be needed as part of…
shendy-a8c Sep 13, 2023
3088de5
Steps to resolve section in the dispute details section on transactio…
shendy-a8c Sep 13, 2023
284243f
Challenge and accept icons for the 4th step from the Steps to resolve…
shendy-a8c Sep 13, 2023
18f2fa5
Add comment to translator explaining that %s is formatted currency am…
shendy-a8c Sep 13, 2023
5a3cbe5
Show dispute response due by date at the 4th step of the Steps to res…
shendy-a8c Sep 13, 2023
53c6679
Changelog.
shendy-a8c Sep 13, 2023
f9c94f9
Positioning the click tool icons more correctly.
shendy-a8c Sep 13, 2023
45e25fa
Add TODO to add link to issuer's evidence files link.
shendy-a8c Sep 13, 2023
63bd71f
Merge branch 'develop' into add/6925-steps-to-resolve
shendy-a8c Sep 13, 2023
6fe270b
Add TODO to link 'guidance on dispute withdrawal' to the docs when it…
shendy-a8c Sep 13, 2023
d28219e
Remove test CSS class.
shendy-a8c Sep 13, 2023
04ee3f6
Show dispute fee instead of dispute amount in the tooltip that explai…
shendy-a8c Sep 13, 2023
e94f356
Merge branch 'develop' into add/6925-steps-to-resolve
shendy-a8c Sep 17, 2023
a7ddf94
Add link to dispute withdrawal docs.
shendy-a8c Sep 17, 2023
116a8db
Handle when customer's name is null.
shendy-a8c Sep 17, 2023
ad54e79
Merge branch 'develop' into add/6925-steps-to-resolve
brucealdridge Sep 20, 2023
6e2b7ff
Merge branch 'develop' into add/6925-steps-to-resolve
Jinksi Sep 20, 2023
d9d006e
Update list style to match design
Jinksi Sep 20, 2023
e8a83fe
Remove "Review the claim" step, out of PR scope
Jinksi Sep 21, 2023
f9126c5
Don't show steps for inquiries
Jinksi Sep 21, 2023
d105ead
Fix card child padding when steps not rendered (inquiries)
Jinksi Sep 21, 2023
19545bd
Add "external link" icon to guidance link to match design
Jinksi Sep 21, 2023
973a63c
Add/update tests for steps to resolve
Jinksi Sep 21, 2023
64556a1
Minor code formatting
Jinksi Sep 21, 2023
0b768b3
Fix tooltip shifting neighboring elements bug
Jinksi Sep 21, 2023
6a55603
Add tooltip component vertical-align as a sensible default
Jinksi Sep 21, 2023
3d35ecc
Add dispute fee to accept tooltip
Jinksi Sep 21, 2023
787b8d9
Make email subject and body translatable
Jinksi Sep 21, 2023
341ef80
Fix typo in translatable string domain
Jinksi Sep 21, 2023
0498f7a
Merge branch 'develop' into add/6925-steps-to-resolve
shendy-a8c Sep 21, 2023
4a10c2a
Add comment for temp inquiry restriction
Jinksi Sep 21, 2023
9275269
Improve CSS comment grammar
Jinksi Sep 21, 2023
71a3349
Merge branch 'develop' into add/6925-steps-to-resolve
Jinksi Sep 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/add-6925-steps-to-resolve
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: This work is part of a UI improvements to increase disputes response that is behind a feature flag. A changelog entry will be added to represent the work as a whole.


6 changes: 6 additions & 0 deletions client/components/tooltip/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
// ensures that the element needed for position calculations isn't included in the DOM layout
display: contents;

// fixes a UI bug where the tooltip can shift neighboring elements when it appears
Jinksi marked this conversation as resolved.
Show resolved Hide resolved
> div {
display: inline;
}

// Styles for buttonIcon
[role='button'] {
cursor: pointer;
Expand All @@ -12,6 +17,7 @@
transition: all 0.3s ease;
fill: currentColor;
margin: 0 0.4em;
vertical-align: text-bottom;

&:focus,
&:hover,
Expand Down
1 change: 1 addition & 0 deletions client/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ declare global {
isWooPayStoreCountryAvailable: boolean;
isSubscriptionsPluginActive: boolean;
isStripeBillingEligible: boolean;
storeName: string;
};

const wcTracks: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
* Internal dependencies
*/
import type { Dispute } from 'wcpay/types/disputes';
import type { ChargeBillingDetails } from 'wcpay/types/charges';
import wcpayTracks from 'tracks';
import { useDisputeAccept } from 'wcpay/data';
import {
Expand All @@ -34,22 +35,29 @@ import { getAdminUrl } from 'wcpay/utils';
import DisputeNotice from './dispute-notice';
import IssuerEvidenceList from './evidence-list';
import DisputeSummaryRow from './dispute-summary-row';
import DisputeSteps from './dispute-steps';
import InlineNotice from 'components/inline-notice';
import './style.scss';

interface Props {
dispute: Dispute;
customer: ChargeBillingDetails | null;
chargeCreated: number;
}

const DisputeAwaitingResponseDetails: React.FC< Props > = ( { dispute } ) => {
const DisputeAwaitingResponseDetails: React.FC< Props > = ( {
dispute,
customer,
chargeCreated,
} ) => {
const { doAccept, isLoading } = useDisputeAccept( dispute );
const [ isModalOpen, setModalOpen ] = useState( false );

const now = moment();
const dueBy = moment.unix( dispute.evidence_details?.due_by ?? 0 );
const countdownDays = Math.floor( dueBy.diff( now, 'days', true ) );
const hasStagedEvidence = dispute.evidence_details?.has_evidence;
const showDisputeActions = ! isInquiry( dispute );
const showDisputeStepsAndActions = ! isInquiry( dispute );
Jinksi marked this conversation as resolved.
Show resolved Hide resolved

const onModalClose = () => {
setModalOpen( false );
Expand Down Expand Up @@ -81,14 +89,22 @@ const DisputeAwaitingResponseDetails: React.FC< Props > = ( { dispute } ) => {
dispute={ dispute }
daysRemaining={ countdownDays }
/>
{ showDisputeStepsAndActions && (
<DisputeSteps
dispute={ dispute }
customer={ customer }
chargeCreated={ chargeCreated }
daysRemaining={ countdownDays }
/>
) }
<IssuerEvidenceList
issuerEvidence={ dispute.issuer_evidence }
/>
</>
) }

{ /* Dispute Actions */ }
{ showDisputeActions && (
{ showDisputeStepsAndActions && (
<div className="transaction-details-dispute-details-body__actions">
<Link
href={
Expand Down
202 changes: 202 additions & 0 deletions client/payment-details/dispute-details/dispute-steps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
/** @format **/

/**
* External dependencies
*/
import React from 'react';
import { __, _n, sprintf } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
import { ExternalLink } from '@wordpress/components';
import { dateI18n } from '@wordpress/date';
import moment from 'moment';
import HelpOutlineIcon from 'gridicons/dist/help-outline';
import classNames from 'classnames';

/**
* Internal dependencies
*/
import type { Dispute } from 'wcpay/types/disputes';
import { ChargeBillingDetails } from 'wcpay/types/charges';
import { formatExplicitCurrency } from 'utils/currency';
import { ClickTooltip } from 'wcpay/components/tooltip';
import { getDisputeFeeFormatted } from 'wcpay/disputes/utils';

interface Props {
dispute: Dispute;
customer: ChargeBillingDetails | null;
chargeCreated: number;
daysRemaining: number;
}

const DisputeSteps: React.FC< Props > = ( {
dispute,
customer,
chargeCreated,
daysRemaining,
} ) => {
let emailLink;
if ( customer?.email ) {
const chargeDate = dateI18n(
'Y-m-d',
moment( chargeCreated * 1000 ).toISOString()
);
const disputeDate = dateI18n(
'Y-m-d',
moment( dispute.created * 1000 ).toISOString()
);
const emailSubject = sprintf(
// Translators: %1$s is the store name, %2$s is the charge date.
__(
`Problem with your purchase from %1$s on %2$s?`,
'woocommerce-payments'
),
wcpaySettings.storeName,
chargeDate
);
const customerName = customer?.name || '';
const emailBody = sprintf(
// Translators: %1$s is the customer name, %2$s is the dispute date, %3$s is the dispute amount with currency-code e.g. $15 USD, %4$s is the charge date.
__(
`Hello %1$s\n\n` +
`We noticed that on %2$s, you disputed a %3$s charge on %4$s. We wanted to contact you to make sure everything was all right with your purchase and see if there's anything else we can do to resolve any problems you might have had.\n\n` +
`Alternatively, if the dispute was a mistake, you can easily withdraw it by calling the number on the back of your card. Thank you so much - we appreciate your business and look forward to working with you.`,
'woocommerce-payments'
),
customerName,
disputeDate,
formatExplicitCurrency( dispute.amount, dispute.currency ),
chargeDate
);
emailLink = `mailto:${ customer.email }?subject=${ encodeURIComponent(
Copy link
Contributor Author

@shendy-a8c shendy-a8c Sep 14, 2023

Choose a reason for hiding this comment

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

Wanted to use querystring.strinfigy() but I don't see it's used at all in the codebase, so I just use encodeURIComponent() to escape each param's value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Has anyone tested clicking the link correctly works with at least one email client? If there's any issue with escaping or protocol then that would catch it! I have this behaviour disabled on my mac (because I use GMail), so wasn't able to test.

Noting so we can test in our test swarm today e.g. on mobile or if someone has mailto configured right :)

emailSubject
) }&body=${ encodeURIComponent( emailBody ) }`;
}

const respondByDate = dispute.evidence_details?.due_by
? dateI18n(
'M j, Y, g:ia',
moment( dispute.evidence_details?.due_by * 1000 ).toISOString()
)
: '–';

return (
<div className="dispute-steps">
<div className="dispute-steps__header">
{ __( 'Steps to resolve:', 'woocommerce-payments' ) }
</div>
<ol className="dispute-steps__steps">
<li>
{ customer?.email
? createInterpolateElement(
__(
'<a>Email the customer</a> to address their concerns.',
'woocommerce-payments'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a
target="_blank"
rel="noopener noreferrer"
href={ emailLink }
/>
),
}
)
: __(
'Email the customer to address their concerns.',
'woocommerce-payments'
) }
</li>
<li>
{ createInterpolateElement(
__(
'Provide <a>guidance on dispute withdrawal</a> if the customer agrees.',
'woocommerce-payments'
),
{
a: (
<ExternalLink href="https://woocommerce.com/document/woopayments/fraud-and-disputes/managing-disputes/#withdrawals" />
),
}
) }
</li>
<li>
{ createInterpolateElement(
__(
'Challenge <challengeicon/> or accept <accepticon/> the dispute by <disputeduedate/>.',
Copy link
Contributor

Choose a reason for hiding this comment

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

I found these inline icon tooltips a bit weird, they break the flow of the sentence. It's functioning well though and super clear and usable so not a blocker.

Maybe that info could be in a single help popup, nearer the action buttons. Thinking out loud – @nikkivias is our UX expert here.

'woocommerce-payments'
),
{
challengeicon: (
<ClickTooltip
buttonIcon={ <HelpOutlineIcon /> }
buttonLabel={ __(
'Challenge the dispute',
'woocommerce-payments'
) }
content={ __(
"Challenge the dispute if you consider the claim invalid. You'll need to provide evidence to back your claim. Keep in mind that challenging doesn't ensure a resolution in your favor.",
'woocommerce-payments'
) }
/>
),
accepticon: (
<ClickTooltip
buttonIcon={ <HelpOutlineIcon /> }
buttonLabel={ __(
'Accept the dispute',
'woocommerce-payments'
) }
content={ sprintf(
// Translators: %s is a formatted currency amount, eg $10.00.
__(
`Accepting this dispute will automatically close it. Your account will be charged a %s fee, and the disputed amount will be refunded to the cardholder.`,
'woocommerce-payments'
),
getDisputeFeeFormatted(
dispute,
true
) || '-'
) }
/>
),
disputeduedate: (
<span className="dispute-steps__steps__response-date">
Copy link
Contributor Author

@shendy-a8c shendy-a8c Sep 14, 2023

Choose a reason for hiding this comment

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

I copied this from DisputeSummaryRow's so it looks consistent.

One doubt I have is that in the design paJDYF-9Ip-p2, when due date is still more than 7-day away, it does not show the ({n} days left to respond) part.

Screenshot 2023-09-14 at 07 16 13

but I see in DisputeSummaryRow, it shows that text, so for consistency sake, I follow DisputeSummaryRow.

{ respondByDate }
<span
className={ classNames( {
'dispute-steps__steps__response-date--urgent':
daysRemaining < 3,
'dispute-steps__steps__response-date--warning':
daysRemaining < 7 &&
daysRemaining > 2,
} ) }
>
{ daysRemaining === 0
? __(
'(Last day today)',
'woocommerce-payments'
)
: sprintf(
// Translators: %s is the number of days left to respond to the dispute.
_n(
'(%s day left to respond)',
'(%s days left to respond)',
daysRemaining,
'woocommerce-payments'
),
daysRemaining
) }
</span>
</span>
),
}
) }
</li>
</ol>
</div>
);
};

export default DisputeSteps;
41 changes: 40 additions & 1 deletion client/payment-details/dispute-details/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}

.dispute-summary-row {
margin: 24px 0;
margin-top: 24px;

&__response-date {
display: flex;
Expand All @@ -39,6 +39,7 @@
display: flex;
justify-content: start;
gap: $grid-unit-10;
margin-top: 24px;

@media screen and ( max-width: $break-small ) {
flex-direction: column;
Expand All @@ -63,7 +64,45 @@
margin-bottom: 8px;
}
}
.dispute-steps {
margin-top: 24px;

&__header {
font-weight: 600;
font-size: 14px;
}
&__steps {
list-style-position: inside;
margin: 0;

> li {
margin: 0;
padding: 16px 10px 16px 4px;
border-bottom: 1px solid $wp-gray-5;
}

.wcpay-tooltip__content-wrapper > [role='button'] {
margin: 0;
}

&__response-date {
display: inline-flex;
align-items: center;
gap: var( --grid-unit-05, 4px );
flex-wrap: wrap;
font-weight: 600;

&--warning {
color: $wp-yellow-30;
font-weight: 700;
}
&--urgent {
color: $alert-red;
font-weight: 700;
}
}
}
}
.transaction-details-dispute-accept-modal {
max-width: 600px;

Expand Down
2 changes: 2 additions & 0 deletions client/payment-details/summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ const PaymentDetailsSummary: React.FC< PaymentDetailsSummaryProps > = ( {
{ isAwaitingResponse( charge.dispute.status ) ? (
<DisputeAwaitingResponseDetails
dispute={ charge.dispute }
customer={ charge.billing_details }
chargeCreated={ charge.created }
/>
) : (
<DisputeResolutionFooter dispute={ charge.dispute } />
Expand Down
Loading
Loading