开发者

Paypal transaction insertin '0' as value

have this paypal page which is working fine only when paypal posts back its not inserting my correct value (By this I mean its inserting '0'), please take a look...

<?php
require 'config.inc.php';

$p = new Paypal();

if(isset($_GET['period']))
{
  $allowedPeriods = array("1000", "5000", "10000", "20000");

  if(!in_array($_GET['period'], $allowedPeriods))
  {
    die("Allowed periods are '1000', '5000', '10000', '20000'");
  }

  if(!$usersClass->checkLoggedIn())
  {
    die("You must be logged in");
  }

  $prices = array( "1000" => 10, "5000" => 30, "10000" => 50,  "20000" => 85 );

  $this_script = "http://".$_SERVER['HTTP_HOST']."/paypal.php?act=";

  $p->add_field('business', PAYPAL_EMAIL_ADDRESS);
  $p->add_field('return', $this_script.'success');
  $p->add_field('cancel_return', $this_script.'cancel');
  $p->add_field('notify_url', $this_script.'ipn');
  $p->add_field('item_name', 'Credits');
  $p->ad开发者_JAVA技巧d_field('cmd', '_xclick');
  $p->add_field('amount', $prices[$_GET['period']]);
  $p->add_field('custom', $usersClass->userID()."||".$_POST['period']);
  $p->add_field('rm', '2'); 
  $p->add_field('currency_code','GBP');

  $p->submit_paypal_post();  
}
if(isset($_GET['act'])) {
  switch ($_GET['act']) {
    case "cancel": print "Order was canceled!";
    break;
    case "success":
    print "If payment was successfully received you should be on the top!"; 
    break;
    case "ipn": if ($p->validate_ipn()) {
      $custom = $_POST['custom'];
      $explode = explode("||", $custom); 
      $userid = (int) $explode[0];
      $days = $explode[1];
      $daysArray = array(10 => 1000, 30 => 5000, 50 => 10000, 85 => 20000 );
      $days = $daysArray[$days];
      $tillDate = $days;
      mysql_query("insert into `featured` values (null, '$userid', '$tillDate')")
    }
    break;
  }
}
?>


I suggest you set error_reporting(E_ALL) and do a post yourself on the ipn script to test it out. 0 could also mean FALSE before using (int) in front of it so it's crucial that you open all errors and see the response yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜