I am attempting to redirect users to a success page when their payment is complete. This is how the code looks:
<?php
session_start();
$total = $_SESSION['total'];
require_once('stripe-php-2.3.0/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("");
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = \Stripe\Charge::create(array(
"amount" => $total, // amount in cents, again
"currency" => "gbp",
"source" => $token,
"description" => "")
);
header('Location: index2.php');
} catch (\Stripe\Error\Card $e) {
// The card has been declined
}
?>
The code does redirect and the address in the browser's address bar is the one that I want and is on the server however I get a 404 error each time.
Check if you have any URL rewrite rule.