01-15-2017, 02:38 PM
You're exactly right about requiring the init. I've never used the paypal, API before but I can give you some pointers.
I would go right up to line 2 and
Then if you go down to the bottom, it looks like you're getting 3 things back...
user_id
payment_id
hash
I can't tell if that user_id is the same as userspice's user id or if that is paypal's user id.
Either way, I would make 5 columns in the database
paypal_id
payment_id
hash
premium
premium_expire
All varchar(255 or whatever) except the last one which should be date.
You can obviously make this fancier, but that's how I would do it to get started.
Then, right after that catch statement on line 88 I would add my update query
//Your math to add however many days to todays date in your date format
//update the logged in user's account info
Here's that last bit on hastebin....
https://hastebin.com/furerinaqe.php
I would go right up to line 2 and
Code:
require_once 'users/init.php';
Then if you go down to the bottom, it looks like you're getting 3 things back...
user_id
payment_id
hash
I can't tell if that user_id is the same as userspice's user id or if that is paypal's user id.
Either way, I would make 5 columns in the database
paypal_id
payment_id
hash
premium
premium_expire
All varchar(255 or whatever) except the last one which should be date.
You can obviously make this fancier, but that's how I would do it to get started.
Then, right after that catch statement on line 88 I would add my update query
Code:
$expiry =
Code:
$fields = array (
Code:
'paypal_id' => $_SESSION['user_id'],
Code:
'payment_id' => $payment->getId(),
Code:
'hash' => $hash,
Code:
'premium' => 'premium',
Code:
'premium_expire' => $expiry,
Code:
);
//update the logged in user's account info
Code:
$db->update('users',$user->data()->id,$fields);
Here's that last bit on hastebin....
https://hastebin.com/furerinaqe.php