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
我正在尝试将条带集成到我的Ember应用程序中,当初始卡片收集帖子完成时,我遇到了障碍。 Stripe试图发布围绕着的形式
<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.
问题是我不想不想做服务器POST。我想劫持表单POST并执行我自己的stripeToken和其他数据元素的自定义帖子来实际创建费用。
StripeButton component below:
StripeButton组件如下:
var StripeButton = Ember.Component.extend({
scriptSource: '<script src="https://checkout.stripe.com/checkout.js" 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?
如何通过我自己的操作告诉Ember控制表单提交以执行我需要的自定义ajax?
1 个解决方案
#1
1
You might want to check out the checkout.js
custom integration here: https://stripe.com/docs/checkout#integration-custom
您可能需要在此处查看checkout.js自定义集成:https://stripe.com/docs/checkout#integration-custom
This will allow you greater flexibility in creating your solution instead of trying to hack the simple integration.
这将使您在创建解决方案时具有更大的灵活性,而不是试图破解简单的集成。
#1
1
You might want to check out the checkout.js
custom integration here: https://stripe.com/docs/checkout#integration-custom
您可能需要在此处查看checkout.js自定义集成:https://stripe.com/docs/checkout#integration-custom
This will allow you greater flexibility in creating your solution instead of trying to hack the simple integration.
这将使您在创建解决方案时具有更大的灵活性,而不是试图破解简单的集成。