We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Trouble with subscr_cancel in Paypal IPN

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);
}

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.

1
Contributor
1
Reply
47 Minutes
Discussion Span
2 Years Ago
Last Updated
3
Views
Question
Answered
liamfriel
Junior Poster
103 posts since Oct 2009
Reputation Points: 13
Solved Threads: 13
Skill Endorsements: 0

Realised the logical error of putting the code in the else of the section where payment_status was not sent.

liamfriel
Junior Poster
103 posts since Oct 2009
Reputation Points: 13
Solved Threads: 13
Skill Endorsements: 0
Question Self-Answered as of 2 Years Ago

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0726 seconds using 2.82MB