PHP - Recoger variables de retorno en tienda virtual PHP

 
Vista:
Imágen de perfil de marti

Recoger variables de retorno en tienda virtual PHP

Publicado por marti (5 intervenciones) el 17/09/2017 18:13:50
Hola,

Tengo una tienda virtual hecha con PHP que desde que paypal cambio el estilo de la web no me funciona bien al leer las variable de retorno POST que devuelve después de una compra.
Antes, cuando la web de paypal era más "antigua" funcionaba correctamente.

Por lo que parece paypal no me pasa las variables POST.

Cuando el cliente ha realizado la compra sale el siguiente error:

Notice: Undefined index: mc_gross in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 144

Notice: Undefined index: mc_currency in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 145

Notice: Undefined index: txn_id in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 146

Notice: Undefined index: receiver_email in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 147

Notice: Undefined index: mc_shipping in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 148

Notice: Undefined index: shipping in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 148

Notice: Undefined index: address_name in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 149

Notice: Undefined index: address_street in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 150

Notice: Undefined index: address_city in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 151

Notice: Undefined index: address_zip in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 152

Notice: Undefined index: address_state in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 153

Notice: Undefined index: payer_email in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 154

Notice: Undefined index: first_name in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 155

Notice: Undefined index: last_name in /Applications/XAMPP/xamppfiles/htdocs/BotigaVirtual/codiFont/return.php on line 156

El error surge en la siguiente parte de código:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$payment_status = $_POST ['payment_status'];
$payment_amount = $_POST ['mc_gross'];
$payment_currency = $_POST ['mc_currency'];
$txn_id = $_POST ['txn_id'];
$receiver_email = $_POST ['receiver_email'];
$shipping = (is_null ( $_POST ['mc_shipping'] ) ? $_POST ['shipping'] : $_POST ['mc_shipping']);
$address_name = $_POST ['address_name'];
$address_street = $_POST ['address_street'];
$address_city = $_POST ['address_city'];
$address_zip = $_POST ['address_zip'];
$address_state = $_POST ['address_state'];
$payer_email = $_POST ['payer_email'];
$first_name = $_POST ['first_name'];
$last_name = $_POST ['last_name'];

Esta es la parte de codigo en que se hace la petición a paypal:
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
<div id="paypalSenseTransport" align="center" style='display: none'>
	<br />
	<!-- URL per a compres reals: https://www.paypal.com/cgi-bin/webscr -->
	<form name="cart"
		action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
		<input type="hidden" name="cmd" value="_cart"> <input type="hidden"
			name="upload" value="1"> <input type="hidden" name="no_shipping"
			value="1"> <input type="hidden" name="business"
			value="[email protected].com" />
<?
 
if ($carru) {
	$i = 1;
	foreach ( $carru as $foto ) {
		?>
<input type="hidden" name="item_name_<?=$i?>"
			value="<?php echo $foto['nomarxiu'] ?>" /> <input type="hidden"
			name="quantity_<?=$i?>" value="<?php echo $foto['quantitat']; ?>"> <input
			type="hidden" name="item_number_<?=$i?>"
			value="<?php echo $foto['tamany'] ?>" /> <input type="hidden"
			name="amount_<?=$i?>" value="<?php echo $foto['preu'] ?>" />
<?
		$i ++;
	}
}
?>
<input type="hidden" name="cn" value="Comentarios" /> <input
			type="hidden" name="currency_code" value="EUR" /> <input
			type="hidden" name="lc" value="EU" /> <input type="hidden" name="bn"
			value="PP-BuyNowBF" /> <input type="hidden" name="rm" value="2"> <input
			type="hidden" name="return"
			value="http://localhost/BotigaVirtual/codiFont/return.php" /> <input
			type="hidden" name="cbt" value="Volver a la tienda"> <input
			type="hidden" name="cancel_return"
			value="http://localhost/BotigaVirtual/codiFont/cancel.html"> <input
			type="image"
			src="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"
			name="submit"
			alt="Make payments with PayPal - it's fast, free and secure!" /> <img
			alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif"
			width="1" height="1" />
	</form>
</div>

Muchas grácias de antenmano!!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder