Я использую структуру из официальной документации (https://stripe.com) /docs/pays/integration-builder), но при проверке консоли в браузере я получаю следующую ошибку:
POST 500 (внутренняя ошибка сервера) и в разделе сети ответ на POST( для create.php) запрос
Код: Выделить всё
{"error":"Call to undefined function curl_version()"}
create.php
Код: Выделить всё
require_once('../stripe-php-7.37.1/init.php'); //my others require are not printed
\Stripe\Stripe::setApiKey('my_key');
header('Content-Type: application/json');
try {
// retrieve JSON from POST body
$json_str = file_get_contents('php://input');
$json_obj = json_decode($json_str);
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => calculateOrderAmount(), //amount calculator
'currency' => 'eur',
]);
$output = [
'clientSecret' => $paymentIntent->client_secret,
];
echo json_encode($output);
} catch (Error $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}
Код: Выделить всё
...
...
Pay
Payment succeeded, see the result in your
Stripe dashboard. Refresh the page to pay again.
...
var stripe = Stripe("my_key");
// Disable the button until we have Stripe set up on the page
document.querySelector("button").disabled = true;
fetch("/Stripe/create.php", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(purchase)
})
.then(function(result) {
result.json();
})
.then(function(data) {
var elements = stripe.elements();
...
У меня следующая файловая архитектура:
├───stripe -php-7.37.1
├───Stripe
│ ├───checkout.php
│ ├───create. php
Спасибо за помощь
Подробнее здесь: https://stackoverflow.com/questions/626 ... php-stripe
Мобильная версия