Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7e4ab9a
WIP: New real account signup flow
ali-fs Mar 17, 2021
6cfaa56
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Mar 17, 2021
b435353
eslint fix
ali-fs Mar 17, 2021
40c2ec1
responsive form-progress
ali-fs Mar 17, 2021
0b507d4
eslint fix
ali-fs Mar 17, 2021
461ddbb
fix required rules and list of available currencies
ali-fs Mar 17, 2021
7bc8624
fix some default values and requirement rules
ali-fs Mar 18, 2021
ba20c30
Merge branch 'master' into real-account-signup-flow
ali-fs Mar 18, 2021
af2db7a
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Mar 18, 2021
b2fab4e
minor bugfix
ali-fs Mar 18, 2021
23cf654
Added websocket, UI fixes, content changes
akmal-deriv Apr 6, 2021
53e9801
Merge pull request #1 from akmal-binary/real-account-signup
ali-fs Apr 6, 2021
b089057
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Apr 6, 2021
539c212
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Apr 15, 2021
11d22e4
add T&C and minor fixes
ali-fs Apr 15, 2021
f8a256e
add T&C and minor fixes
ali-fs Apr 18, 2021
cab1ca6
Merge branch 'real-account-signup-flow' of github.com:ali-fs/binary-s…
ali-fs Apr 18, 2021
79284aa
css responsive bugfix
ali-fs Apr 19, 2021
7161c9c
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Apr 20, 2021
c87e3f8
minor bugfix
ali-fs Apr 20, 2021
b3d7815
minor bugfix
ali-fs Apr 25, 2021
9ff5bd6
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Apr 25, 2021
c58ccff
Merge branch 'master' into real-account-signup-flow
ali-fs Apr 25, 2021
43af23c
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Apr 26, 2021
56dcfda
minor bugfixs
ali-fs Apr 26, 2021
d6fe48d
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Apr 26, 2021
815ae08
fix currency list bug
ali-fs Apr 26, 2021
01328d6
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs May 3, 2021
eb65f18
mobile view bugfix
ali-fs May 3, 2021
ec8c1c5
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs May 6, 2021
8d214c5
mobile view bugfix
ali-fs May 6, 2021
c049272
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs May 9, 2021
3399b6a
minor css bugfix
ali-fs May 9, 2021
4af3aa8
minor css bugfix
ali-fs May 9, 2021
ad68651
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs May 10, 2021
5f59676
fix center select and minor css fix
ali-fs May 10, 2021
f6bb2af
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Jul 26, 2021
69640e6
exclude special countries form new signup flow
ali-fs Aug 1, 2021
15e8d5c
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Aug 1, 2021
675a222
update the list of excluded countries
ali-fs Aug 2, 2021
5fde212
minor bugfixes
ali-fs Aug 11, 2021
3b200b9
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Aug 11, 2021
19e0d6d
minor bugfixes
ali-fs Aug 23, 2021
1678104
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Aug 23, 2021
afe31db
change some text for CW
ali-fs Aug 26, 2021
7e9fa7c
revert some text changes duo to new design
ali-fs Aug 29, 2021
b4cd53d
eslint fix
ali-fs Aug 29, 2021
42d6159
Merge branch 'master' of github.com:binary-com/binary-static into rea…
ali-fs Sep 7, 2021
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
4 changes: 3 additions & 1 deletion scripts/config/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ module.exports = [

['trading', 'app/trade/trading', 'default', 'SmartTrader'],

// TODO: Remove 'maltainvestws' and 'realws' after completely change the signup flow for all countries as these only being used for exceptional countries.
['new_account/maltainvestws', 'app/new_account/financial', 'default', 'Financial Account Opening'],
['new_account/realws', 'app/new_account/real', 'default', 'Real Money Account Opening'],
['new_account/real_account', 'app/new_account/real_account', 'default', 'Real Account Opening'],
['new_account/virtualws', 'app/new_account/virtual', 'default', 'Create New Demo Account'],
['new_account/welcome', 'app/new_account/welcome_page', 'default', 'Welcome to Binary.com'],
['new_account/welcome_onboarding', 'app/new_account/welcome_onboarding', 'default', 'Welcome to Binary.com'],
['new_account/welcome_onboarding', 'app/new_account/welcome_onboarding', 'default', 'Welcome to Binary.com'],

['resources', 'app/resources/index', 'default', 'Resources'],
['resources/asset_indexws', 'app/resources/asset_index', 'full_width', 'Asset Index'],
Expand Down
2 changes: 1 addition & 1 deletion src/javascript/_common/check_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const checkPassword = (password_selector, should_show_error) => {
const removeCheck = (password_selector, should_reset_meter) => {
const el_password = document.querySelector(password_selector);
const el_meter_bar = el_password.parentNode.querySelector('.password--meter-fill');
const password_value = el_password.value.trim();
const password_value = (el_password.value || '').trim();
const el_feedback_message = el_password.parentNode.querySelector('.password--message');
if (el_meter_bar && password_value.length < 1 || should_reset_meter) {
el_meter_bar.style.transform = 'scale(0, 1)';
Expand Down
5 changes: 5 additions & 0 deletions src/javascript/app/base/binary_pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ const Accounts = require('../pages/user/accounts');
const LostPassword = require('../pages/user/lost_password');
const MetaTrader = require('../pages/user/metatrader/metatrader');
const TypesOfAccounts = require('../pages/user/metatrader/types_of_accounts');
// TODO: Remove 'FinancialAccOpening' and 'RealAccOpening' after completely change the signup flow for all countries
const FinancialAccOpening = require('../pages/user/new_account/financial_acc_opening');
const RealAccOpening = require('../pages/user/new_account/real_acc_opening');
const RealAccountOpening = require('../pages/user/new_account/real_account_opening');
const VirtualAccOpening = require('../pages/user/new_account/virtual_acc_opening');
const WelcomePage = require('../pages/user/new_account/welcome_page');
const WelcomePageOnboarding = require('../pages/user/new_account/welcome_onboarding');
Expand Down Expand Up @@ -109,6 +111,7 @@ const pages_config = {
logged_inws : { module: LoggedInHandler },
lost_passwordws : { module: LostPassword, not_authenticated: true },
malta : { module: StaticPages.Locations },
// TODO: Remove 'maltainvestws' after completely change the signup flow for all countries
maltainvestws : { module: FinancialAccOpening, is_authenticated: true },
market_timesws : { module: TradingTimesUI, no_mf: true, no_blocked_country: true },
metals : { module: GetStarted.Metals },
Expand All @@ -120,7 +123,9 @@ const pages_config = {
portfoliows : { module: Portfolio, is_authenticated: true, needs_currency: true },
professional : { module: professionalClient, is_authenticated: true, only_real: true },
profit_tablews : { module: ProfitTable, is_authenticated: true, needs_currency: true },
// TODO: Remove 'realws' after completely change the signup flow for all countries
realws : { module: RealAccOpening, is_authenticated: true },
real_account : { module: RealAccountOpening, is_authenticated: true },
redirect : { module: Redirect },
regulation : { module: Regulation },
reset_passwordws : { module: ResetPassword },
Expand Down
23 changes: 12 additions & 11 deletions src/javascript/app/base/header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const BinaryPjax = require('./binary_pjax');
const Client = require('./client');
const BinarySocket = require('./socket');
const showHidePulser = require('../common/account_opening').showHidePulser;
const getCurrencyDisplayCode = require('../common/currency').getCurrencyDisplayCode;
const getLandingCompanyValue = require('../../_common/base/client_base').getLandingCompanyValue;
const isAuthenticationAllowed = require('../../_common/base/client_base').isAuthenticationAllowed;
Expand Down Expand Up @@ -136,20 +135,20 @@ const Header = (() => {
return;
}

const showUpgrade = (url, localized_text) => {
const showUpgrade = (url, params, localized_text) => {
applyToAllElements(upgrade_msg, (el) => {
el.setVisibility(1);
applyToAllElements('a', (ele) => {
ele.html(createElement('span', { text: localized_text })).setVisibility(1).setAttribute('href', Url.urlFor(url));
ele.html(createElement('span', { text: localized_text })).setVisibility(1).setAttribute('href', Url.urlFor(url, params));
}, '', el);
});
};

const showUpgradeBtn = (url, localized_text) => {
const showUpgradeBtn = (url, params, localized_text) => {
applyToAllElements(upgrade_msg, (el) => {
el.setVisibility(1);
applyToAllElements('a.button', (ele) => {
ele.html(createElement('span', { text: localized_text })).setVisibility(1).setAttribute('href', Url.urlFor(url));
ele.html(createElement('span', { text: localized_text })).setVisibility(1).setAttribute('href', Url.urlFor(url, params));
}, '', el);
});
};
Expand Down Expand Up @@ -186,9 +185,9 @@ const Header = (() => {
if (show_upgrade_msg) {
const upgrade_url = upgrade_info.can_upgrade_to.length > 1
? 'user/accounts'
: Object.values(upgrade_info.upgrade_links)[0];
showUpgrade(upgrade_url, upgrade_link_txt);
showUpgradeBtn(upgrade_url, upgrade_btn_txt);
: 'new_account/real_account';
showUpgrade(upgrade_url, `account_type=${upgrade_info.can_upgrade_to[0]}`, upgrade_link_txt);
showUpgradeBtn(upgrade_url, `account_type=${upgrade_info.can_upgrade_to[0]}`, upgrade_btn_txt);
} else {
applyToAllElements(upgrade_msg, (el) => {
applyToAllElements('a', (ele) => {
Expand All @@ -203,9 +202,9 @@ const Header = (() => {
getElementById('virtual-wrapper').setVisibility(0);
const upgrade_url = upgrade_info.can_upgrade_to.length > 1
? 'user/accounts'
: Object.values(upgrade_info.upgrade_links)[0];
showUpgrade(upgrade_url, upgrade_link_txt);
showUpgradeBtn(upgrade_url, upgrade_btn_txt);
: 'new_account/real_account';
showUpgrade(upgrade_url, `account_type=${upgrade_info.can_upgrade_to[0]}`, upgrade_link_txt);
showUpgradeBtn(upgrade_url, `account_type=${upgrade_info.can_upgrade_to[0]}`, upgrade_btn_txt);

if (/new_account/.test(window.location.href)) {
showHidePulser(0);
Expand All @@ -217,6 +216,8 @@ const Header = (() => {
});
};

const showHidePulser = (should_show) => { $('.upgrademessage').children('a').setVisibility(should_show); };

const showHideNewAccount = (upgrade_info) => {
if (upgrade_info.can_upgrade || upgrade_info.can_open_multi) {
changeAccountsText(1, localize('Create Account'));
Expand Down
2 changes: 1 addition & 1 deletion src/javascript/app/common/__tests__/account_opening.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('AccountOpening', () => {
expect(AccountOpening.redirectAccount()).to.eq(1);
});
it('will not redirect client who is already on maltainvest account opening page again', () => {
setURL(`${Url.websiteUrl()}en/maltainvestws.html`);
setURL(`${Url.websiteUrl()}en/new_account/real_account.html?account_type=maltainvest`);
expect(AccountOpening.redirectAccount()).to.eq(0);
});
it('will redirect client who cannot upgrade their account to the previous page', () => {
Expand Down
145 changes: 123 additions & 22 deletions src/javascript/app/common/account_opening.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ const moment = require('moment');
const generateBirthDate = require('./attach_dom/birth_date_picker');
const FormManager = require('./form_manager');
const BinaryPjax = require('../base/binary_pjax');
const Client = require('../base/client');
const Header = require('../base/header');
const BinarySocket = require('../base/socket');
const Client = require('../base/client');
const professionalClient = require('../pages/user/account/settings/professional_client');
const param = require('../../_common/url').param;
const ClientBase = require('../../_common/base/client_base');
const CommonFunctions = require('../../_common/common_functions');
const getElementById = require('../../_common/common_functions').getElementById;
const localize = require('../../_common/localize').localize;
const State = require('../../_common/storage').State;
const toISOFormat = require('../../_common/string_util').toISOFormat;
Expand All @@ -16,14 +20,47 @@ const urlFor = require('../../_common/url').urlFor;
const getPropertyValue = require('../../_common/utility').getPropertyValue;

const AccountOpening = (() => {

const excluded_countries = ['im', 'au', 'sg', 'no'];

const getSinupPageLink = (upgrade_info, account_type) => {
const get_settings = State.getResponse('get_settings');
const country_code = get_settings.country_code;
if (excluded_countries.includes(country_code)) { // old flow
return urlFor(upgrade_info.upgrade_links[account_type]);
} // new flow
return urlFor('/new_account/real_account', `account_type=${account_type}`);

};

const redirectAccount = () => {
const upgrade_info = Client.getUpgradeInfo();

if (!upgrade_info.can_upgrade) {
BinaryPjax.loadPreviousUrl();
return -1;
}
const country_code = State.getResponse('get_settings').country_code;

if (window.location.pathname.includes('/real_account')) { // new signup flow
if (excluded_countries.includes(country_code)) {
BinaryPjax.load('user/accounts');
}
const real_account_signup_target = param('account_type');
const is_in_correct_path = upgrade_info.can_upgrade_to.some(lc => lc === real_account_signup_target);
if (!is_in_correct_path) {
const upgradable_accounts_count = upgrade_info.can_upgrade_to.length;
if (upgradable_accounts_count > 1) {
BinaryPjax.load('user/accounts');
} else if (upgradable_accounts_count === 1) {
window.location.replace(urlFor('/new_account/real_account', `account_type=${upgrade_info.can_upgrade_to[0]}`));
}
return 1;
}
return 0;
} // old signup flow (only for excluded countries)
if (!excluded_countries.includes(country_code)) {
BinaryPjax.load('user/accounts');
}
if (!upgrade_info.is_current_path) {
const upgradable_accounts_count = Object.keys(upgrade_info.upgrade_links).length;
if (upgradable_accounts_count > 1) {
Expand All @@ -34,6 +71,17 @@ const AccountOpening = (() => {
return 1;
}
return 0;

};

const showResponseError = (response) => {
getElementById('loading').setVisibility(0);
getElementById('real_account_wrapper').setVisibility(1);
const $notice_box = $('#client_message').find('.notice-msg');
$('#submit-message').empty();
$notice_box.text(response.msg_type === 'sanity_check' ? localize('There was some invalid character in an input field.') : response.error.message).end()
.setVisibility(1);
$.scrollTo($notice_box, 500, { offset: -150 });
};

const populateForm = (form_id, getValidations, is_financial) => {
Expand Down Expand Up @@ -205,21 +253,6 @@ const AccountOpening = (() => {
}
};

const handleTaxIdentificationNumber = () => {
BinarySocket.wait('get_settings').then((response) => {
const tax_identification_number = response.get_settings.tax_identification_number;
if (tax_identification_number) {
$('#lbl_tax_identification_number').text(tax_identification_number);
CommonFunctions.getElementById('row_lbl_tax_identification_number').setVisibility(1);
$('#tax_identification_number')
.val(tax_identification_number) // Set value for validation
.attr({ 'data-force': true, 'data-value': tax_identification_number });
} else {
CommonFunctions.getElementById('row_tax_identification_number').setVisibility(1);
}
});
};

const handleState = (states_list, form_id, getValidations) => {
const address_state_id = '#address_state';
BinarySocket.wait('get_settings').then((response) => {
Expand Down Expand Up @@ -256,6 +289,7 @@ const AccountOpening = (() => {
}
});
};

const handleNewAccount = (response, message_type) => {
if (response.error) {
const error_message = response.error.message;
Expand All @@ -275,6 +309,21 @@ const AccountOpening = (() => {
}
};

const handleTaxIdentificationNumber = () => {
BinarySocket.wait('get_settings').then((response) => {
const tax_identification_number = response.get_settings.tax_identification_number;
if (tax_identification_number) {
$('#lbl_tax_identification_number').text(tax_identification_number);
CommonFunctions.getElementById('row_lbl_tax_identification_number').setVisibility(1);
$('#tax_identification_number')
.val(tax_identification_number) // Set value for validation
.attr({ 'data-force': true, 'data-value': tax_identification_number });
} else {
CommonFunctions.getElementById('row_tax_identification_number').setVisibility(1);
}
});
};

const commonValidations = () => {
const residence = Client.get('residence');
const req = [
Expand Down Expand Up @@ -313,7 +362,7 @@ const AccountOpening = (() => {
id = $(this).attr('id');
if (!/^(tnc|address_state|chk_professional|chk_tax_id|citizen)$/.test(id)) {
validation = { selector: `#${id}`, validations: ['req'] };
if (id === 'not_pep') {
if (id === 'pep_declaration') {
validation.exclude_request = 1;
validation.validations = [['req', { message: localize('Please confirm that you are not a politically exposed person.') }]];
}
Expand All @@ -323,6 +372,54 @@ const AccountOpening = (() => {
return validations;
};

const setCurrencyForFinancialAccount = async (currency_to_set) => {
sessionStorage.removeItem('new_financial_account_set_currency');
await BinarySocket.wait('authorize');
const response = await BinarySocket.send({ set_account_currency: currency_to_set });
if (response.error) {
showResponseError(response);
} else {
Client.set('currency', currency_to_set);
BinarySocket.send({ balance: 1 });
BinarySocket.send({ payout_currencies: 1 }, { forced: true });
Header.displayAccountStatus();
setTimeout(() => { window.location.replace(urlFor('user/set-currency') || urlFor('trading')); }, 500); // need to redirect not using pjax
}
};

const createNewAccount = async (account_details, submit_button) => {
FormManager.disableButton(submit_button);
const is_maltainvest_account = !!account_details.new_account_maltainvest;
account_details.client_type = $('#chk_professional').is(':checked') ? 'professional' : 'retail';
delete account_details.tax_identification_confirm;
delete account_details.tnc;
delete account_details.pep_declaration;
delete account_details.fs_professional;

// Set currency after account is created for Maltainvest only
if (is_maltainvest_account && account_details.currency) {
const currency = account_details.currency;
delete account_details.currency;
sessionStorage.setItem('new_financial_account_set_currency', currency);
}

const response = await BinarySocket.send(account_details);
if (response.error) {
if (response.error.code === 'show risk disclaimer') return true;
showResponseError(response);
} else {
localStorage.setItem('is_new_account', 1);
const email = Client.get('email');
const loginid = response[is_maltainvest_account ? 'new_account_maltainvest' : 'new_account_real'].client_id;
const token = response[is_maltainvest_account ? 'new_account_maltainvest' : 'new_account_real'].oauth_token;
ClientBase.setNewAccount({ email, loginid, token });
if (is_maltainvest_account) window.location.reload();
else window.location.replace(urlFor('user/set-currency'));
}
FormManager.enableButton(submit_button);
return false;
};

const showHidePulser = (should_show) => { $('.upgrademessage').children('a').setVisibility(should_show); };

const registerPepToggle = () => {
Expand All @@ -334,13 +431,17 @@ const AccountOpening = (() => {
};

return {
redirectAccount,
populateForm,
handleNewAccount,
commonValidations,
createNewAccount,
excluded_countries,
getSinupPageLink,
handleNewAccount,
populateForm,
redirectAccount,
registerPepToggle,
selectCheckboxValidation,
setCurrencyForFinancialAccount,
showHidePulser,
registerPepToggle,
};
})();

Expand Down
Loading