Trouble with subscr_cancel in Paypal IPN

Discussion in 'PHP' started by Frails, Feb 25, 2011.

  1. #1
    Hello,

    I am using a script to process subscriptions on our sites - I can sucessfully get the subscription payment to process, I am having issues processing a cancel IPN request.

    
    // assign posted variables to local variables
    $item_name = make_safe($_POST['item_name']);
    $item_number = make_safe($_POST['item_number']);
    $payment_status = make_safe($_POST['payment_status']);
    $payment_amount = make_safe($_POST['mc_gross']);
    $payment_currency = make_safe($_POST['mc_currency']);
    $txn_id = make_safe($_POST['txn_id']);
    $txn_type = make_safe($_POST['txn_type']);
    $subscr_id = make_safe($_POST['subscr_id']);
    $receiver_email = $_POST['receiver_email'];
    $payer_email = make_safe($_POST['payer_email']);
    $custom = numOnly($_POST['custom']);
    $date = time();
    
    mail("lblah"," Payment","ID $custom.  $payment_status, $receiver_email TXN TYPE = $txn_type","From:NB");
    
    
    if (!$fp) {
    // HTTP ERROR
    } else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {
    }
    
    	//check the payment_status is Completed
    	if($payment_status != "Completed"){
    		$error .= "This Transaction has not been completed";
        //mail("lcah","$sitename Payment2","ID $custom.  $payment_status, $receiver_email $error FAIL","From: $sitename");
    	}else{
    		//check if cancelled
        if($txn_type == "subscr_cancel"){
      
        }
    
        if($txn_type == "recurring_payment_outstanding_payment_failed"){
          //cancel & remove
        }
    	}
    
    	// process payment
    	if(!$error){
               //works
    	}else{
                //works
    	}
    }
    elseif (strcmp ($res, "INVALID") == 0) {
    // log for manual investigation
    
    }
    }
    fclose ($fp);
    }
    
    PHP:
    I have tried the if $txn_type == "subscr_cancel" in several places but the easiest understanding I have is that $payment_status is not passed when a the IPN sends a cancel request.

    Does anyone have some hints or had similar difficulty with something like this before.

    Any help would be appreciated.
     
    Frails, Feb 25, 2011 IP
  2. Frails

    Frails Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have solved this issue - it was logical error in the payment status if
     
    Frails, Feb 25, 2011 IP