By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

hello this my code is not working internet explorer plz give me solution

P: 5
hello this my code is not working internet explorer plz give me solution

Expand|Select|Wrap|Line Numbers
  1. /**
  2.  * When we click on a card
  3.  */
  4.  $('#btnpay').click(function(){
  5.   const paymentRequest = {
  6.     cardNumber:  $('#cartno').val(),
  7.     expYear: $('#expYear').val(),
  8.     expMonth: $('#expMonth').val(), 
  9.     cvc: $('#cvcno').val(),
  10.     currency: 'GBP', 
  11.     amount: $('#amount').val(),
  12.     nativeElement: document.querySelector('#iframe-payment')
  13.   };
  14.  
  15.   paymentRequest.nativeElement.innerHTML = 'Loading... Please wait... while you are redirecting payment getway ';
  16. $('.frm').hide()
  17.   doPayment(paymentRequest).then((result) => {
  18. $('#formpay').append('<input type="hidden" name="stripeSource" value="'+result.id+'" />');
  19. $('#formpay').submit()
  20.  
  21.   }).catch((error) => {
  22.  
  23.     paymentRequest.nativeElement.innerHTML = 'Ups! We can\t validate your details...';
  24.  
  25.     setTimeout(function() {
  26.       location.reload();
  27.       }, 3000);
  28.   });
  29. })
  30.  
  31.  
  32.  
  33.   function isNumberKey(evt){
  34.  
  35.     var charCode = (evt.which) ? evt.which : event.keyCode
  36.     if (charCode > 31 && (charCode < 48 || charCode > 57))
  37.     return false;
  38.  
  39.  
  40.  
  41. }
  42.  
  43.  
  44. $('#cartno').keyup(function() {
  45.   var length = $(this).val().length;
  46.  
  47.   if(length==16){
  48.  
  49.       $('#expMonth').focus()
  50.   }
  51.  
  52. });
  53.  
  54. $('#expMonth').keyup(function() {
  55.   var length = $(this).val().length;
  56. var firstChar = $(this).val().substr(0, 1);
  57. if(firstChar>1){
  58. $(this).val(0)}
  59.   if(length==2){
  60. $('#expYear').focus()
  61.   }
  62.  
  63.  
  64.  
  65.  
  66. });
  67.  
  68.  
  69. $('#expYear').keyup(function() {
  70.   var length = $(this).val().length;
  71.  
  72.   if(length==2){
  73. $('#cvcno').focus()
  74.   }
  75.  
  76. });
  77.  
  78.  
  79. $('#cvcno').keyup(function() {
  80.   var length = $(this).val().length;
  81.  
  82.   if(length==3){
  83. $('#btnpay').focus()
  84.   }
  85.  
  86. });
May 19 '18 #1
Share this Question
Share on Google+
9 Replies


gits
Expert Mod 5K+
P: 5,298
what exactly is not working?
May 22 '18 #2

P: 5
trigger is not working on internet explorer
error on this line doPayment(paymentRequest).then((result) => {
plz giving me right solution
May 22 '18 #3

gits
Expert Mod 5K+
P: 5,298
which version of IE is it? i suspect that it doesnt support promises so you would need to include some code to polyfill the promise-construct or u can use babel to transpile the code.
May 22 '18 #4

P: 5
this code not working on IE 11 version please give me any solution
May 22 '18 #5

gits
Expert Mod 5K+
P: 5,298
i gave you 2 possible hints to solve that issue - u can use babel for transpiling or use something like this:

https://github.com/taylorhakes/promise-polyfill

note: this is just an example - there are many more such implementations that can be used.
May 22 '18 #6

P: 5
i used babel but i get other error 'Promise' is undefined in api file



this file


Expand|Select|Wrap|Line Numbers
  1. /**
  2.  * This is the main function - The only one that we should call from outside this file
  3.  */
  4. function doPayment(paymentRequest) {
  5.   return new Promise((resolve, reject) => {
  6.     const onCreateCardCallback = create3DSecure(paymentRequest, resolve, reject);
  7.     return Stripe.source.create({
  8.       type: 'card',
  9.       card: {
  10.         number: paymentRequest.cardNumber,
  11.         cvc: paymentRequest.cvc,
  12.         exp_month: paymentRequest.expMonth,
  13.         exp_year: paymentRequest.expYear
  14.       }
  15.     }, onCreateCardCallback);
  16.   });
  17. }
  18.  
  19. function create3DSecure(paymentRequest, resolve, reject) {
  20.   return (status, cardResponse) => {
  21.  
  22.  
  23.     if (status !== 200 || cardResponse.error) {  // problem
  24.       reject(cardResponse.error);
  25.     } else if (cardResponse.card.three_d_secure === 'not_supported' && cardResponse.status === 'chargeable') {
  26.       resolve(cardResponse);
  27.     } else if(cardResponse.card.three_d_secure === 'optional' || cardResponse.card.three_d_secure === 'required') {
  28.       const onCreate3DSecureCallback = createIframe(paymentRequest, resolve, reject);
  29.  
  30.       Stripe.source.create({
  31.         type: 'three_d_secure',
  32.         amount: paymentRequest.amount,
  33.         currency: paymentRequest.currency,
  34.         three_d_secure: { card: cardResponse.id },
  35.         redirect: { return_url:'demo.com'}
  36.       }, onCreate3DSecureCallback);
  37.     }
  38.     else {
  39.       reject(cardResponse);
  40.     }
  41.   };
  42. }
  43.  
  44. function createIframe(paymentRequest, resolve, reject) {
  45.   return (status, stripe3dsResponse) => {
  46.  
  47.     if (status !== 200 || stripe3dsResponse.error) {  // problem
  48.       reject(stripe3dsResponse.error);
  49.     } else {
  50.       paymentRequest.nativeElement.innerHTML =
  51.         '<iframe style="width:100%; height:622px;" frameborder="0" src="' + stripe3dsResponse.redirect.url + '"></iframe>';
  52.  
  53.       const onPollCallbackReal = onPollCallback(paymentRequest, resolve, reject);
  54.       Stripe.source.poll(stripe3dsResponse.id, stripe3dsResponse.client_secret, onPollCallbackReal);
  55.     }
  56.   };
  57. }
  58.  
  59. function onPollCallback(paymentRequest, resolve, reject) {
  60.   return (status, source) => {
  61.  
  62.  
  63.     if (status !== 200 || source.error) {
  64.  
  65.       reject(source.error);
  66.     } else if (source.status === 'canceled' || source.status === 'consumed' || source.status === 'failed') {
  67.  
  68.       reject(source.status);
  69.     } else if (source.three_d_secure.authenticated &&  source.status === 'chargeable') {
  70.  
  71.  
  72.       resolve(source);
  73.     }
  74.   };
  75. }
May 22 '18 #7

gits
Expert Mod 5K+
P: 5,298
this most likely means that the Browser doesnt know of a Promise object
May 22 '18 #8

P: 5
what i do on this error please give me any solution thank you for helping to me
May 22 '18 #9

gits
Expert Mod 5K+
P: 5,298
there is a call:
Expand|Select|Wrap|Line Numbers
  1. new Promise
obviously that Object is not defined anywhere - so the browser doesnt know that object and u need some polyfill - either the babel one or another. for babel u can start checking here:

https://babeljs.io/docs/plugins/transform-runtime/
May 22 '18 #10

Post your reply

Sign in to post your reply or Sign up for a free account.