-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Hi!
I would like to ask how to fix the error?
<?php
// Barion fizetési visszatérő oldal (barion-payment.php)
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['PaymentId']) && isset($_POST['POSId'])) {
// Ellenőrizd, hogy a POST adatok érkeztek-e a fizetési tranzakcióval kapcsolatban
$paymentId = $_POST['PaymentId'];
$posId = $_POST['POSId'];
// Barion API hívás a fizetés véglegesítéséhez és ellenőrzéséhez
$barionAPIURL = "https://api.test.barion.com/payment/getstatus";
$barionAPIPOSKey = "";
$requestData = array(
"POSKey" => $barionAPIPOSKey,
"PaymentId" => $paymentId
);
$requestDataJSON = json_encode($requestData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $barionAPIURL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestDataJSON);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$paymentStatus = json_decode($response, true);
// Ellenőrizd a fizetési tranzakció státuszát
if ($paymentStatus['Status'] == "Succeeded") {
// A fizetés sikeres volt, frissítsd az adatbázist a vásárolt PP pontokkal
$ppPontok = $paymentStatus['Transactions'][0]['Total'];
// Adatbázis frissítése
// ...
echo 'Sikeres fizetés!';
} else {
// A fizetés sikertelen volt
echo 'Sikertelen fizetés!';
}
} else {
// Hiányzó POST adatok esetén
echo 'Sikertelen fizetés!';
}
}
?>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$barionPOSKey = "";
$barionRedirectURL = "https://neonnights.illesinnovate.hu/pp/barion-payment.php";
// Barion fizetési létrehozása
$barionPaymentURL = "https://api.test.barion.com/v2/Payment/Start";
// Adatok a fizetéshez
$itemName = $_POST["name_item"];
$itemDescription = $_POST["name_description"];
$itemPrice = $_POST["name_price"];
// Fizetési adatok előkészítése
$paymentData = array(
"POSKey" => $barionPOSKey,
"PaymentType" => "Immediate",
"GuestCheckOut" => true,
"FundingSources" => ["All"],
"PaymentRequestId" => uniqid("NNRP-"),
"PayerHint" => "user@example.com",
"Transactions" => array(
array(
"POSTransactionId" => uniqid("TRANS-"),
"Payee" => "neonnights@illesinnovate.hu",
"Total" => 10, // Összeg PP pontok vásárlásához
"Items" => array(
array(
"Name" => $itemName,
"Description" => $itemDescription,
"Quantity" => 1,
"Unit" => "db",
"UnitPrice" => $itemPrice, // Ár PP pontonként
)
)
)
),
"RedirectUrl" => $barionRedirectURL
);
$paymentDataJSON = json_encode($paymentData);
// API hívás és válaszfeldolgozás
// Barion fizetési átirányítás helyett API hívás
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $barionPaymentURL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $paymentDataJSON);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Válaszfeldolgozás
$paymentResponse = json_decode($response, true);
if ($paymentResponse['Status'] === 'Succeeded') {
// A fizetés sikeres volt, folytasd a szükséges tevékenységekkel
$paymentId = $paymentResponse['PaymentId'];
$transactionId = $paymentResponse['Transactions'][0]['POSTransactionId'];
$totalAmount = $paymentResponse['Transactions'][0]['Total'];
// Adatok további feldolgozása vagy adatbázis frissítése
// ...
echo 'Sikeres fizetés!';
} else {
// A fizetés sikertelen volt, kezeld a hibát vagy jelentsd az ügyfeleknek
$errorMessage = $paymentResponse['Errors'][0]['Description'];
echo 'Sikertelen fizetés! Hiba: ' . $errorMessage;
}
// Barion fizetési átirányítás
header("Location: $barionPaymentURL");
exit;
}
?>
Waiting for your reply!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels