Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
97 changes: 97 additions & 0 deletions client/components/dispute-defense-toolkit/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/** @format **/

/**
* External dependencies
*/
import React from 'react';
import { __ } from '@wordpress/i18n';
import {
Card,
CardHeader,
CardBody,
CheckboxControl,
} from '@wordpress/components';

/**
* Internal dependencies
*/
import './style.scss';

const DisputeDefenseToolkit: React.FC = () => {
const noop = ( isChecked: boolean ) => undefined;

Check warning on line 21 in client/components/dispute-defense-toolkit/index.tsx

View workflow job for this annotation

GitHub Actions / JS linting

'isChecked' is defined but never used

return (
<Card className="dispute-defense-toolkit">
<CardHeader>
<h2>
{ __( 'Dispute Defense Toolkit', 'woocommerce-payments' ) }
</h2>
</CardHeader>
<CardBody>
<div className="toolkit-section">
<h3>
{ __(
'Automatic Evidence Collection',
'woocommerce-payments'
) }
</h3>
<ul className="toolkit-features">
<li>
<CheckboxControl
label={ __(
'Auto-save tracking numbers',
'woocommerce-payments'
) }
checked={ true }
disabled={ true }
onChange={ noop }
/>
<p className="description">
{ __(
'Automatically saves tracking numbers from supported shipping providers',
'woocommerce-payments'
) }
</p>
</li>
<li>
<CheckboxControl
label={ __(
'Log support communications',
'woocommerce-payments'
) }
checked={ true }
disabled={ true }
onChange={ noop }
/>
<p className="description">
{ __(
'Automatically logs customer support conversations for dispute evidence',
'woocommerce-payments'
) }
</p>
</li>
<li>
<CheckboxControl
label={ __(
'Save delivery confirmation photos',
'woocommerce-payments'
) }
checked={ true }
disabled={ true }
onChange={ noop }
/>
<p className="description">
{ __(
'Automatically saves delivery confirmation photos to order metadata',
'woocommerce-payments'
) }
</p>
</li>
</ul>
</div>
</CardBody>
</Card>
);
};

export default DisputeDefenseToolkit;
149 changes: 149 additions & 0 deletions client/components/dispute-defense-toolkit/pre-fill-evidence.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/** @format **/

/**
* External dependencies
*/
import React from 'react';
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';

/**
* Internal dependencies
*/
import { recordEvent } from 'tracks';

interface PreFillEvidenceProps {
disputeReason: string;
productType: string;
onPreFill: ( evidence: Record< string, string > ) => void;
}

/**
* Component that provides pre-filled evidence data based on dispute reason and product type
*/
const PreFillEvidence: React.FC< PreFillEvidenceProps > = ( {
disputeReason,
productType,
onPreFill,
} ) => {
// Hard-coded evidence data for demonstration purposes
const getPreFilledEvidence = () => {
// General evidence that applies to all dispute types
const generalEvidence: Record< string, string > = {
product_description:
'Premium digital subscription service with monthly billing',
customer_name: 'John Doe',
customer_email_address: '[email protected]',
billing_address: '123 Main St, Anytown, CA 90210',
customer_purchase_ip: '192.168.1.1',
customer_communication:
'Customer confirmed receipt of service via email on 2023-05-15',
};

// Evidence specific to dispute reason and product type
let specificEvidence: Record< string, string > = {};

// Handle different dispute reasons
switch ( disputeReason ) {
case 'fraudulent':
if ( productType === 'digital_product_or_service' ) {
specificEvidence = {
access_activity_log:
'Customer accessed the service on 2023-05-10, 2023-05-12, and 2023-05-15',
};
} else if ( productType === 'physical_product' ) {
specificEvidence = {
shipping_carrier: 'USPS',
shipping_tracking_number: '9400100897654321',
shipping_date: '2023-05-05',
shipping_address: '123 Main St, Anytown, CA 90210',
};
} else if ( productType === 'offline_service' ) {
specificEvidence = {
service_date: '2023-05-10',
service_documentation:
'Service was provided as scheduled',
};
}
break;
case 'product_not_received':
if ( productType === 'physical_product' ) {
specificEvidence = {
shipping_carrier: 'USPS',
shipping_tracking_number: '9400100897654321',
shipping_date: '2023-05-05',
shipping_address: '123 Main St, Anytown, CA 90210',
};
} else if ( productType === 'digital_product_or_service' ) {
specificEvidence = {
access_activity_log:
'Customer accessed the service on 2023-05-10, 2023-05-12, and 2023-05-15',
};
} else if ( productType === 'offline_service' ) {
specificEvidence = {
service_date: '2023-05-10',
service_documentation:
'Service was provided as scheduled',
};
}
break;
case 'credit_not_processed':
specificEvidence = {
refund_policy:
'Our refund policy allows for refunds within 30 days of purchase',
refund_policy_disclosure:
'The refund policy was clearly displayed during checkout',
refund_refusal_explanation:
'The customer is not entitled to a refund as they have used the service for more than 30 days',
};
break;
case 'duplicate':
specificEvidence = {
duplicate_charge_id: 'ch_1234567890',
duplicate_charge_explanation:
'This is a separate charge for a different product',
};
break;
case 'subscription_canceled':
specificEvidence = {
cancellation_policy:
'Our cancellation policy requires 30 days notice',
cancellation_policy_disclosure:
'The cancellation policy was clearly displayed during checkout',
cancellation_rebuttal:
'The customer did not provide the required 30 days notice for cancellation',
};
break;
default:
// For unrecognized or other dispute reasons
specificEvidence = {
uncategorized_text:
'This transaction was legitimate and the customer received the product/service as described',
};
}

return { ...generalEvidence, ...specificEvidence };
};

const handlePreFill = () => {
const preFilledEvidence = getPreFilledEvidence();
onPreFill( preFilledEvidence );

recordEvent( 'wcpay_dispute_prefill_evidence_clicked', {
dispute_reason: disputeReason,
product_type: productType,
} );
};

return (
<Button
variant="secondary"
onClick={ handlePreFill }
className="dispute-defense-toolkit__prefill-button"
>
{ __( 'Pre-fill evidence form', 'woocommerce-payments' ) }
</Button>
);
};

export default PreFillEvidence;
29 changes: 29 additions & 0 deletions client/components/dispute-defense-toolkit/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.dispute-defense-toolkit {
margin: 16px 0;

.toolkit-section {
h3 {
margin-bottom: 16px;
}
}

.toolkit-features {
list-style: none;
margin: 0;
padding: 0;

li {
margin-bottom: 16px;

&:last-child {
margin-bottom: 0;
}
}

.description {
margin: 4px 0 0 24px;
color: #757575;
font-size: 13px;
}
}
}
Loading
Loading