Leadpagesのランディングページにストライプチェックアウトボタンを追加しようとしています。誰かが支払いを完了した後、リダイレクトされるはずです...しかし、リダイレクトは起こっていません。理由は分かりません。ストライプチェックアウト後にページがリダイレクトされない
ここに私のページがあります:http://snapstories.leadpages.co/test/ ...ストライプのデモビザ番号:4242424242424242と任意の有効期限/セキュリティコードでチェックアウトをテストできるように今すぐテストキーを使用しています...あなたはどこにでもリダイレクトされます。
demo-stripe.phpスクリプトは、「成功」レスポンスが送信されていないが、リダイレクトをトリガーするフロントエンドコードに「成功」レスポンスを送信することになっています。ここで
はデモstripe.phpコードです:
<?php
require_once('./stripe/init.php');
$stripe = array(
"secret_key" => "sk_test_******",
"publishable_key" => "pk_test_******"
);
\Stripe\Stripe::setApiKey($stripe['secret_key']);
// Get the credit card details submitted by the form
$token = $_GET['stripeToken'];
$email = $_GET['stripeEmail'];
$callback = $_GET['callback'];
try {
$customer = \Stripe\Customer::create(array(
"source" => $token,
"email" => $email
));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 100,
'currency' => 'usd'
));
header('Content-type: application/json');
$response_array['status'] = 'success';
echo $callback.'('.json_encode($response_array).')';
return 1;
}
catch (\Stripe\Error\Card $e) {
// Since it's a decline, \Stripe\Error\Card will be caught
}
?>
はここでフロントエンドのコードです:
<script src="https://checkout.stripe.com/checkout.js"></script>
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_*****',
image: 'imagefile.png',
locale: 'auto',
token: function(token) {
$.ajax({
type: "POST",
dataType: 'jsonp',
url: "https://snapstories.co/demo-stripe.php",
data: { stripeToken: token.id, stripeEmail: token.email},
success: function(data) {
window.location.href = "http//www.google.com";
},
});
}
});
document.getElementsByClassName('w-f73e4cf1-859d-e3e4-97af-8efccae7644a')[0].addEventListener('click', function(e) {
// Open Checkout with further options:
handler.open({
name: 'Testing',
description: 'testing',
amount: 100
});
e.preventDefault();
});
// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
handler.close();
});
</script>
コードを画像ではなくテキストとして投稿してください。 – imtheman
更新されました。イメージは更新されていません。 – jam