PAY PAL IPN SCRIPTS TO INSERT ORDERS AFTER PAYMENT AT PAY PAL
http://www.bobbyprogramdownload.com/ordersipn_listener.php
<?php
$request="_notify_validate";
foreach ($_POST $key => $value) {
$request .= "&$key=$value";
}
$RECEIVER_EMAIL = $_POST['receiver_email'];
$PAYER_EMAIL = $_POST['payer_email'];
$NUM_CART_ITEMS = $_POST['num_cart_items'];
$STREET_ADDRESS = $_Post[‘street_address’];
$CITY_ADDRESS = $_Post[‘city_address’];
$STATE_ADDRESS = $_Post[‘state_address’];
$COUNTRY_ADDRESS= $_Post[‘country_address’];
$fp = fsockopen("www.paypal.com","80");
fputs( $fp, $header.$request);
while (!feof($fp)) {
$res =fgets($fp, 1024);
if ($res =="verified") {
$CMPID = 1;
$SQLNUMBERS = " SELECT * FROM NUMBERS ";
$SQLNUMBERS .= " WHERE CMPID=";
$SQLNUMBERS .= $CMPID;
$FNUMBERS = mysql_query($SQLNUMBERS , $CON);
$NUMBERS = mysql_fetch_object($FNUMBERS);
$ORDERNO = $NUMBERS->ORDERNO;
$ORDERNO = $ORDERNO + 1;
$SQLNUMBERS = " UPDATE NUMBERS SET ";
$SQLNUMBERS .= " ORDERNO =";
$SQLNUMBERS .= $ORDERNO;
$SQLNUMBERS .= " WHERE CMPID=";
$SQLNUMBERS .= $CMPID;
$COUNTER = 0;
while ($COUNTER <=$NUM_CART_ITEMS) {
$COUNTER = $COUNTER + 1;
$ITEM_NAME_FIELD="item_name".$COUNTER;
$QUANTITY_FIELD ="quantity".$COUNTER;
$AMOUNT_FIELD ="mc_gross".$COUNTER;
$ITEM_NAME = $_Post[$ITEM_NAME_FIELD];
$QTYORD = $_Post[$QUANTITY_FIELD];
$SPRICE = $_Post[$AMOUNT_FIELD];
$AMOUNT = $QTYORD * $SPRICE;
$SQLITM =" SELECT * FROM PRODUCT ";
$FPRODUCT =mysql_query($SQLITM, $CON);
while ( $ITMMST = mysql_fetch_object($FPRODUCT)) {
$ITEMNO = $ITMMST->ITEMNO;
$DESCRIPTION = $ITMMST->DESCRIPTION;
$POSITION = strpos( $ITEM_NAME, $DESCRIPTION);
if ( $POSITION == 0 ) {
}
else {
}
}
$SQLORDERS = " INSERT INTO ORDERDETAIL VALUES ";
$SQLORDERS .= "(";
$SQLORDERS .= $ORDERNO;
$SQLORDERS .= ",";
$SQLORDERS .= $ITEMNO ;
$SQLORDERS .= ",";
$SQLORDERS .= $QTYORD;
$SQLORDERS .= ",";
$SQLORDERS .= $SPRICE;
$SQLORDERS .= ",";
$SQLORDERS .= $AMOUNT;
$SQLORDERS .= ")";
}
$FLAG = 0;
$SQLCUS = " SELECT * FROM CUSTOMER ";
$FCUSTOMER = mysql_query($SQLCUS, $CON);
while ($CUSTOMER = mysql_fetch_object($FCUSTOMER)) {
$CUSTNO = $CUSTOMER->CUSTNO;
$EMAIL = $CUSTOMER->EMAIL;
if ( $EMAIL == $PAYER_EMAIL) {
$FLAG = 1;
}
}
if ($FLAG == 1) {
$ORDERSQL = " INSERT INTO ORDHED VALUES ";
$ORDERSQL .= "(";
$ORDERSQL .= $ORDERNO;
$ORDERSQL .= ",";
$ORDERSQL .= $ORDDAT;
$ORDERSQL .= ",";
$ORDERSQL .= $CUSTNO;
$ORDERSQL .= ",";
$ORDERSQL .= $PAYMENTMETHOD;
$ORDERSQL .= ",";
$ORDERSQL .= $STATUS;
$ORDERSQL .= ")";
}
}
else {
}
}
?>
No comments:
Post a Comment