mercredi 24 février 2016

stripe jquery function to an ember property?

Having problems converting stripe Jquery function into a ember property. Have try multiple was but looks like I am missing something. Thanks

         var stripeResponseHandler = function(status, response) {
             var $form = $('#contact-form');
             var self = this;
             if (response) {
                 self.set('stripeToken',response);
                console.log(self.get('stripeToken'));
                 // Show the errors on the form
                 $form.find('.payment-errors').text(response.error.message);
                 $form.find('input').prop('disabled', false);
             } else {
                 // token contains id, last4, and card type
                 var token = response.id;
                 // Insert the token into the form so it gets submitted to the server
                 $form.append($('<input type="hidden" name="stripeToken" />').val(token));
                 // and re-submit
                 $form.get(0).submit();
             }
         };

         $('#contact-form').submit(function(e) {
             var $form = $(this);
             // Disable the submit button to prevent repeated clicks
             $form.find('input').prop('disabled', true);
             Stripe.card.createToken($form, stripeResponseHandler);
         });




Aucun commentaire:

Enregistrer un commentaire