in

AlertPay Developers Community

Advanced IPN - PHPEcono 1.1 (Debugger included)

Last post 10-19-2009 1:29 PM by Beaster. 54 replies.
Page 2 of 4 (55 items) < Previous 1 2 3 4 Next >
Sort Posts: Previous Next
  • 09-04-2008 10:29 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

     So... what's happening? No New News??

  • 09-04-2008 10:38 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

    Sorry let me try to reproduce your problem and will update you when I find the solution. I did not encounter this phenomenon during my testing.
  • 09-08-2008 2:44 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

     While you are working on that, I have a question for you.

     I have an IPN Script that I used to use with paypal ... If I sent it to you, could you modify it to work with AlertPay?

     If so, how much would you charge me to do that?

     Let me know ... 

  • 09-22-2008 10:41 AM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

    As Beaster wrote the code, a customer could edit the html and lower the price of the product, right? So you need to also verify the amount paid too, but if the item cost the buyer paid is lowered by the alertpay fee, you would need to consider that also? Example: My product costs 20$. Someone buys it. How much will ap_totalamount be when I get IPN? Will it say 20 or 18.75 (20$ deducted 5% + 0.45$)

  • 09-22-2008 1:58 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

     Yes, that's a great point - an IPN Script needs to verify the Amount Paid - to ensure the person buying it didn't alter the price before purchasing it; This would protect a person from releasing a digital product that has not been fully paid for.

     I wish my php skills were better, or I'd write this script myself; I'm guessing Beaster has had some issues in getting the script right, so that is the reason for his silence here -- working out the kinks in a script can be very Tough; But I think he got us all off to a good start; now we just need some people with good Coding ability to come and sure things up.

    The script I used for PayPal was excellent because it does/did what you're suggesting - the item #, price, location of the file, were all In the script - and the script would Verify these values before validating the purchase, and before emailing the customer their digital product -- Later versions allowed you to input your products into a mySql database, and then did the same thing - verifying each value before validating and finalizing the sale.

    So, I'm sure this can be done - but, by whom??

     

  • 09-23-2008 9:15 AM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

    I can solve those problems, but I have two questions first. When someone from alertpay staff answers them, I will post the code.

    1. What does ap_totalamount variable holds? Is it the exact price of my product or is it increased/decreased by fees? What im asking is, is it the price of the product the customer paid or is it how much was transfered to my account including the fees?

    2. When testing my IPN url I noticed there is no referrer and the remote ip was 67.205.87.226. Referrer should be at least something like http://www.alertpay.com/IPNCaller.aspx but I can manage without it also. Im interested in the alertpay IP addres. The page that called my alerturl had an IP of  67.205.87.226.Can this IP change and what values can it take?

  • 09-23-2008 10:54 AM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

    ap_amount is the cash the guy pais before ap_additionalcharges, ap_shippingcharges, ap_taxamount and ap_discountamount are added to it. The final amout is ap_totalamount

    I am sorry i didint have time to solve your problem yet. I am facing a time issue at the moment. I have 3 websites to finish in a very small amount of time so i didin't set up a test environement to see if i can repreduce your error. But in one of tose 3 i am gona need to set up a new IPM script so i am planning making an update to the Advanced IPN. I should be able to take a look at your problem at the same time.

    Theres one thing you can try thought ... Try making an item in your alertpay account and use the generated code forme to see if the transaction works that way. If it does, then your problem is from your forme.

     Dejangex, send me your updates if you have any, i will incorperate it to the next version.

  • 09-23-2008 11:54 AM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

    ap_totalamount is the total amount, the exact price that you have set for your product(s) [which includes the fee charged to you]. If you have one product of 20$, ap_totalamount will have 20. It holds the price of the product that your customer paid. [The amount transferred to your account will be 20-fees.]

    The IP doesn't change. We don't create a page while processing on payprocess, we send the http form post
  • 09-23-2008 1:17 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

    I am planing to make my own site that uses alertpay and generic items and I have studied the IPN integration. Here are some things to check for:

    1. Is the IPN really comming from the alertpay? This is the code to check the IP(assuming that the IP will not change):

    if($_SERVER['REMOTE_ADDR'] != '67.205.87.226')
    {
        //Invalid transaction,IP not from alertpay
        //log it or whatever and check maybe who tried to *** you
    }
    2. Check that the right price was paid for the product(use this if you sell one item at a time and dont have many items):

    <?php
    //Hardcoded way:
    $item_code = $_POST['ap_itemcode']; //The code of the item
    $amount_paid = $_POST['ap_totalamount']; //How much was paid for the item

    switch ($ap_itemcode) {

    case "myitemcode1":
        if ($amount_paid == "20.00") {//good boy, paid the exact amount} else {//BAD BOY, he messed with the code}
        break;

    case "myitemcode2":
        if ($amount_paid == "7.40") {//paid} else {//did not pay}
        break;

    case "myitemcode3":
        if ($amount_paid == "2.33") {//paid} else {//did not pay}
        break;

    default:
        //invalid item code
    }
    ?>

    3. Check that the right price was paid for multiple product:
    For this you will need to go pro with mysql and all. You will have a sql database with item names, codes and prices. Using Beasters code you would get.

    <?php
    //Assumes that you have you sql connection setup already
    $item_code = $_POST['ap_itemcode']; //The code of the item(s), in this case it is "123-456-789" so we need to break it down in 3 parts later
    $amount_paid = $_POST['ap_totalamount']; //How much was paid for the item(s)
    $amount_that_should_be_paid = 0.00; //Set this later in code

    $ap_itemcode = explode('-', $ap_itemcode);
    // $ap_itemcode[0] = "123";
    // $ap_itemcode[1] = "456";
    // $ap_itemcode[2] = "789";

    // you can loop those by doing this
    foreach ($ap_itemcode as $itmCode) {
        $query  = "SELECT price FROM items WHERE item_code='$itmCode'"; //Find the item in the database
        $row = mysql_fetch_array($result);                //Grab the data to an array
        $amount_that_should_be_paid += $row['price'];             //Add up to the total price
    }

    $amount_that_should_be_paid = number_format($amount_that_should_be_paid, 2, ".", ""); //turn the number into xxxx.xx format just to be sure

    if ($amount_paid != $amount_that_should_be_paid)
    {
        //something wrong, amounts dont add up
    }
    else
    {
        //customer paid all
    }

    ?>

    *Note: I did not test this code
    **Note: For points 2 and 3, if you pass value like 9 or 9.3 it will be returned in the same format when it gets posted to your IPN url. Use number_format($number, 2, ".", ""); function to turn any number into x.xx format(that is, with two numbers behind decimal)
    ***Note: IP check can be spoofed, dont rely only on this, and dont forget: the security code check can also fail if someone can read your php file and this can happen if you have security holes, which most probably you do.  You are never safe!
  • 09-23-2008 1:31 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

    Far best way to handle multiple items would be to store orders of items into your own databse, along with the username of the customer, his email etc. and then send the unique number of that order to alertpay as $ap_itemcode. Then when you get IPN you can check with your database if the record exists and is the amount paid right. If there are any questions, do not hesitate to ask.
  • 09-23-2008 5:05 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

     These are some great breakthrough's I think -- but I'm going to have to take a look at all this a little later -- however all of this is good. 

    As it stands right now you two may be the only Developers working out the kinks, to get a very good, working IPN script that can meet the needs of many people using this processor.

    I wanted to say, Beaster and Dejangex, that the earlier Code provided for selling items "on the fly" - w/out having to create each item In the alertpay business account manager, Works just fine -- I've actually plugged it in on a page and am now tying in amounts and information and it's all working perfectly.

    However the Other issue I had -- is still the same; which, is kind of odd I must say -- since it works on one page but not the other. 

    Hope I didn't confuse you; but the problem may just be IN the form; I'll take a look at that today too; and don't worry man I know you're going to get to it when you can; I design sites too, run sites, so things tend to get busy; I just am more of a designer than a coder and you two fellas know more about coding than I.  

    I do beleive however, like the other guy mentioned, whats sent to alertpay, is the fee, BEFORE their fee's are applied.

    So if your item is $20 - what they pay is $20, and then You get $18,  after alertpay takes their fee's.

    At least that's how it's working on my page... 8.99 converts to 8.99 on the payout page -- so, that's my assumption and belief.

    :)

  • 09-23-2008 6:21 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

    Yes, indeed, Ive fully tested IPN and ap_amount is the fee users will see on your page and what you will post to the alertpay. You will later be returned this same value. ap_totalamount will give you back ap_amount +/- tax fee, shipping fee etc. Fees that alertpay takes are not included in this value.

    I have posted few topics in the new feature forum so we will see if AP staff do something about it. If they add them, it will be great for merchants, and more ppl would use AP on their sites.

  • 12-08-2008 11:09 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

     This topic kind of died out...

     I've actually  been using the first code; works very well to "Send items to alertpay ON the fly" - so my kudos to Beaster once again for his excellent coding work;  Dejangex; I'm interested in what you were doing as well; finding a way to black a transaction that didn't come From AlertPay; or a way to make sure people paid what they were supposed to pay.

    I may need to drop you a line about that; or we could go over here here - it is probably more beneficial to be here, for other people looking for answers; Im sure this thread has helped out many so far; often Silent about the help in the forum - but what I'm really looking for, is a way to pass all the amounts to a Variable on a .php page - that will then Send a Total Amount to alertpay, for more than one good.

     I "think" Beaster was explaining how to do it when he originally answered the 'on the fly' script question.

     

    Beaster:
    Well i guess it always depens of what you need. But what i do is simply use this:

    <?php

    // Item Type
    $ap_purchasetype = 'item';

    // The your alertpay email
    $ap_merchant = 'test@yourdomain.com';

    // Item name
    $ap_itemname = 'My item name';

    // Item description
    $ap_description = 'My Item Description';

    // The currency used (USD, CAD, EUR ...)
    $ap_currency = 'USD';

    // The thank you page
    $ap_returnur = 'http://...';

    // The failed URL
    $ap_cancelurl = 'http://...';

    // Item number
    $ap_itemcode = '123abc-cda321';

    // Item quantity
    $ap_quantity = '1';

    // Amount to pay
    $total = '9.99';

    // Submit button image URL
    $img_url = 'http://...';

    // This is the form. The only visible part is the submit button. This should appear in the transaction overview page.

    print('<form method="POST" action="https://www.alertpay.com/PayProcess.aspx">  

    <input type="hidden" name="ap_purchasetype" value="'
    .$ap_purchasetype.'"/>  
    <input type="hidden" name="ap_merchant" value="'
    .$ap_merchant.'"/>  
    <input type="hidden" name="ap_itemname" value="'
    .$ap_itemname.'"/>  
    <input type="hidden" name="ap_currency" value="'
    .$ap_currency.'"/>  
    <input type="hidden" name="ap_returnurl" value="'
    .$ap_returnur.'"/>  
    <input type="hidden" name="ap_itemcode" value="'
    .$ap_itemcode.'"/>  
    <input type="hidden" name="ap_quantity" value="'
    .$ap_quantity.'"/>  
    <input type="hidden" name="ap_description" value="'
    .$ap_description.'"/>  
    <input type="hidden" name="ap_amount" value="'
    .$total.'"/>  
    <input type="hidden" name="ap_cancelurl" value="'
    .$ap_cancelurl.'"/>
    <input type="image" name="ap_image" src="'
    .$img_url.'"/>

    </form>'
    );

    ?>

    Then by using the advanced IPN you simply add the
    insert into or update you need to finish up the transaction on your end.

    Theres 2 places you can add it. to the (If this is a test) and (The paiement was sucessful)

    And for your secounde question, i simply seperate the item numbers by - and store them in the transaction database. When i need to list them out for some reason i simply explode the numbers and loop them like this

    <?php

    $ap_itemcode
    = explode('-', $ap_itemcode);
    // $ap_itemcode[0] =" 123abc"
    // $ap_itemcode[1] = cda321

    // you can loop those by doing this
    foreach ($ap_itemcode as $itemnumber) {

    }

    ?>

    I hope this helps out. If you have more questions, go ahead.

    I dont know what the 'transaction database' is - I would prefer to do this without using a database on my server; and would prefer to send it all to a .php page - that when accessed can work Like a Checkout page - where you to go Review your order; and when you're ready - you Place it; sending all itemcodes and itemnumbers, prices, etc... To Alertpay.

     Is that possible?

     

     

  • 12-10-2008 6:12 PM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)


    Hi,

     I need someone to create me a IPN! which is customized and stuff

    Any developer please contact me at gr8est4u@gmail.com

      Hello,

    I read your IPN PDF Guide, which didn't answer my questions.
    I would like to have a IPN website thing, from which people can pay $$ diffrently,

    I am the administrator of the program, so suppose you come under me, you would pass me your 2nd 4th 8th 16th 32nd [keep multiplying by 2] sale FOREVER. each sale is 90$ [ 30$ fixed admin fee and 60$ program joining fee]

    so like this u keep paying me and same goes on with any other people i make... and then this chain goes for people that you make and people they make and on and on!

    Could someone help me code it and make a IPN for me

     

    Please contact me at gr8est4u@gmail.com with Title - AlertPay IPN code developing

     

  • 12-11-2008 2:15 AM In reply to

    Re: Advanced IPN - PHPEcono 1.1 (Debugger included)

     Well Frankly, what you're talking about here is illegal.

     I doubt anyone will help you out with using alertpay in that manner - as it would jeapordize All of us who use it legally.

     If you were Selling a Product or a Service; then that would be a little different; but what you're describing; is a pyramid or ponzi scheme. Which is NOT the same as an affiliate program, or network marketing - good luck though.

Page 2 of 4 (55 items) < Previous 1 2 3 4 Next >

  AlertPay - Verified by Visa AlertPay - secure credit card and checking services BBBOnline Reliability Program