Clickbank IPN Help
Hope you can help me with this guys. I would like to use the IPN of clickbank but I don´t know how to do it well because there is not a good guy on how to set up a product with clickbank. So here I am going to show you my IPN code.
The probles is that When I tried to test the IPN. I receive a notification to my email but it doesnt execute the function workerSale to update the database. Can you please help me with that.
I already try refreshing the page manually and it works. But clicking on test IPN it doesn't work.
<?php // CLICKBANK IPN EMAIL NOTIFICATION SCRIPT // VERSION 6.0 $email_to = "romioaa@gmail.com"; $email_from = "Nueva Venta <clickbank@tareascortas.com>"; $secretKey = "17FSSFEDS54643TR"; $rawData = file_get_contents("php://input"); $json = json_decode($rawData, true); $notification = $json['notification']; $iv = $json['iv']; $notification = str_replace("\n","",$notification); $decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, substr(sha1($secretKey), 0, 32), base64_decode($notification), MCRYPT_MODE_CBC, base64_decode($iv)), "\0..\32"); $decrypted = trim($decrypted); //is not that important just for convience $decrypted = utf8_encode($decrypted); //is important if you have certain special chars that will be decrypted $order = json_decode($decrypted); // Product Item $product = $order->lineItems[0]; // Customer info $customer = $order->customer; $subject = "New Transaction: ".$order->transactionType.": $" . $order->totalAccountAmount; $message = "Transaction Time : ".$order->transactionTime."\n"; $message = "Product: ".$product->productTitle."\n"; $message .= "Vendor: ".$order->vendor."\n"; $message .= "Transaction Type: ".$order->transactionType."\n"; $message .= "Vendor: ".$order->itemNo."\n"; $message .= "monto: ".$order->totalAccountAmount."\n"; $var = $order->transactionType; $amout2 = $order->totalAccountAmount; if($order->affiliate) { $message.= "Affiliate: ".$order->affiliate."\n"; } if($order->trackingCodes->tracking_code) { $message.= "Tracking ID: ".$order->trackingCodes->tracking_code."\n"; } if($customer->shipping->fullName) { $message .= "Customer Name: " .$customer->shipping->fullName. "\n"; } if($customer->shipping->email) { $message .= "Customer Email: " .$customer->shipping->email. "\n"; } $message .= "Amount: $".$order->totalAccountAmount."\n"; $message .= "\n\nhttp://www.TareasCortas.com - MicrtoTrabajos"; $header = 'To: '.$email_fullname. "\r\n". 'From: '.$email_from. "\r\n" . 'Reply-To: '.$email_reply. "\r\n" . 'X-Mailer: PHP/' . phpversion(); if(mail($email_to,$subject,$message,$header)) { // Mail send } else { // Email not sending } ?> <?php session_start(); require_once("inc/auth.inc.php"); require_once("inc/config.inc.php"); $cc = 0; // update user activity time UpdateUserActivity($userid); /////////////// Page config /////////////// $PAGE_TITLE = "Mi Cuenta"; $username = $_SESSION['FirstName']; function workerSale($a) { smart_mysql_query("UPDATE jobfia_users SET balance=balance+".$a." WHERE user_id='1047' LIMIT 1"); } workerSale($amout2); ?> |