Support » Plugin: PayPal IPN for WordPress » Updating WordPress table with refund hook …

  • Hello,
    I am receiving email notifications successfully to my email in my 2 hooks for transactions Completed AND same transaction Refunded (testing in Sandbox).
    I created a separate table and that gets updated with the transaction fine as does your IPN for wordpress.
    Screen shots here: and GREAT.

    I am trying to UPDATE my database when it is refunded.
    Your IPN gets updated but my DB doesn’t, yet i get the email
    sent to say ts refunded so i know I’m missing something.
    I need it to update table where item_name and payer_email = data from $posted transaction.
    Can you see where I’ve gone wrong please?
    Here’s the code:

    //--> REFUND HOOK
    add_action('paypal_ipn_for_wordpress_payment_status_refunded', 'refunded_send_email', 10, 1);
    function refunded_send_email($posted)
    // email part i left out for this post as it works..
        global $wpdb;
    	$table_name = $wpdb->prefix . "ipn_data_tbl";
    	$payment_status = isset($posted['payment_status']) ? $posted['payment_status'] : '';
        $receiver_email = isset($posted['receiver_email']) ? $posted['receiver_email'] : '';
    	$payer_email = isset($posted['payer_email']) ? $posted['payer_email'] : '';
    	$item_name = isset($posted['item_name']) ? $posted['item_name'] : '';
        $first_name = isset($posted['first_name']) ? $posted['first_name'] : '';
        $last_name = isset($posted['last_name']) ? $posted['last_name'] : '';
            'payment_status' => $payment_status
            'payer_email' => $serial,
            'item_name'   => $product,
    //<---REFUND HOOK 

    Hope code is ok above to read..else here->


Viewing 6 replies - 1 through 6 (of 6 total)
  • Oh, forgot… while waiting for reply
    just donated too. Thanks…great plugin and support.
    Transaction ID: 2G479203JT333531A



    HI @schmutly

    If you look at your code then Base don what I see here you are not passing anything to your DB. See this.

            'payment_status' => $payment_status
            'payer_email' => $serial, // this should be $payer_email 
            'item_name'   => $product, // This should be Item Name

    Or is there a specific reason you are adding those 2 variables : $serial , $product

    Please double check this and and update these values accordingly and I am sure DB will be updated accordingly.


    Hi Oliver,
    i must be misunderstanding the codex at that point. I thought THAT array was my “where”
    statement. I’m coming from Mysql side and the serial/product are strings compared from a software activation.
    So if there was a refund i wanted to update that row in database to “Refunded” from being “Completed” in my DB.
    So it was meant to be: update payment_status where payer_email = &serial AND item_name= $product. I might have the 2nd array incorrect :/
    I must have that part wrong as you pointed out i am “adding” those 2 variables when in fact i’m wanting to update a row on condition of those 2 variables so that the correct row is updated from Completed to Refund.
    hmm..scratching head, I’ll go sleep on it and try again tomorrow.

    • This reply was modified 1 year, 8 months ago by schmutly.
    Plugin Contributor angelleye


    @schmutly I think you are understanding the use of the method correctly, but it seems that you may be passing data that may not be valid.

    Where is $serial coming from? Does that have an email address in it?

    Plugin Contributor angelleye


    Ah, yeah, it seems maybe you just need to use the correct variables for those parameters and that might fix it.

    You can also check your MySQL logs to see if you’re showing any errors there from queries failing.

    Thanks guys…IDIOT!!! (me lol) why on earth was i passing the $product for when
    it’s only used for the activation of the software, nothing to do with the IPN side.
    Sorry..see, sometimes it just takes another pair of eyes.
    It didn’t click for me to change it (tired? hmm.)

    $wpdb->update($table_name, array(
    	'payment_status' => $payment_status
    ) , array(
    	'payer_email' => $payer_email,
    	'item_name' => $item_name

    All good now. Thank you both.Great plugin and support.
    Kind, and expert PayPal professionals.. 🙂

    • This reply was modified 1 year, 8 months ago by schmutly.
    • This reply was modified 1 year, 8 months ago by schmutly.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Updating WordPress table with refund hook …’ is closed to new replies.