-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaypal.php
More file actions
44 lines (39 loc) · 900 Bytes
/
paypal.php
File metadata and controls
44 lines (39 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* paypal
*
* @package Sngine
* @author Zamblek
*/
// fetch bootstrap
require('bootstrap.php');
// user access
if(!$user->_logged_in) {
user_login();
}
// process paypal payments
try {
if($_GET['status'] == 'success') {
// valid inputs
if(!isset($_GET['package_id']) || !is_numeric($_GET['package_id'])) {
_error(400);
}
if(!isset($_GET['paymentId']) || !isset($_GET['PayerID'])) {
_error(400);
}
// check package
$package = $user->get_package($_GET['package_id']);
if(!$package) {
_error(400);
}
// check payment
$payment = paypal_check($_GET['paymentId'], $_GET['PayerID']);
if($payment) {
// update user package
$user->update_user_package($package['package_id'], $package['name'], $package['price']);
}
}
redirect();
} catch (Exception $e) {
_error('System Message', $e->getMessage());
}