• Resolved fiore80

    (@fiore80)


    Hi, how can i get or display in “all orders” user id of the completed transaction?
    You can help me?
    Thanks

    Beppe

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Noor Alam

    (@naa986)

    Hi, The order is processed in the backend via PayPal IPN (Instant Payment Notification). I don’t think it’s possible for the plugin to know whether or not a user was logged in when the order came in.

    • This reply was modified 8 years, 1 month ago by Noor Alam.

    For someone who want user_id information from IPN call, here is a quick hacking,

    file: wp-content/plugins/wp-paypal/paypal-ipn.php
    before this line(about line 115), wp_paypal_debug_log("Updating order information", true);
    adding following code

        $user_id=$_GET['user_id'];
        $ipn_response['user_id']=$user_id;

    before this line(about line 140), do_action('wp_paypal_order_processed', $post_id);
    adding following code

        update_post_meta($post_id, '_user_id', $user_id);
        do_action('wp_paypal_order_processed_ipn_response', $post_id,$ipn_response,$user_id);

    file:wp-content/plugins/wp-paypal/main.php
    change this line(about line 296): $atts['callback'] = home_url() . '/?wp_paypal_ipn=1';
    to this:
    $atts['callback'] = home_url() . '/?wp_paypal_ipn=1&user_id='.get_current_user_id();

    after all above changes, you can use following function to hook on the new action and do what you want,

    function c9mf_hook_wp_paypal_order_processed_ipn_response($post_id,$ipn_response,$user_id)
    {
    /* ipn_response sample
    (
    [transaction_subject] => Monthly fee
    [payment_date] => 00:18:30 Oct 22, 2016 PDT
    [txn_type] => subscr_payment
    [subscr_id] => I-UH1FCT2P80M9
    [last_name] => buyer
    [residence_country] => CN
    [item_name] => Monthly fee
    [payment_gross] => 10.00
    [mc_currency] => USD
    [business] => [email protected]
    [payment_type] => instant
    [protection_eligibility] => Ineligible
    [verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31At3k7RW3LJrgx7UCuT72hnR3sARy
    [payer_status] => verified
    [test_ipn] => 1
    [payer_email] => [email protected]
    [txn_id] => 2G162234UC429330Y
    [receiver_email] => [email protected]
    [first_name] => test
    [payer_id] => LQRQ8N8LT4WMG
    [receiver_id] => 8BMVT4A9RKB4W
    [payment_status] => Completed
    [payment_fee] => 0.69
    [mc_fee] => 0.69
    [mc_gross] => 10.00
    [charset] => windows-1252
    [notify_version] => 3.8
    [ipn_track_id] => ea507fe44d737
    )
    */
        $payment_status = get_post_meta($post_id, '_payment_status', true);
    
        if(isset($payment_status) && $payment_status=='Completed'){
            //do anything here
        } 
    }
    add_action('wp_paypal_order_processed_ipn_response','c9mf_hook_wp_paypal_order_processed_ipn_response',10,3);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get user ID’ is closed to new replies.