Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to get a users email so it will update them when they purchased premium, I'm using Stripe as my payment system. The only way I can get it to work, is if I insert their email/id into my php page. I'm wanting the page to get the users email on it's on.

PHP
$_SESSION['user_id'] = 9;

$stripe = array(
	"secret_key" => "sk_test_vDYOBYxCErhrgGCeWQJhR4mQ",
	"publishable_key" => "pk_test_4mIuE3OsajKO4cnFppcDDISu"
	);
	
	\Stripe\Stripe::setApiKey($stripe['secret_key']);

$db = new PDO('mysql:host=127.0.0.1;dbname=blog', 'root', '');

$userQuery = $db->prepare("
	SELECT id, username, email, premium
	FROM users
	WHERE id = :user_id
	");
	
	$userQuery->execute(['user_id' => $_SESSION['user_id']]);
	
	$users = $userQuery->fetchObject();


I'm using ID's right now, I have to enter them on my own. The website isn't live, just testing. I can get the users email with Stripe on my checkout page by putting
PHP
echo $users->email
& the email shows up on the purchase screen, where normally they would have to type it. I'm not sure how to get it on purchase so it will update the user in the DB though.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900