Results 1 to 10 of 11

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Location
    Ontario, Canada
    Posts
    27
    Plugin Contributions
    0

    help question Custom DB insert after payment confirmation

    Greetings,

    I'm trying to insert paypal_ipn_id and some other variables into a custom table on the Paypal payment is completed. But nothing gets inserted in the custom table.
    Assuming the correct way to do is to define custom table in the database_tables.php file and use the defined name in the paypal.php file shown below:

    PHP Code:
    function after_process() {    
    global 
    $insert_id$db;    
    if (
    $_SESSION['paypal_transaction_PDT_passed'] != true) {      
    $_SESSION['order_created'] = '';      
    unset(
    $_SESSION['paypal_transaction_PDT_passed']);      
    return 
    false;    
    } else {      
    unset(
    $_SESSION['paypal_transaction_PDT_passed']);      
    $sql "insert into " TABLE_ORDERS_STATUS_HISTORY " (comments, orders_id, orders_status_id, date_added) values (:orderComments, :orderID, :orderStatus, now() )";
          
    $sql $db->bindVars($sql':orderComments''PayPal status: ' $this->pdtData['payment_status'] . ' ' ' @ ' $this->pdtData['payment_date'] . "\n" ' Trans ID:' $this->pdtData['txn_id'] . "\n" ' Amount: ' $this->pdtData['mc_gross'] . ' ' $this->pdtData['mc_currency'] . '.''string');
          
    $sql $db->bindVars($sql':orderID'$insert_id'integer');
          
    $sql $db->bindVars($sql':orderStatus'$this->order_status'integer');
          
    $db->Execute($sql);

     
    $var2 1;
     
    $var30;
     
    $var4 0;

          
    $sql "insert into " TABLE_SUB_LIST " (mem_id, field2, field3, field4) values (:ipnid, :var2, :var3, :var4)";
          
    $sql $db->bindVars($sql':ipnid'$this->paypal_ipn_id'integer');
          
    $sql $db->bindVars($sql':var2'$var2'integer');
          
    $sql $db->bindVars($sql':var3'$var3'integer');
          
    $sql $db->bindVars($sql':var4'$var4'integer');
          
    $db->Execute($sql);

     
    ipn_debug_email('PDT NOTICE :: Order added: ' $insert_id "\n" 'PayPal status: ' $this->pdtData['payment_status'] . ' ' ' @ ' $this->pdtData['payment_date'] . "\n" ' Trans ID:' $this->pdtData['txn_id'] . "\n" ' Amount: ' $this->pdtData['mc_gross'] . ' ' $this->pdtData['mc_currency']);
        }
      } 
    What did I do wrong? Please help.

  2. #2
    Join Date
    Dec 2007
    Location
    Ontario, Canada
    Posts
    27
    Plugin Contributions
    0

    Default Re: Custom DB insert after payment confirmation

    Anyone?

  3. #3
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Custom DB insert after payment confirmation

    Your code itself looks fine.

    And, if your transaction is happening via the PayPal IPN Website Payments Standard module, *and* you have it correctly set up to use a PDT token, then it should work as long as PayPal's servers don't trigger the IPN notification before the customer gets back to your store from PayPal's site.

    If you want to cause it to do the insert during the IPN handling process, you'll have to intercept the order generation code in the ipn_main_handler script instead.

    Unfortunately PayPal is a complicated duck.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Dec 2007
    Location
    Ontario, Canada
    Posts
    27
    Plugin Contributions
    0

    Default Re: Custom DB insert after payment confirmation

    Looked into the piece of code of ipn_main_handler. Not sure where I can add similar insert instructions into it.

  5. #5
    Join Date
    Dec 2007
    Location
    Ontario, Canada
    Posts
    27
    Plugin Contributions
    0

    Default Re: Custom DB insert after payment confirmation

    The sql insertion code seemed to be working within the case 'unique': condition. Can someone confirm that this is the correct place to insert data into custom table after purchase confirmation?

  6. #6
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Custom DB insert after payment confirmation

    Quote Originally Posted by qwerpoiu338 View Post
    The sql insertion code seemed to be working within the case 'unique': condition. Can someone confirm that this is the correct place to insert data into custom table after purchase confirmation?
    Yes, and probably best after this line:
    $order->send_order_email($insert_id, 2);
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v154 Payment after Order Confirmation
    By yaseent in forum General Questions
    Replies: 0
    Last Post: 22 Oct 2015, 11:39 AM
  2. Custom Order Payment Link or After Login
    By marketsource in forum Managing Customers and Orders
    Replies: 3
    Last Post: 14 Jan 2011, 04:47 PM
  3. After PayPal confirms payment, I want to add a custom step
    By darlo in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 15 Oct 2009, 10:57 PM
  4. Payment method radio buttons stopped working after adding custom fields
    By sparklefish in forum Addon Payment Modules
    Replies: 5
    Last Post: 9 Mar 2009, 05:56 PM
  5. Custom DB insert after payment confirmation
    By gregeverett in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 30 Jul 2007, 09:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg