Last active
May 11, 2016 17:53
-
-
Save vinaynb/0e23822a8c053e00b12d3d0878ba7ddb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| startPaymentProcess: function(bookingId) { | |
| //gets the data required by Payumoney | |
| var pgData = this.getDataForPaymentGateway(); | |
| //create a Url with query parameters containing our data | |
| var url = "pgLoader.html?amt=" + pgData.amt + "&name=" + | |
| pgData.name + "&mobileNo=" + pgData.mobileNo + "&email=" + pgData.email + "&bookingId=" + bookingId; | |
| //open a webview instance using inappbrowser plugin | |
| var w = window.open(url, '_blank', 'location=no,hardwareback=no'); | |
| ActivityIndicator.show("Processing...Please wait.."); | |
| var me = this; | |
| w.addEventListener('loadstop', function(event) { | |
| console.log(event); | |
| var containsPgLoader = event.url.indexOf("pgLoader.html"); | |
| if (containsPgLoader > -1) { | |
| w.executeScript({ | |
| file: "resources/js/paymentGateway.js" | |
| }); | |
| } | |
| if (event.url == "https://www.payumoney.com/payment/postBackParam.do") { | |
| ActivityIndicator.hide(); | |
| } | |
| if (event.url == me.apiUrl + "PaymentFailure") { | |
| ActivityIndicator.hide(); | |
| w.executeScript({ | |
| code: "getDetails()" | |
| }, | |
| function(values) { | |
| console.log(values); | |
| var msg = values[0].Message; | |
| me.onBookingFailure(bookingId, w.msg); | |
| } | |
| ); | |
| } | |
| if (event.url == me.apiUrl + "PaymentCancel") { | |
| ActivityIndicator.hide(); | |
| w.executeScript({ | |
| code: "getDetails()" | |
| }, | |
| function(values) { | |
| console.log(values); | |
| var msg = values[0].Message; | |
| me.onBookingFailure(bookingId, w.msg); | |
| } | |
| ); | |
| } | |
| if (event.url == me.apiUrl + "PaymentSuccess") { | |
| ActivityIndicator.hide(); | |
| w.executeScript({ | |
| code: "getDetails()" | |
| }, | |
| function(values) { | |
| console.log(values); | |
| if (values[0].Code == 1) { | |
| me.onBookingSuccessfull(bookingId, w); | |
| } else { | |
| me.onBookingFailure(bookingId, w); | |
| } | |
| } | |
| ); | |
| } | |
| var index = event.url.indexOf("https://www.payumoney.com/txn/mobile"); | |
| if (index > -1) { | |
| ActivityIndicator.hide(); | |
| } | |
| }); | |
| w.addEventListener('loadstart', function(event) { | |
| console.log(event); | |
| if (event.url == "https://www.payumoney.com/payment/postBackParam.do") { | |
| ActivityIndicator.show("Processing...Please wait.."); | |
| } | |
| if (event.url == me.apiUrl + "PaymentSuccess") { | |
| ActivityIndicator.show("Processing...Please wait.."); | |
| } | |
| if (event.url == me.apiUrl + "PaymentFailure") { | |
| ActivityIndicator.show("Processing...Please wait.."); | |
| } | |
| if (event.url == me.apiUrl + "PaymentCancel") { | |
| ActivityIndicator.show("Processing...Please wait.."); | |
| } | |
| }); | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment