-
Notifications
You must be signed in to change notification settings - Fork 67
/
dispute-steps.tsx
279 lines (272 loc) · 8.57 KB
/
dispute-steps.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/** @format **/
/**
* External dependencies
*/
import React from 'react';
import { __, 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';
/**
* 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';
import DisputeDueByDate from './dispute-due-by-date';
interface Props {
dispute: Dispute;
customer: ChargeBillingDetails | null;
chargeCreated: number;
}
export const DisputeSteps: React.FC< Props > = ( {
dispute,
customer,
chargeCreated,
} ) => {
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(
emailSubject
) }&body=${ encodeURIComponent( emailBody ) }`;
}
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 identify the issue and work towards a resolution where possible.',
'woocommerce-payments'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a
target="_blank"
rel="noopener noreferrer"
href={ emailLink }
/>
),
}
)
: __(
'Email the customer to identify the issue and work towards a resolution where possible.',
'woocommerce-payments'
) }
</li>
<li>
{ createInterpolateElement(
__(
'Assist the customer <a>in withdrawing their dispute</a> if they agree to do so.',
'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 <dueByDate/>',
'woocommerce-payments'
),
{
challengeIcon: (
<ClickTooltip
buttonIcon={ <HelpOutlineIcon /> }
buttonLabel={ __(
'Challenge the dispute tooltip',
'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 tooltip',
'woocommerce-payments'
) }
content={ sprintf(
// Translators: %s is a formatted currency amount, eg $10.00.
__(
`Accepting this dispute will automatically close it. The disputed amount and the %s dispute fee will not be returned to you.`,
'woocommerce-payments'
),
getDisputeFeeFormatted(
dispute,
true
) || '-'
) }
/>
),
dueByDate: (
<DisputeDueByDate
dueBy={ dispute.evidence_details.due_by }
showRemainingDays={ false }
/>
),
}
) }
</li>
</ol>
</div>
);
};
export const InquirySteps: React.FC< Props > = ( {
dispute,
customer,
chargeCreated,
} ) => {
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(
emailSubject
) }&body=${ encodeURIComponent( emailBody ) }`;
}
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 identify the issue and work towards a resolution where possible.',
'woocommerce-payments'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a
target="_blank"
rel="noopener noreferrer"
href={ emailLink }
/>
),
}
)
: __(
'Email the customer to identify the issue and work towards a resolution where possible.',
'woocommerce-payments'
) }
</li>
<li>
{ createInterpolateElement(
__(
'Submit evidence <submitEvidenceIcon/> or issue a refund by <dueByDate/>.',
'woocommerce-payments'
),
{
submitEvidenceIcon: (
<ClickTooltip
buttonIcon={ <HelpOutlineIcon /> }
buttonLabel={ __(
'Submit evidence tooltip',
'woocommerce-payments'
) }
content={ createInterpolateElement(
__(
"To submit evidence, provide documentation that supports your case. Keep in mind that submitting evidence doesn't ensure a favorable outcome. If the cardholder agrees to withdraw the inquiry, you'll still need to officially submit your evidence to prevent bank escalation. <learnMoreLink>Learn more</learnMoreLink>",
'woocommerce-payments'
),
{
learnMoreLink: (
<ExternalLink href="https://woocommerce.com/document/woopayments/fraud-and-disputes/managing-disputes/#inquiries" />
),
}
) }
/>
),
dueByDate: (
<DisputeDueByDate
dueBy={ dispute.evidence_details.due_by }
/>
),
}
) }
</li>
</ol>
</div>
);
};