ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Simple Commerce IPN

September 19, 2012 4:59am

Subscribe [1]
  • #1 / Sep 19, 2012 4:59am

    Hench

    3 posts

    Hi all,

    I’m most of the way through the build of my current site, but I’ve come unstuck getting Simple Commerce to show purchases.

    I’ve set up IPN and it appears to be working correctly within Paypal. I’ll paste the request code in a second.

    Now, to list out my store items I’m using a custom form based on an article in the wiki (probably this one).

    Here’s how it looks in my template (with some omissions for anonymity)

    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="cart">
    
           <input type="hidden" name="cmd" value="_cart" />
    
           <input type="hidden" name="notify_url" value="http://qa.mydomain.com/index.php?ACT=12" />  
           <input type="hidden" name="return" value="{site_url}index.php/store/thankyou" />  
           <input type="hidden" name="cancel_return" value="{site_url}index.php/store/{categories}{category_name}{/categories}" />  
    
           <input type="hidden" name="business" value="[email protected]" />
           <input type="hidden" name="currency_code" value="USD" />
           <input type="hidden" name="lc" value="US" />
           <input type="hidden" name="custom" value="1" />
    
           <input type="hidden" name="item_name" value="{title}" />
           <input type="hidden" name="item_number" value="{item_id}" />
           
           <input type="hidden" name="add" value="1" />
    
           <input type="hidden" name="no_shipping" value="1" />
           <input type="hidden" name="no_note" value="1" />
           <input type="hidden" name="undefined_quantity" value="1" />
           <input type="hidden" name="custom" id="reg" value="{item_regular_price}" />
           <input type="hidden" name="custom1" id="var" value="{other_variation_price}" />
           
           <div class="addtoCart">
            {if variations == null}
             <input type="hidden" name="amount" value="{item_regular_price}" />
            {/if}
            {if variations != null}
            
             
             <input type="hidden" name="on0" value="Option" />
             <input type="hidden" name="os0" value="" id="option">
             
             <select name="amount" id="itemOptions">
              {variations}
               <option value="{item_regular_price}" title="{item}">{item}</option>
              {/variations}
              {if other_variations != null}
              {other_variations}
               <option value="{other_variation_price}" title="{item}">{item}</option>
              {/other_variations}
              {/if}
             </select>
            
            {/if}
            <input type="submit" value="Add to Cart" alt="Add to Cart" />
           </div>
          </form>

    As you can see, it is quite custom.

    So, this all works fine and I can buy items etc with no hassle. But the IPN simply isn’t coming through to the site.

    Now, I read something about the buyer needing to be logged into expression engine. I thought to myself, “that can’t be right”, but if it is, please let me know. If that is indeed right, that seems a bit crazy. At any rate, I would be logged in as the site admin whilst making my test purchases.

    Here’s what Paypal is sending back to the notification URL (matches above):

    // i've split these lines so it's easier to read
    mc_gross=1.00&
    item_mpn1=&
    protection_eligibility=Ineligible&
    item_count_unit1=0&
    item_number1=10&
    tax=0.00&payer_id=LCL8UT28EHRK2&
    payment_date=03:38:01 Sep 18, 2012 PDT&
    item_tax_rate1=0&
    option_selection1_1=Large&
    payment_status=Completed&
    charset=windows-1252&
    mc_shipping=0.00&
    item_tax_rate_double1=0.00&
    mc_handling=0.00&
    first_name=firstname&
    mc_fee=0.34&
    notify_version=3.6&
    custom=1.00&
    payer_status=verified&
    [email protected]&
    num_cart_items=1&
    mc_handling1=0.00&
    verify_sign=A.blwIALVY3q8s0Qh4LRlBxXuJl3A2pM7ZOWUjvoXzoB9iAPh5lgmMVe&
    [email protected]&
    mc_shipping1=0.00&
    item_style_number1=&
    tax1=0.00&
    option_name1_1=Option&
    item_plu1=&
    txn_id=1KE75873MY779912V&
    payment_type=instant&
    payer_business_name=BusinessName&
    last_name=Lastname&
    item_isbn1=&
    item_name1=Test item&
    [email protected]&
    payment_fee=0.34&
    quantity1=1&
    receiver_id=HH3FLWBBJEBRJ&
    txn_type=cart&
    item_model_number1=&
    mc_gross_1=1.00&
    mc_currency=USD&
    item_taxable1=N&
    residence_country=AU&
    transaction_subject=1.00&
    payment_gross=1.00&
    ipn_track_id=650071dd60283

    Any ideas what I may be doing wrong?

    I can’t see that it would have anything to do with using a subdomain, but is there anything else I may need to setup on the server, or a flaw in my store template? I’m stumped.

    Many thanks for any insight into this matter.

    Dan

  • #2 / Sep 20, 2012 4:25pm

    Kevin Smith

    4784 posts

    Hi Hench,

    It’s true that IPN features only work for purchases made by logged-in members of the site, as noted in the documentation.

    So the first step in troubleshooting this is to check the incoming IPN data as EE sees it. Simple Commerce actually has a way to send an email with this data, and here’s how you enable that:

    Open up /system/expressionengine/modules/simple_commerce/mod.simple_commerce.php, and change this variable near the beginning of the file to read:

    var $debug_incoming_ipn = TRUE;

    Next change this variable to the email address you want to receive this data dump:

    var $debug_email_address = '[email protected]';

    Save that file to your server, and then run another test purchase. Post that data dump back here for us to inspect, and you can cleanse it to remove private information if you need to.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases