WordPressで作成したサイトにStripe決済を導入しようと思い、下記のページを参考に全く同じようにやってみたのですが、最後の「完了ページへのリダイレクト」がうまくいかない状態です。
WordPressでカード決済!Stripeの使い方【自動返信メール対応】
▼以下決済ボタンページのHTML
<form action="https://●●●●●●●●.co.jp/wp-content/themes/●●●●●●●●/checkout.php" method="POST"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="pk_test_●●●●●●●●" data-amount="10000" data-name="株式会社●●●●●●●●" data-description="●●●●●●●●" data-image="https://stripe.com/img/documentation/checkout/marketplace.png" data-locale="auto" data-currency="jpy" data-zip-code="false" data-allow-remember-me="false" data-label="申し込む(決済する)"></script> </form> </div>
▼以下checkout.php
<?php require_once( dirname(__FILE__).'/lib/stripe-php-6.19.5/init.php'); // Set your secret key: remember to change this to your live secret key in production // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey("sk_test_●●●●●●●●"); // Token is created using Stripe.js or Checkout! // Get the payment token submitted by the form: $token = $_POST['stripeToken']; $email = $_POST['stripeEmail']; // フォームから情報を取得: try { $charge = \Stripe\Charge::create(array( "amount" => 10000, "currency" => "jpy", "source" => $token, "description" => "●●●●●●●●", )); }catch (\Stripe\Error\Card $e) { // 決済できなかったときの処理 die('決済が完了しませんでした'); } // 自動返信メール mb_language("Japanese"); mb_internal_encoding("UTF-8"); $title = "●●●●●●●●お申し込みありがとうございます"; $content = "●●●●●●●●お申し込みありがとうございます。\nクレジットカード決済が完了いたしました。"; $from_name = "株式会社●●●●●●●●"; $from_addr = "info@●●●●●●●●.co.jp"; $from_name_enc = mb_encode_mimeheader($from_name, "ISO-2022-JP"); $from = $from_name_enc . "<" . $from_addr . ">"; $header = "From: " . $from . "\n"; $header = $header . "Reply-To: " . $from; //to user send mail if(mb_send_mail($email,$title, $content, $header, "-f" .$from_addr)){ echo "メールを送信しました"; } else { echo "メールの送信に失敗しました"; }; // 管理者宛メール $title_me = "Stripe決済がありました"; $from_me = "info@●●●●●●●●.co.jp"; $content_me = "●●●●●●●●申し込みで\nStripe決済がありました。"; if(mb_send_mail($from_me,$title_me, $content_me, $header, "-f" .$from_addr)){ echo "メールを送信しました"; } else { echo "メールの送信に失敗しました"; }; // サンキューページへリダイレクト header('Location: https://●●●●●●●●.co.jp/stripe-thanks.html'); exit; ?>
決済ボタンを押しても、上記のサンキューページへリダイレクトせず、
https://●●●●●●●●.co.jp/wp-content/themes/●●●●●●●●/checkout.php
ページになったままの状態です。
どなたかご教授いただければ幸いです。
回答1件
あなたの回答
tips
プレビュー