Skip to content
Merged
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
51 changes: 42 additions & 9 deletions app/controllers/orders/pending.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,53 @@ export default Controller.extend({
this.notify.error(this.l10n.t(error.error));
}
},
openPaytmModal() {
async openPaytmModal() {
// Model controller for PaytmModal
this.setProperties({
'isPaytmModalOpen': true
});
try {
const res = await this.loader.post(`orders/${this.model.order.identifier}/paytm/initiate-transaction`);
this.setProperties({
'isPaytmModalOpen' : true,
'txnToken' : res.body.txnToken
});
} catch (error) {
this.notify.error(this.l10n.t(error.error));
}
},

openOTPController() {
async openOTPController(mobileNumber) {
// Modal controller for OTP step
this.setProperties({
'isPaytmModalOpen' : false,
'isOTPModalOpen' : true
});
try {
const payload = {
'data': {
'phone': mobileNumber
}
};
await this.loader.post(`orders/${this.model.order.identifier}/paytm/send_otp/${this.txnToken}`, payload);
this.setProperties({
'isPaytmModalOpen' : false,
'isOTPModalOpen' : true
});
} catch (error) {
this.notify.error(this.l10n.t(error.error));
}
},

async verifyOtp(OTP) {
try {
const payload = {
'data': {
'otp': OTP
}
};
await this.loader.post(`orders/${this.model.order.identifier}/paytm/validate_otp/${this.txnToken}`, payload);
this.setProperties({
'isOTPModalOpen': false
});
} catch (error) {
this.notify.error(this.l10n.t(error.error));
}
},

processStripeToken(token) {
// Send this token to server to process payment
this.set('isLoading', true);
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/modals/paytm-otp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<button type="button" class="ui black button" {{action 'close'}}>
{{t 'Cancel'}}
</button>
<button class="ui green button">
<button {{action verifyOtp otp}} class="ui green button">
{{t 'Verify'}}
</button>
</div>
2 changes: 1 addition & 1 deletion app/templates/components/modals/paytm-payment-options.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<button type="button" class="ui black button" {{action 'close'}}>
{{t 'Cancel'}}
</button>
<button {{action openOTPController}} class="ui green button" disabled={{not isWalletSelected}}>
<button {{action openOTPController mobileNumber}} class="ui green button" disabled={{not isWalletSelected}}>
{{t 'Proceed'}}
</button>
</div>
4 changes: 2 additions & 2 deletions app/templates/orders/pending.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@
</div>
</div>
</div>
{{modals/paytm-payment-options isLoading=isLoading isOpen=isPaytmModalOpen amount=model.order.amount currency=model.order.event.paymentCurrency openOTPController=(action 'openOTPController')}}
{{modals/paytm-otp isLoading=isLoading isOpen=isOTPModalOpen amount=model.order.amount currency=model.order.event.paymentCurrency}}
{{modals/paytm-payment-options isLoading=isLoading isOpen=isPaytmModalOpen amount=model.order.amount currency=model.order.event.paymentCurrency openOTPController=(action 'openOTPController') txnToken=txnToken}}
{{modals/paytm-otp isLoading=isLoading isOpen=isOTPModalOpen amount=model.order.amount currency=model.order.event.paymentCurrency txnToken=txnToken verifyOtp=(action 'verifyOtp')}}