User id wilt niet mee werken.
Ik heb een paypal script voor een webshop van een klant. Maar nu wil ik dat hij je user id meegeeft. Maar dat doe hij niet.
Als ik het zo doe dan werkt het:
Code (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
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
if($lid->ingelogd() === TRUE)
{
$info = $lid->info(array('id', 'cart_sec'));
$cartQuery = $mysql->query("SELECT
producten.price,
winkelwagen.id AS winkelwagen_id
FROM
cart winkelwagen,
products producten
WHERE
winkelwagen.lid = '".$info['id']."'
AND
winkelwagen.deleted = 0
AND
winkelwagen.article = producten.id
AND
producten.deleted = 0");
$prijs = 0;
while($cartFetch = $mysql->fetch($cartQuery))
{
$prijs += $cartFetch['price'];
}
}
$_SESSION['lid_id'] = $info['id'];
$item_name = $info['id'];
$lidid = $info['id'];
$item_amount = $prijs;
{
$info = $lid->info(array('id', 'cart_sec'));
$cartQuery = $mysql->query("SELECT
producten.price,
winkelwagen.id AS winkelwagen_id
FROM
cart winkelwagen,
products producten
WHERE
winkelwagen.lid = '".$info['id']."'
AND
winkelwagen.deleted = 0
AND
winkelwagen.article = producten.id
AND
producten.deleted = 0");
$prijs = 0;
while($cartFetch = $mysql->fetch($cartQuery))
{
$prijs += $cartFetch['price'];
}
}
$_SESSION['lid_id'] = $info['id'];
$item_name = $info['id'];
$lidid = $info['id'];
$item_amount = $prijs;
En als ik hier info['id'] gebruikt, dan doe hij het niet:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
// PAYMENT VALIDATED & VERIFIED!
if($valid_txnid && $valid_price)
{
$orderid = updatePayments($data);mail("***", "PAYPAL succes", "Suucce'gffggfddds'".$data['item_name'].' - '.$info['lid_id']."'");
if($orderid)
{
if($valid_txnid && $valid_price)
{
$orderid = updatePayments($data);mail("***", "PAYPAL succes", "Suucce'gffggfddds'".$data['item_name'].' - '.$info['lid_id']."'");
if($orderid)
{
Hele code hieronder:
Code (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
define('ALLOW', FALSE);
define('PAGE_TITLE', 'Winkelwagen');
include 'includes/config.php';
// Database variables
$host = "localhost"; //database location
$user = "***"; //database username
$pass = "****"; //database password
$db_name = "***"; //database name
// PayPal settings
$paypal_email = '[email protected]';
$return_url = LINK.'payment-successful.htm';
$cancel_url = LINK.'payment-cancelled.htm';
$notify_url = LINK.'payments.php';
$item_name = 'Test Item';
$item_amount = 0.01;
// Include Functions
include("functions.php");
//Database Connection
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db_name);
if($lid->ingelogd() === TRUE)
{
$info = $lid->info(array('id', 'cart_sec'));
$cartQuery = $mysql->query("SELECT
producten.price,
winkelwagen.id AS winkelwagen_id
FROM
cart winkelwagen,
products producten
WHERE
winkelwagen.lid = '".$info['id']."'
AND
winkelwagen.deleted = 0
AND
winkelwagen.article = producten.id
AND
producten.deleted = 0");
$prijs = 0;
while($cartFetch = $mysql->fetch($cartQuery))
{
$prijs += $cartFetch['price'];
}
}
$_SESSION['lid_id'] = $info['id'];
$item_name = $info['id'];
$lidid = $info['id'];
$item_amount = $prijs;
// Check if paypal request or response
if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"]))
{
// Firstly Append paypal account to querystring
$querystring .= "?business=".urlencode($paypal_email)."&";
// Append amount& currency (£) to quersytring so it cannot be edited in html
//The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable.
$querystring .= "item_name=".urlencode($item_name)."&";
$querystring .= "amount=".urlencode($item_amount)."&";
//loop for posted values and append to querystring
foreach($_POST as $key => $value){
$value = urlencode(stripslashes($value));
$querystring .= "$key=$value&";
}
// Append paypal return addresses
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
$querystring .= "notify_url=".urlencode($notify_url);
// Append querystring with custom field
//$querystring .= "&custom=".USERID;
// Redirect to paypal IPN
header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring);
exit();
}else{
// Response from Paypal
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
$req .= "&$key=$value";
}
// assign posted variables to local variables
$data['item_name'] = $_POST['item_name'];
$data['item_number'] = $_POST['item_number'];
$data['payment_status'] = $_POST['payment_status'];
$data['payment_amount'] = $_POST['mc_gross'];
$data['payment_currency'] = $_POST['mc_currency'];
$data['txn_id'] = $_POST['txn_id'];
$data['receiver_email'] = $_POST['receiver_email'];
$data['payer_email'] = $_POST['payer_email'];
$data['custom'] = $_POST['custom'];
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp($res, "VERIFIED") == 0)
{
// Used for debugging
mail("***", "PAYPAL DEBUGGING", "Verified Response<br />data = <pre>".print_r($_POST, true)."</pre>");
// Validate payment (Check unique txnid & correct price)
$valid_txnid = check_txnid($data['txn_id']);
$valid_price = check_price($data['payment_amount'], $data['item_number']);
// PAYMENT VALIDATED & VERIFIED!
if($valid_txnid && $valid_price)
{
$orderid = updatePayments($data);mail("***", "PAYPAL succes", "Suucce'gffggfddds'".$data['item_name'].' - '.$data['lid_id']."'");
if($orderid)
{
}
else
{
mail("***", "PAYPAL DEBUGGING", "Kon niet in database zetten");
}
}else{
mail("***", "PAYPAL DEBUGGING", "Er is betaald maar info is veranderd.");
}
}else if (strcmp ($res, "INVALID") == 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
// E-mail admin or alert user
// Used for debugging
mail("***", "PAYPAL DEBUGGING", "Invalid Response<br />data = <pre>".print_r($post, true)."</pre>");
}
}
fclose ($fp);
}
}
?>
define('ALLOW', FALSE);
define('PAGE_TITLE', 'Winkelwagen');
include 'includes/config.php';
// Database variables
$host = "localhost"; //database location
$user = "***"; //database username
$pass = "****"; //database password
$db_name = "***"; //database name
// PayPal settings
$paypal_email = '[email protected]';
$return_url = LINK.'payment-successful.htm';
$cancel_url = LINK.'payment-cancelled.htm';
$notify_url = LINK.'payments.php';
$item_name = 'Test Item';
$item_amount = 0.01;
// Include Functions
include("functions.php");
//Database Connection
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db_name);
if($lid->ingelogd() === TRUE)
{
$info = $lid->info(array('id', 'cart_sec'));
$cartQuery = $mysql->query("SELECT
producten.price,
winkelwagen.id AS winkelwagen_id
FROM
cart winkelwagen,
products producten
WHERE
winkelwagen.lid = '".$info['id']."'
AND
winkelwagen.deleted = 0
AND
winkelwagen.article = producten.id
AND
producten.deleted = 0");
$prijs = 0;
while($cartFetch = $mysql->fetch($cartQuery))
{
$prijs += $cartFetch['price'];
}
}
$_SESSION['lid_id'] = $info['id'];
$item_name = $info['id'];
$lidid = $info['id'];
$item_amount = $prijs;
// Check if paypal request or response
if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"]))
{
// Firstly Append paypal account to querystring
$querystring .= "?business=".urlencode($paypal_email)."&";
// Append amount& currency (£) to quersytring so it cannot be edited in html
//The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable.
$querystring .= "item_name=".urlencode($item_name)."&";
$querystring .= "amount=".urlencode($item_amount)."&";
//loop for posted values and append to querystring
foreach($_POST as $key => $value){
$value = urlencode(stripslashes($value));
$querystring .= "$key=$value&";
}
// Append paypal return addresses
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
$querystring .= "notify_url=".urlencode($notify_url);
// Append querystring with custom field
//$querystring .= "&custom=".USERID;
// Redirect to paypal IPN
header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring);
exit();
}else{
// Response from Paypal
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
$req .= "&$key=$value";
}
// assign posted variables to local variables
$data['item_name'] = $_POST['item_name'];
$data['item_number'] = $_POST['item_number'];
$data['payment_status'] = $_POST['payment_status'];
$data['payment_amount'] = $_POST['mc_gross'];
$data['payment_currency'] = $_POST['mc_currency'];
$data['txn_id'] = $_POST['txn_id'];
$data['receiver_email'] = $_POST['receiver_email'];
$data['payer_email'] = $_POST['payer_email'];
$data['custom'] = $_POST['custom'];
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp($res, "VERIFIED") == 0)
{
// Used for debugging
mail("***", "PAYPAL DEBUGGING", "Verified Response<br />data = <pre>".print_r($_POST, true)."</pre>");
// Validate payment (Check unique txnid & correct price)
$valid_txnid = check_txnid($data['txn_id']);
$valid_price = check_price($data['payment_amount'], $data['item_number']);
// PAYMENT VALIDATED & VERIFIED!
if($valid_txnid && $valid_price)
{
$orderid = updatePayments($data);mail("***", "PAYPAL succes", "Suucce'gffggfddds'".$data['item_name'].' - '.$data['lid_id']."'");
if($orderid)
{
}
else
{
mail("***", "PAYPAL DEBUGGING", "Kon niet in database zetten");
}
}else{
mail("***", "PAYPAL DEBUGGING", "Er is betaald maar info is veranderd.");
}
}else if (strcmp ($res, "INVALID") == 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
// E-mail admin or alert user
// Used for debugging
mail("***", "PAYPAL DEBUGGING", "Invalid Response<br />data = <pre>".print_r($post, true)."</pre>");
}
}
fclose ($fp);
}
}
?>
Wie kan me helpen? Bedankt! :D
Gewijzigd op 24/11/2011 20:40:17 door Shahiem Seymor
Ik zie nergens dat je $data['lid_id'] vult met een waarde.