Init
This commit is contained in:
18
admin/db_con.php
Normal file
18
admin/db_con.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
$hostname = $_SERVER['HTTP_HOST'];
|
||||
|
||||
if($hostname == 'api.stellaamor.com.local'){
|
||||
$server = 'localhost';
|
||||
$username = "root";
|
||||
$db = "stella_amor";
|
||||
$db_con = new pdo("mysql:host=$server;dbname=$db;charset=utf8mb4", $username);
|
||||
}else{
|
||||
$server = 'localhost';
|
||||
$username = 'mysinfu1_stella';
|
||||
$db_pass = 'E1#j#W4Y4UcV';
|
||||
$db = 'mysinfu1_stella';
|
||||
|
||||
$db_con = new pdo("mysql:host=$server;dbname=$db;charset=utf8mb4", $username, $db_pass);
|
||||
}
|
||||
?>
|
||||
18
admin/error_log
Normal file
18
admin/error_log
Normal file
@@ -0,0 +1,18 @@
|
||||
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 8
|
||||
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 9
|
||||
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 9
|
||||
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 11
|
||||
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 11
|
||||
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 11
|
||||
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 11
|
||||
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 8
|
||||
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 9
|
||||
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
|
||||
37
admin/payments.php
Normal file
37
admin/payments.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
include('db_con.php');
|
||||
|
||||
$apiData = file_get_contents('php://input');
|
||||
$apiData = json_decode($apiData);
|
||||
|
||||
|
||||
$customer = $apiData->data->object->customer;
|
||||
$status = $apiData->data->object->status;
|
||||
$end = $apiData->data->object->lines->data[0]->period->end;
|
||||
|
||||
// echo "Customer: $customer\n";
|
||||
// echo "Status: $status\n";
|
||||
// echo "End: $end\n";
|
||||
|
||||
$sql = $db_con->prepare("SELECT id FROM stripe_user_data WHERE cu_name = :customer");
|
||||
$sql->bindValue(':customer', $customer);
|
||||
$sql->execute();
|
||||
|
||||
$numRows = $sql->rowCount();
|
||||
|
||||
if($numRows == 0){
|
||||
$stmt = $db_con->prepare("INSERT INTO stripe_user_data (cu_name, exp_date) VALUES (:cu_name, :exp_date)");
|
||||
$stmt->bindValue(':cu_name', $customer);
|
||||
$stmt->bindValue(':exp_date', $end);
|
||||
$stmt->execute();
|
||||
}else{
|
||||
$stripe_user = $sql->fetch(PDO::FETCH_ASSOC);
|
||||
$stripe_user_id = $stripe_user['id'];
|
||||
$stmt = $db_con->prepare("UPDATE stripe_user_data SET exp_date = :exp_date WHERE id = :id");
|
||||
$stmt->bindValue(':id', $stripe_user_id);
|
||||
$stmt->bindValue(':exp_date', $end);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
42
admin/subscriptions.php
Normal file
42
admin/subscriptions.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
include('db_con.php');
|
||||
|
||||
$apiDataEncoded = file_get_contents('php://input');
|
||||
$apiData = json_decode($apiDataEncoded);
|
||||
$uname = $apiData->data->object->custom_fields[0]->text->value;
|
||||
$uemail = $apiData->data->object->customer_details->email;
|
||||
$customerId = $apiData->data->object->customer;
|
||||
|
||||
$sql = $db_con->prepare('SELECT id FROM users WHERE uname = :uname');
|
||||
$sql->bindValue(':uname', $uname);
|
||||
$sql->execute();
|
||||
$numRows = $sql->rowCount();
|
||||
|
||||
if($numRows > 0){
|
||||
$userData = $sql->fetch(PDO::FETCH_ASSOC);
|
||||
$user_id = $userData['id'];
|
||||
|
||||
$stmt = $db_con->prepare("UPDATE users SET stripe_cu = :customerId WHERE id = :id");
|
||||
$stmt->bindValue(':customerId', $customerId);
|
||||
$stmt->bindValue(':id', $user_id);
|
||||
$stmt->execute();
|
||||
}else{
|
||||
$sql = $db_con->prepare('SELECT id FROM users WHERE u_email = :u_email');
|
||||
$sql->bindValue(':u_email', $uemail);
|
||||
$sql->execute();
|
||||
$numRows = $sql->rowCount();
|
||||
|
||||
if($numRows > 0){
|
||||
$userData = $sql->fetch(PDO::FETCH_ASSOC);
|
||||
$user_id = $userData['id'];
|
||||
|
||||
$stmt = $db_con->prepare("UPDATE users SET stripe_cu = :customerId WHERE id = :id");
|
||||
$stmt->bindValue(':customerId', $customerId);
|
||||
$stmt->bindValue(':id', $user_id);
|
||||
$stmt->execute();
|
||||
}else{
|
||||
die('Incorrect details');
|
||||
}
|
||||
}
|
||||
die();
|
||||
?>
|
||||
Reference in New Issue
Block a user