Server : LiteSpeed System : Linux nl-srv-web1396.main-hosting.eu 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64 User : u107206879 ( 107206879) PHP Version : 7.2.34 Disable Function : NONE Directory : /home/u107206879/domains/escort46.de/public_html/ |
<?php
$statusMsg='';
// Stripe Code Start
require 'stripe/Stripe.php';
$params = array(
"testmode" => "off",
"private_live_key" => "sk_live_DEy7v5pRjT5oV4m0EjKPrFha",
"public_live_key" => "pk_live_UuS9pQLZIGorMbyEJvyiD8tx",
"private_test_key" => "sk_test_gJUwWhLnSXAzKwxDCQODQtlt",
"public_test_key" => "pk_test_zBnB0kABam3rAHUNjL1Mpcjy"
);
if ($params['testmode'] == "on") {
Stripe::setApiKey($params['private_test_key']);
$pubkey = $params['public_test_key'];
} else {
Stripe::setApiKey($params['private_live_key']);
$pubkey = $params['public_live_key'];
}
if(isset($_POST['stripeToken'])){
$charge = array();
if(!empty($_POST['plan_id']) && !empty($_POST['sub_plan_id'])){
$plan_sql = mysqli_query($connection,"SELECT plan_name, amount, currency FROM plans WHERE plan_id=".$_POST['plan_id']." AND sub_plan_id=".$_POST['sub_plan_id']);
$plan_amount = mysqli_fetch_assoc($plan_sql);
$amount_cents = $plan_amount['amount'];
$currency = $plan_amount['currency'];
$plan_name = $plan_amount['plan_name'];
}
$adid = $_POST['ad_id'];
$plan_id = $_POST['plan_id'];
$sub_plan_id = $_POST['sub_plan_id'];
if($plan_id=="1"){
$plan="Bronze";
}elseif($plan_id=="2"){
$plan="Silver";
}elseif($plan_id=="3"){
$plan="Gold";
}
if($sub_plan_id=="1"){
$sub_plan="7";
}elseif($sub_plan_id=="2"){
$sub_plan="14";
}elseif($sub_plan_id=="3"){
$sub_plan="30";
}
$payer_email = $_SESSION['email'];
$card_num = $_POST['card_num'];
$card_cvc = $_POST['cvc'];
$card_exp_month = $_POST['exp_month'];
$card_exp_year = $_POST['exp_year'];
$amount = str_replace('.','',$amount_cents); // Chargeble amount
$description = "";
try {
$charge = Stripe_Charge::create(array(
"amount" => $amount,
"currency" => $currency,
"source" => $_POST['stripeToken'],
"description" => $description,
'metadata' => array("Plan Name" => $plan_name, "Plan" => $plan_id, "Sub Plan" => $sub_plan_id, "Email" => $payer_email)
)
);
if ($charge->source->address_zip_check == "fail") {
throw new Exception("zip_check_invalid");
} else if ($charge->source->address_line1_check == "fail") {
throw new Exception("address_check_invalid");
} else if ($charge->source->cvc_check == "fail") {
throw new Exception("cvc_check_invalid");
}
// Payment has succeeded, no exceptions were thrown or otherwise caught
$result = "success";
} catch(Stripe_CardError $e) {
$error = $e->getMessage();
$result = "Declined due to Card Error";
} catch (Stripe_InvalidRequestError $e) {
$result = "Declined due to Invalid Request Error";
} catch (Stripe_AuthenticationError $e) {
$result = "Declined due to Authentication Error";
} catch (Stripe_ApiConnectionError $e) {
$result = "Declined due to Api Connection Error";
} catch (Stripe_Error $e) {
$result = "Declined due to Error";
} catch (Exception $e) {
if ($e->getMessage() == "zip_check_invalid") {
$result = "Declined due to invalid ZIP";
} else if ($e->getMessage() == "address_check_invalid") {
$result = "Declined due to invalid Address";
} else if ($e->getMessage() == "cvc_check_invalid") {
$result = "Declined due to invalid CVC";
} else {
$result = "Declined due to Error";
}
}
//echo "<pre>";
//echo "<BR>Stripe Payment Status : ".$result;
//echo "<BR>Stripe Response : ";
//print_r($charge);
//die();
//check whether the charge is successful
if(isset($charge['amount_refunded']) && $charge['amount_refunded'] == 0 && isset($charge['failure_code']) && empty($charge['failure_code']) && isset($charge['paid']) && $charge['paid'] == 1 && isset($charge['captured']) && $charge['captured'] == 1){
//order details
$amount = $charge['amount'];
$txn_id = $charge['balance_transaction'];
$currency = $charge['currency'];
$status = $charge['status'];
$created = $charge['created'];
$paydate = date("Y-m-d H:i:s", $created);
$exdate = strtotime(date($paydate)."+$sub_plan day");
$expdate=date("Y-m-d H:i:s",$exdate);
//insert tansaction data into the database
$sql = "INSERT INTO payment_stripe (ad_id, txn_id, plan_type, plan_id, sub_plan_id, rec_amount, currency, card_num, card_cvc, card_exp_month, card_exp_year, payer_email, payment_date, payment_status, stripe_payload) VALUES($adid, '".$txn_id."', '".$plan."', ".$plan_id.", ".$sub_plan_id.", '".$amount_cents."', '".$currency."', '".$card_num."', '".$card_cvc."', '".$card_exp_month."', '".$card_exp_year."', '".$payer_email."', '".$paydate."', '".$status."', '".$charge."')";
$insert = mysqli_query($connection,$sql);
$last_insert_id = $connection->insert_id;
//if order inserted successfully
if($last_insert_id && $status == 'succeeded'){
$statusMsg = "The transaction was successful";
mysqli_query($connection,"UPDATE advertise SET plan_id = ".$plan_id.", start_date = '".$paydate."', end_date = '".$expdate."', adstatus = 1, isApproved=1 WHERE id=".$adid);
$to="[email protected]";
$subject="Payment";
$headers='From:'.MAIN_EMAIL_NAME.' <'.MAIN_EMAIL.'>';
$msg="Hello, \n";
$msg.="Received Payment of ".$amount_cents." $currency for AD ID:".$adid;
mail($to,$subject,$msg,$headers);
}else{
$statusMsg = "Transaction has been failed";
}
}else{
$statusMsg = "Transaction has been failed";
}
}
// Stripe Code End