0

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.

Edited by liamfriel: n/a

1
Contributor
1
Reply
3
Views
6 Years
Discussion Span
Last Post by liamfriel
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.