Я хочу отправить электронное письмо и вставить данные в базу данных после того, как наш веб-крючок подтвердит правильность оплаты. но когда платеж произойдет, вы не увидите сообщение об успехе на странице, которую я включил в страницу успеха. Страница полностью пуста.
И когда я вставляю свою функцию sendemail (), она не хочет вставлять данные и отправлять электронное письмо, в котором говорится: $ email = $ _get ['email'] не определено, но я включил мою выборку. php я получаю все данные из URL: cadeau. php? bon = voetbehandeling & client_secret = src_client_secret_E745XOwwOtHh45umH8WM6iGA & электронная почта = test% 40gmail.com & id = 58158488 100 & gt; *1002* 1023 *
var idealBank = elements.create('idealBank', options);
// Add an instance of the idealBank Element into
// the `ideal-bank-element` <div>.
idealBank.mount('#ideal-bank-element');
idealBank.on('change', function(event) {
var bank = event.value;
// Perform any additional logic here...
});
// Create a source or display an error when the form is submitted.
var form = document.getElementById('payment-form');
form.addEventListener('submit', function(event) {
event.preventDefault();
var randNo = Math.floor(Math.random() * 100) + 2 + "" + new Date().getTime() + Math.floor(Math.random() * 100) + 2 + (Math.random().toString(36).replace(/[^a-zA-Z]+/g, '').substr(0, 5));
var email = document.querySelector('input[name="email"]').value;
var sourceData = {
type: 'ideal',
amount: price,
currency: 'eur',
statement_descriptor: 'U heeft een tegoedbon gekocht = ' + bon,
owner: {
name: document.querySelector('input[name="name"]').value,
email: document.querySelector('input[name="email"]').value,
},
// Specify the URL to which the customer should be redirected
// after paying.
redirect: {
return_url: 'https://www.pedicurepraktijkpapendrecht.nl/stripe/cadeau.php' + '?email=' + email + '&id=' + randNo + '&bon=' + bon,
},
};
// Call `stripe.createSource` with the idealBank Element and
// additional options.
stripe.createSource(idealBank, sourceData).then(function(result) {
if (result.error) {
// Inform the customer that there was an error.
var errorElement = document.getElementById('error-message');
errorElement.textContent = error.message;
} else {
// Redirect the customer to the authorization URL.
stripeSourceHandler(result.source);
}
});
});
function stripeSourceHandler(source) {
// Redirect the customer to the authorization URL.
document.location.href = source.redirect.url;
}
страница успеха
?php
include('./webhook.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<script src="https://js.stripe.com/v3/"></script>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"
integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
<title>Email versturen naar uw email!</title>
</head>
<body>
<div class="form-row">
<h1>Bedankt voor het kopen van een tegoedbon!</h1>
<p>Uw tegoedbon word gestuurd naar uw email!</p>
<div class="flex">
<a href="https://www.pedicurepraktijkpapendrecht.nl/"
class="btn text-center margin-right max-width">Naar de
website</a>
<a href="checkout.php" class="btn text-center margin-right max-width">Nog een tegoedbon kopen?</a>
</div>
</div>
</body>
webhook. php
require('./vendor/autoload.php');
$endpoint_secret = 'whsec_4lLBwyPL7TG2zi4Azl8Q5KBggzOZUqet';
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;
try {
$event = \Stripe\Webhook::constructEvent(
$payload, $sig_header, $endpoint_secret
);
} catch(\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
exit();
} catch(\Stripe\Exception\SignatureVerificationException $e) {
// Invalid signature
http_response_code(400);
exit();
}
if ($event->type == "source.chargeable") {
$intent = $event->data->object;
printf("Succeeded: %s", $intent->id);
http_response_code(200);
exit();
} elseif ($event->type == "source.failed") {
$intent = $event->data->object;
$error_message = $intent->last_payment_error ? $intent->last_payment_error->message : "";
printf("Failed: %s, %s", $intent->id, $error_message);
http_response_code(200);
exit();
}
?>