Skip to content

Commit 56f93b0

Browse files
uds5501kushthedude
authored andcommitted
feat: Design PayTM gateway modals (#3447)
* feat: add paytm checkout modals * feat: add validations to modals
1 parent c9f3868 commit 56f93b0

File tree

6 files changed

+129
-0
lines changed

6 files changed

+129
-0
lines changed

app/components/modals/paytm-otp.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import ModalBase from 'open-event-frontend/components/modals/modal-base';
2+
import FormMixin from 'open-event-frontend/mixins/form';
3+
4+
export default class extends ModalBase.extend(FormMixin) {
5+
isSmall = true;
6+
7+
getValidationRules() {
8+
return {
9+
inline : true,
10+
delay : false,
11+
on : 'blur',
12+
fields : {
13+
otp: {
14+
identifier : 'otp',
15+
rules : [
16+
{
17+
type : 'empty',
18+
prompt : this.l10n.t('Please enter the OTP')
19+
}
20+
]
21+
}
22+
}
23+
};
24+
}
25+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import ModalBase from 'open-event-frontend/components/modals/modal-base';
2+
import FormMixin from 'open-event-frontend/mixins/form';
3+
import { validPhoneNumber } from 'open-event-frontend/utils/validators';
4+
5+
export default class extends ModalBase.extend(FormMixin) {
6+
isSmall = true;
7+
isWalletSelected = false;
8+
9+
getValidationRules() {
10+
return {
11+
inline : true,
12+
delay : false,
13+
on : 'blur',
14+
fields : {
15+
mobileNumber: {
16+
identifier : 'mobile_number',
17+
rules : [
18+
{
19+
type : 'empty',
20+
prompt : this.l10n.t('Please enter the Mobile Number')
21+
},
22+
{
23+
type : 'regExp',
24+
value : validPhoneNumber,
25+
prompt : this.l10n.t('Please enter a valid mobile number')
26+
}
27+
]
28+
}
29+
}
30+
};
31+
}
32+
33+
}

app/controllers/orders/pending.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ export default Controller.extend({
5151
this.notify.error(this.l10n.t(error.error));
5252
}
5353
},
54+
openPaytmModal() {
55+
// Model controller for PaytmModal
56+
this.setProperties({
57+
'isPaytmModalOpen': true
58+
});
59+
},
60+
61+
openOTPController() {
62+
// Modal controller for OTP step
63+
this.setProperties({
64+
'isPaytmModalOpen' : false,
65+
'isOTPModalOpen' : true
66+
});
67+
},
5468
processStripeToken(token) {
5569
// Send this token to server to process payment
5670
this.set('isLoading', true);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div class="header">
2+
{{t 'Amount to be paid:'}} {{currency-symbol currency}} {{amount}}
3+
</div>
4+
5+
<div class="content">
6+
{{t 'Enter OTP sent to mobile number'}}
7+
<form class="ui form" autocomplete="off">
8+
<div class="field">
9+
{{input type='number' id='otp' value=otp required=true}}
10+
</div>
11+
</form>
12+
</div>
13+
<div class="actions">
14+
<button type="button" class="ui black button" {{action 'close'}}>
15+
{{t 'Cancel'}}
16+
</button>
17+
<button class="ui green button">
18+
{{t 'Verify'}}
19+
</button>
20+
</div>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="header">
2+
{{t 'Amount to be paid:'}} {{currency-symbol currency}} {{amount}}
3+
</div>
4+
5+
<div class="content">
6+
<div class="muted small text">
7+
{{t 'Select an option to pay'}}
8+
</div>
9+
<form class="ui form" autocomplete="off" {{action 'openOTPController' on='submit' preventDefault=true}}>
10+
<div class="field">
11+
{{ui-radio name='payment_mode' value='paytm' onChange=(action (mut isWalletSelected))}}
12+
{{t 'Paytm Wallet'}}<img src="/images/payment-logos/paytm.png" alt="paytm">
13+
</div>
14+
{{#if isWalletSelected}}
15+
<div class="field">
16+
<div class="label">
17+
{{t 'Please enter your Paytm registered Mobile Number to continue'}}
18+
</div>
19+
{{input type='number' id='mobile_number' value=mobileNumber required=true}}
20+
</div>
21+
{{/if}}
22+
</form>
23+
</div>
24+
25+
<div class="actions">
26+
<button type="button" class="ui black button" {{action 'close'}}>
27+
{{t 'Cancel'}}
28+
</button>
29+
<button {{action openOTPController}} class="ui green button" disabled={{not isWalletSelected}}>
30+
{{t 'Proceed'}}
31+
</button>
32+
</div>

app/templates/orders/pending.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
</form>
6262
</div>
6363
{{/if}}
64+
{{#if isPaytm}}
65+
<button class="ui button primary" {{action "openPaytmModal"}}>{{t 'Pay with PayTM'}}</button>
66+
{{/if}}
6467
{{#if isAliPay}}
6568
<button class="ui button primary" {{action alipayCheckout model.order.identifier}}>{{t 'Pay with AliPay'}}</button>
6669
{{/if}}
@@ -77,3 +80,5 @@
7780
</div>
7881
</div>
7982
</div>
83+
{{modals/paytm-payment-options isLoading=isLoading isOpen=isPaytmModalOpen amount=model.order.amount currency=model.order.event.paymentCurrency openOTPController=(action 'openOTPController')}}
84+
{{modals/paytm-otp isLoading=isLoading isOpen=isOTPModalOpen amount=model.order.amount currency=model.order.event.paymentCurrency}}

0 commit comments

Comments
 (0)