Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 7fb1593

Browse files
committed
Added payment ref field to Payment Agent Withdrawal page
1 parent bbdee1d commit 7fb1593

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

src/javascript/app/pages/cashier/payment_agent_withdraw.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ const PaymentAgentWithdraw = (() => {
2222
form : '#viewForm',
2323
};
2424
const field_ids = {
25-
ddl_agents: '#ddlAgents',
26-
frm_msg : '#form-error',
27-
txt_agents: '#txtAgents',
28-
txt_amount: '#txtAmount',
25+
ddl_agents : '#ddlAgents',
26+
frm_msg : '#form-error',
27+
txt_agents : '#txtAgents',
28+
txt_amount : '#txtAmount',
29+
txt_payment_ref: '#txtPaymentRef',
2930
};
3031

3132
let $agent_error,
3233
$ddl_agents,
3334
$txt_agents,
3435
$txt_amount,
36+
$txt_payment_ref,
3537
$views,
3638
agent_name,
3739
agent_website,
@@ -91,14 +93,16 @@ const PaymentAgentWithdraw = (() => {
9193
const min = () => getAPILimit('min');
9294
const max = () => getAPILimit('max');
9395

94-
$agent_error = $('.row-agent').find('.error-msg');
95-
$txt_agents = $(field_ids.txt_agents);
96-
$txt_amount = $(field_ids.txt_amount);
96+
$agent_error = $('.row-agent').find('.error-msg');
97+
$txt_agents = $(field_ids.txt_agents);
98+
$txt_amount = $(field_ids.txt_amount);
99+
$txt_payment_ref = $(field_ids.txt_payment_ref);
97100

98101
$form.find('.wrapper-row-agent').find('label').append($('<span />', { text: '*', class: 'required_field_asterisk' }));
99102
$form.find('label[for="txtAmount"]').text(`${localize('Amount in')} ${currency}`);
100103
FormManager.init(form_id, [
101-
{ selector: field_ids.txt_amount, validations: ['req', ['number', { type: 'float', decimals: getDecimalPlaces(currency), min, max }], ['custom', { func: () => +Client.get('balance') >= +$txt_amount.val(), message: localize('Insufficient balance.') }]], request_field: 'amount' },
104+
{ selector: field_ids.txt_amount, validations: ['req', ['number', { type: 'float', decimals: getDecimalPlaces(currency), min, max }], ['custom', { func: () => +Client.get('balance') >= +$txt_amount.val(), message: localize('Insufficient balance.') }]], request_field: 'amount' },
105+
{ selector: field_ids.txt_payment_ref, validations: [['regular', { regex: /^[0-9A-Za-z .,'-]{0,30}$/, message: localize('Only letters, numbers, space, hyphen, period, comma, and apostrophe are allowed.') }], ['length', { min: 0, max: 30 }]], request_field: 'description' },
102106

103107
{ request_field: 'currency', value: currency },
104108
{ request_field: 'paymentagent_loginid', value: getPALoginID },
@@ -134,12 +138,22 @@ const PaymentAgentWithdraw = (() => {
134138
validateAmount();
135139
});
136140

141+
$txt_payment_ref.on('change', () => {
142+
validatePaymentRef();
143+
});
144+
137145
const validateAmount = () => {
138146
if ($txt_amount.val()) {
139147
Validation.validate(form_id);
140148
}
141149
};
142150

151+
const validatePaymentRef = () => {
152+
if ($txt_payment_ref.val()) {
153+
Validation.validate(form_id);
154+
}
155+
};
156+
143157
FormManager.handleSubmit({
144158
form_selector : form_id,
145159
fnc_response_handler: withdrawResponse,
@@ -175,6 +189,11 @@ const PaymentAgentWithdraw = (() => {
175189
$('#lblCurrency').text(request.currency);
176190
$('#lblAmount').text(getNumberFormat(request.amount, request.currency));
177191

192+
if (request.description) {
193+
$('#lblPaymentRef').text(request.description);
194+
$('#lblPaymentRefContainer').setVisibility(1);
195+
}
196+
178197
FormManager.init(view_ids.confirm, [
179198
{ request_field: 'paymentagent_loginid', value: request.paymentagent_loginid },
180199
{ request_field: 'amount', value: getNumberFormat(request.amount, request.currency) },

src/templates/app/cashier/paymentagent_withdraw.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ const PaymentAgentWithdraw = () => (
7878
<form id='viewConfirm' className='viewItem invisible'>
7979
<p>{it.L('Please confirm the transaction details in order to complete the transfer:')} </p>
8080

81-
<p>{it.L('Transfer to')}: <span id='lblAgentName' /><br />{it.L('Amount')}: <span id='lblCurrency' /> <span id='lblAmount' /></p>
81+
<p>
82+
{it.L('Transfer to')}: <span id='lblAgentName' />
83+
<br />
84+
{it.L('Amount')}: <span id='lblCurrency' /> <span id='lblAmount' />
85+
<br />
86+
<span id='lblPaymentRefContainer' className='invisible'>
87+
{it.L('Payment reference')}: <span id='lblPaymentRef' />
88+
</span>
89+
</p>
8290

8391
<SubmitButton
8492
custom_btn_id='btnBack'
@@ -114,6 +122,10 @@ const PaymentAgentWithdraw = () => (
114122
<SeparatorLine className='gr-padding-10' show_mobile />
115123
</div>
116124
<FormRow label={it.L('Amount')} id='txtAmount' type='text' />
125+
<div className='gr-9 gr-centered'>
126+
<SeparatorLine className='gr-padding-10' show_mobile />
127+
</div>
128+
<FormRow label={it.L('Optional: Type in your payment reference.')} id='txtPaymentRef' type='text' />
117129
<p id='form-error' className='error-msg center-text invisible' />
118130
<SubmitButton msg_id='withdrawFormMessage' type='submit' text={it.L('Submit')} />
119131
<div className='gr-8 gr-centered gr-padding-20'>

0 commit comments

Comments
 (0)