【发布时间】:2015-11-07 00:26:18
【问题描述】:
所以我尝试在我的 Ionic 应用程序上使用 Stripe Checkout 框。在手机上看起来不错。我使用自定义集成。在我看来有一个按钮:
<button class="button button-small button-flat button-balanced" ng-click="payStripe(selectedTask.total)">Pay</button>
当点击时,它会在我的控制器中触发 payStripe 功能,如下所示:
$scope.payStripe = function(amount) {
var chargeAmount = amount * 100;
console.log ("Pass in amount: " + chargeAmount);
var handler = StripeCheckout.configure({
key: '[stripe key]',
token: function(token) {
$http({
url: "http://localhost:3000/api/charge",
method: "POST",
data: {
stripeToken: token.id,
amount: chargeAmount,
}
}).success(function(data, status, headers, config) {
console.log("Status code: " + status);
}).error(function(data, status, headers, config) {
console.log("Status code: " + status);
});
}
});
// Open Checkout with further options
handler.open({
name: 'hughdesign.net',
description: '2 widgets',
amount: chargeAmount
});
}
我还在 index.html 中包含了 。我在 iOs 模拟器上运行它。第一次尝试一切正常,充电成功。在我的服务器返回 204 并且 Stripe Checkout 在我的应用程序中弹出关闭后。我想通过单击按钮再次打开它,它现在抛出错误:
Error: Unable to communicate with Checkout. Please contact support@stripe.com if the problem persists.
sendMessage@https://checkout.stripe.com/checkout.js:1:48617
https://checkout.stripe.com/checkout.js:1:15530
https://checkout.stripe.com/checkout.js:1:47580
ready@https://checkout.stripe.com/checkout.js:1:47850
invoke@https://checkout.stripe.com/checkout.js:1:47521
https://checkout.stripe.com/checkout.js:1:15530
close@https://checkout.stripe.com/checkout.js:2:52386
https://checkout.stripe.com/checkout.js:2:16468
open@https://checkout.stripe.com/checkout.js:2:34640
这发生在我所有其他包含此按钮的视图中(都触发相同的功能)。为什么它只工作一次然后停止工作?该应用程序确实在第一次结帐时与结帐通信...请帮助!谢谢!!
【问题讨论】:
标签: angularjs ionic-framework payment-gateway stripe-payments