So I try to use the Stripe Checkout box on my Ionic App. It looks nice on mobile. I use the custom integration. There is a button in my view:
<button class="button button-small button-flat button-balanced" ng-click="payStripe(selectedTask.total)">Pay</button>
When click, it trigger payStripe function as follow in my controller:
$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
});
}
I also included the in my index.html. I run it on iOs simulator. Everything works nicely at the first try and the charge is successful. After my server return a 204 and the Stripe Checkout pop up close in my app. I want to open it again by clicking the button, it throw error now:
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
And this happen to all my other views which contain this button (all trigger the same function). Why it works ONLY ONCE and then stop working? The app did communicated with checkout at the first time checkout...Please help! Thanks!!
Hi I tried to solve your problem but it is showing some error's, can you briefly tell me what you defined in StriprCheckout
StripeCheckout is not defined