-
Notifications
You must be signed in to change notification settings - Fork 13
/
paypal_checkout.php
60 lines (43 loc) · 1.17 KB
/
paypal_checkout.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once('includes/header.php');
require_once('includes/order.lib.php');
payment_main();
function payment_main() {
$user = user_isonline();
if ($user === false) {
payment_die(_('Please login before checkout'));
}
$sid = @$_GET['serviceid'];
$sid = (int)$sid;
$sql = "SELECT * FROM service WHERE id=$sid";
$res = db_query($sql);
if ($res == false || db_num_rows($res) == 0) {
payment_die(_('We have no this service'));
}
$arr = db_fetch_array($res);
$orderarr = order_new($sid);
if ($orderarr == false) {
payment_die(_('Checkout fail, please contact us for help'));
}
/// 使用 PayPal 进行支付
$ret = paypal_new_payment($orderarr['orderid'], $amount);
if ($ret == false) {
payment_die(_('Checkout fail, please contact us for help'));
}
payment_redirect(PAYPAL_REDIRECTURL . '?token=' . $ret['token']);
}
function payment_die($msg) {
global $smarty;
$smarty->assign('error_msg', $msg);
$smarty->display('error.html');
die();
}
function payment_redirect($url) {
global $smarty;
$url = urlencode($url);
header("Location: $url");
$smarty->assign('redirect_url', $url);
$smarty->display('paypal_redirect.html');
die();
}
?>