key*_*red 12 angularjs stripe-payments
我目前正在尝试实施标准的Stripe Payments结帐对话.当我放入<script>文档(https://stripe.com/docs/checkout)中描述的简短包含时,应该显示的按钮没有呈现.
当我把它放在我的顶级index.html文件中时,按钮会显示.当我把它放到一个部分,当它击中一个特定的路线时,它显示,它没有.我认为这是因为它没有执行Javascript,因为它在路由中的页面加载时不会发生.
有什么办法让我在路线上工作,或者我应该只实现一个指向stripe.js库的自定义表单?谢谢.
问题是,如你所说,js不会触发.解决方案是checkout.js在index.html文件中简单地包含Stripe ,然后触发Stripe弹出窗口以与控制器(或其他地方)一起打开.
在index.html(或等效的)中
<script src="https://checkout.stripe.com/checkout.js"></script>
<!-- Angular script(s) -->
Run Code Online (Sandbox Code Playgroud)
在你的控制器(或其他地方)
var handler = StripeCheckout.configure({
key: 'pk_test_6pRNASCoBOKtIshFeQd4XMUh',
image: '/img/documentation/checkout/marketplace.png',
locale: 'auto',
token: function(token) {
// Use the token to create the charge with a server-side script.
// You can access the token ID with `token.id`
}
});
handler.open({
name: 'Stripe.com',
description: '2 widgets',
amount: 2000
});
// handler.close();
Run Code Online (Sandbox Code Playgroud)
这是根据条纹文档进行的改编:https://stripe.com/docs/checkout#integration-custom