Skip to content

Commit

Permalink
Ameerul /Bug 66413 Deriv P2P- Incorrect message displayed for High Ri…
Browse files Browse the repository at this point in the history
…sk client (binary-com#6709)

* fixed logic for displaying correct message and checklist if user is high risk

* fixed setIsHighRisk naming

* removed check for fully authed, no fa, and added if they are high risk, set block to true

* if user is high risk and blocked, prioritise blocked overall

* fixed blocked message issue when user is not authenticated

* chore: changed logic for authenticated and no fa users
  • Loading branch information
ameerul-deriv committed May 2, 2023
1 parent 7cca6b5 commit c46a37b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 43 deletions.
2 changes: 1 addition & 1 deletion packages/p2p/src/components/app-content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const AppContent = ({ order_id }) => {
return <Loading is_fullscreen={false} />;
}

if (general_store.should_show_dp2p_blocked || general_store.is_p2p_blocked_for_pa) {
if (general_store.should_show_dp2p_blocked) {
return <Dp2pBlocked />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Dp2pBlockedChecklist = () => {
const { general_store } = useStores();
const history = useHistory();

if (general_store.is_high_risk_fully_authed_without_fa && !general_store.is_p2p_blocked_for_pa) {
if (general_store.is_high_risk && !general_store.is_blocked) {
const checklist_items = [
{
content: localize('Complete the financial assessment form'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,27 @@ import { Localize } from '../i18next';
const Dp2pBlockedDescription = () => {
const { general_store } = useStores();

let blocked_description;

if (general_store.is_high_risk_fully_authed_without_fa) {
const getBlockedDescription = () => {
if (general_store.is_p2p_blocked_for_pa) {
blocked_description = (
return (
<Localize i18n_default_text='P2P transactions are locked. This feature is not available for payment agents.' />
);
} else {
blocked_description = (
<Localize i18n_default_text='To enable this feature you must complete the following:' />
);
} else if (general_store.is_high_risk && !general_store.is_blocked) {
return <Localize i18n_default_text='To enable this feature you must complete the following:' />;
}
} else if (general_store.is_p2p_blocked_for_pa) {
blocked_description = (
<Localize i18n_default_text='P2P transactions are locked. This feature is not available for payment agents.' />
);
} else {
blocked_description = (
return (
<Localize
i18n_default_text='Please use <0>live chat</0> to contact our Customer Support team for help.'
components={[
<span key={0} className='link link--orange' onClick={() => window.LC_API.open_chat_window()} />,
]}
/>
);
}
};

return (
<Text className='dp2p-blocked__description' align='center' color='prominent' line_height='m' size='xs'>
{blocked_description}
{getBlockedDescription()}
</Text>
);
};
Expand Down
50 changes: 25 additions & 25 deletions packages/p2p/src/stores/general-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class GeneralStore extends BaseStore {
is_blocked = false;
is_block_unblock_user_loading = false;
is_block_user_modal_open = false;
is_high_risk_fully_authed_without_fa = false;
is_high_risk = false;
is_listed = false;
is_loading = false;
is_modal_open = false;
Expand All @@ -51,6 +51,7 @@ export default class GeneralStore extends BaseStore {
should_show_popup = false;
user_blocked_count = 0;
user_blocked_until = null;
is_modal_open = false;

list_item_limit = isMobile() ? 10 : 50;
path = {
Expand Down Expand Up @@ -91,6 +92,7 @@ export default class GeneralStore extends BaseStore {
is_blocked: observable,
is_block_unblock_user_loading: observable,
is_block_user_modal_open: observable,
is_high_risk: observable,
is_listed: observable,
is_loading: observable,
is_p2p_blocked_for_pa: observable,
Expand All @@ -107,7 +109,6 @@ export default class GeneralStore extends BaseStore {
should_show_popup: observable,
user_blocked_count: observable,
user_blocked_until: observable,
is_high_risk_fully_authed_without_fa: observable,
is_modal_open: observable,
blocked_until_date_time: computed,
is_active_tab: computed,
Expand Down Expand Up @@ -141,7 +142,7 @@ export default class GeneralStore extends BaseStore {
setInactiveNotificationCount: action.bound,
setIsAdvertiser: action.bound,
setIsBlocked: action.bound,
setIsHighRiskFullyAuthedWithoutFa: action.bound,
setIsHighRisk: action.bound,
setIsListed: action.bound,
setIsLoading: action.bound,
setIsP2pBlockedForPa: action.bound,
Expand Down Expand Up @@ -191,7 +192,7 @@ export default class GeneralStore extends BaseStore {
}

get should_show_dp2p_blocked() {
return this.is_blocked || this.is_high_risk_fully_authed_without_fa;
return this.is_blocked || this.is_high_risk || this.is_p2p_blocked_for_pa;
}

blockUnblockUser(should_block, advertiser_id, should_set_is_counterparty_blocked = true) {
Expand Down Expand Up @@ -419,7 +420,7 @@ export default class GeneralStore extends BaseStore {
onMount() {
this.setIsLoading(true);
this.setIsBlocked(false);
this.setIsHighRiskFullyAuthedWithoutFa(false);
this.setIsHighRisk(false);
this.setIsP2pBlockedForPa(false);

this.disposeUserBarredReaction = reaction(
Expand All @@ -438,37 +439,36 @@ export default class GeneralStore extends BaseStore {
requestWS({ get_account_status: 1 }).then(({ error, get_account_status }) => {
const hasStatuses = statuses => statuses.every(status => get_account_status.status.includes(status));

const is_authenticated = hasStatuses(['authenticated']);
const is_blocked_for_pa = hasStatuses(['p2p_blocked_for_pa']);
const is_fa_not_complete = hasStatuses(['financial_assessment_not_complete']);

if (error) {
this.setIsHighRiskFullyAuthedWithoutFa(false);
this.setIsHighRisk(false);
this.setIsBlocked(false);
this.setIsP2pBlockedForPa(false);
} else if (get_account_status.p2p_status === 'perm_ban') {
this.setIsBlocked(true);
} else if (get_account_status.risk_classification === 'high') {
const is_cashier_locked = hasStatuses(['cashier_locked']);

const is_fully_authenticated = hasStatuses(['age_verification', 'authenticated']);
const is_not_fully_authenticated = !hasStatuses(['age_verification', 'authenticated']);

const is_fully_authed_but_poi_expired = hasStatuses(['authenticated', 'document_expired']);
const is_fully_authed_but_needs_fa =
is_fully_authenticated && hasStatuses(['financial_assessment_not_complete']);

const is_not_fully_authenticated_and_fa_not_completed =
is_not_fully_authenticated && hasStatuses(['financial_assessment_not_complete']);

if (is_fully_authed_but_needs_fa) {
// First priority: Send user to Financial Assessment if they have to submit it.
this.setIsHighRiskFullyAuthedWithoutFa(true);
} else if (
is_cashier_locked ||
is_not_fully_authenticated ||
is_fully_authed_but_poi_expired ||
is_not_fully_authenticated_and_fa_not_completed
is_not_fully_authenticated && is_fa_not_complete;

if (
is_authenticated &&
(is_cashier_locked ||
is_not_fully_authenticated ||
is_fully_authed_but_poi_expired ||
is_not_fully_authenticated_and_fa_not_completed)
) {
// Second priority: If user is blocked, don't bother asking them to submit FA.
this.setIsBlocked(true);
}

if (!is_authenticated && !is_fa_not_complete) this.setIsBlocked(true);

if (is_fa_not_complete) this.setIsHighRisk(true);
}

if (is_blocked_for_pa) {
Expand Down Expand Up @@ -672,8 +672,8 @@ export default class GeneralStore extends BaseStore {
this.is_block_unblock_user_loading = is_block_unblock_user_loading;
}

setIsHighRiskFullyAuthedWithoutFa(is_high_risk_fully_authed_without_fa) {
this.is_high_risk_fully_authed_without_fa = is_high_risk_fully_authed_without_fa;
setIsHighRisk(is_high_risk) {
this.is_high_risk = is_high_risk;
}

setIsListed(is_listed) {
Expand Down

0 comments on commit c46a37b

Please sign in to comment.