Hi All, I’m trying to get Stripe setup.
I’ve got the API call to setup and retrieve the session OK.
Now I’m trying to redirect to checkout. The only way to do this that I can see is to use their
javascript method. It works perfectly as an HTML file but I can’t get it to work in my project.
I have replaced part of my public key with some hashes here.
Here is the working HTML file :
KP Balance and Purchase<script>
function checkout() {
var stripe = Stripe('pk_test_jh#######37v9');
stripe.redirectToCheckout({
sessionId:'cs_test_UdVb83XgZ0fT2XJjuPExSboEtLyLgSnx2qWlrbYjpY4L3Ihoq6c0cGNd'
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
});
}
This is what I’ve got in the ‘PageReceived’ event of my socket - after I’ve got Session id etc to achieve the above
I’ve hard coded the session id for the purpose of testing :
self.ExecuteJavaScript(" src="“https://js.stripe.com/v3/”" ")
self.ExecuteJavaScript(" var stripe = Stripe(‘pk_test_jhX0BZ########0bDcx37v9’); " )
Self.ExecuteJavaScript( "stripe.redirectToCheckout({sessionId: ‘cs_test_UdVb83XgZ0fT2XJjuPExSboEtLyLgSnx2qWlrbYjpY4L3Ihoq6c0cGNd’ }).then(function (result) { }); " )
This is the error I’m getting
Could not execute returned javascript: Can’t find variable: Stripe
Source: src=“https://js.stripe.com/v3/”
var stripe = Stripe(‘pk_test_jhX0BZV#########D200bDcx37v9’);
stripe.redirectToCheckout({sessionId: ‘cs_test_UdVb83XgZ0fT2XJjuPExSboEtLyLgSnx2qWlrbYjpY4L3Ihoq6c0cGNd’ }).then(function (result) { });
Any help would be great thank you.