mercredi 24 décembre 2014

Emberjs Stripe integration post with stripeToken

I am trying to integrate stripe into my Ember app and I'm running into a snag when the initial card collection post is finished. Stripe tries to post the form surrounding the



<form {{action "charge" on="submit"}} method="POST">
<input type="hidden" name="plan" {{bind-attr value="plan.id"}} />
{{strip-button amount=plan.amount name=plan.name emailAddress=emailAddress}}
</form>


The problem is that I do not want to do not want to do a server POST. I would like to take hijack the form POST and do my own custom post of the stripeToken and other data elements to actually create the charge.


StripeButton component below:



var StripeButton = Ember.Component.extend({
scriptSource: '<script src="http://ift.tt/1doUtf9" class="stripe-button"',
scriptClose: '></script>',
dataElement: function(element, value) {
return 'data-' + element + '="' + value + '"';
},
didInsertElement: function() {
this.$().append(
this.get('scriptSource') +
this.dataElement('key', 'pk_test_wat') +
this.dataElement('amount', this.get('amount')) +
this.dataElement('email', this.get('emailAddress')) +
this.dataElement('label', this.get('name') + ' Plan') +
this.dataElement('name', 'Company Name') +
this.dataElement('description', this.get('name')) +
this.get('scriptClose')
);
}
});

export default StripeButton;


How do I tell Ember to take control of the form submit with my own action to perform the custom ajax I need?





Aucun commentaire:

Enregistrer un commentaire