The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Integrating with PayPal
#3
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
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 =
//Your math to add however many days to todays date in your date format

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

  Reply


Messages In This Thread
Integrating with PayPal - by gathr - 01-14-2017, 04:50 PM
Integrating with PayPal - by gathr - 01-15-2017, 02:00 AM
Integrating with PayPal - by mudmin - 01-15-2017, 02:38 PM
Integrating with PayPal - by gathr - 01-17-2017, 09:43 AM
Integrating with PayPal - by mudmin - 01-17-2017, 02:23 PM
Integrating with PayPal - by gathr - 02-02-2017, 10:13 AM
Integrating with PayPal - by gathr - 02-08-2017, 12:22 AM
Integrating with PayPal - by mudmin - 02-14-2017, 02:22 PM
Integrating with PayPal - by gathr - 02-14-2017, 10:16 PM
Integrating with PayPal - by radke - 10-10-2017, 11:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)