cms90
Forum Replies Created
-
Forum: Plugins
In reply to: [Payment Button for PayPal] update_user_meta after pay was completFor 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 codeupdate_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] => testaccount_biz@gmail.com [payment_type] => instant [protection_eligibility] => Ineligible [verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31At3k7RW3LJrgx7UCuT72hnR3sARy [payer_status] => verified [test_ipn] => 1 [payer_email] => testaccount_biz@gmail.com [txn_id] => 2G162234UC429330Y [receiver_email] => testaccount_biz@gmail.com [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);Forum: Plugins
In reply to: [Payment Button for PayPal] Get user IDFor 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 codeupdate_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] => testaccount_biz@gmail.com [payment_type] => instant [protection_eligibility] => Ineligible [verify_sign] => AFcWxV21C7fd0v3bYYYRCpSSRl31At3k7RW3LJrgx7UCuT72hnR3sARy [payer_status] => verified [test_ipn] => 1 [payer_email] => testaccount_biz@gmail.com [txn_id] => 2G162234UC429330Y [receiver_email] => testaccount_biz@gmail.com [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);Forum: Plugins
In reply to: [Payment Button for PayPal] update_user_meta after pay was completHi @naa986,
first, thanks for your great plugin, but I have a question here,
if we want to update_user_meta, we need user_id information, but the action ‘wp_paypal_order_processed’ was triggered by the paypal_ipn call, so, we cannot get the current front-end user_id with the get_user_id() function of wordpress since the paypal_ipn have no idea who make the call, I think we may need to add the user_id information to the notify_url, then we can retrive it, and pass it via the ‘wp_paypal_order_processed’ action, would you mind updating your plugin to achieve this feature?If you are busing on other project, please let me know, I am happy to update it 🙂
Hi,
Thanks for your quick reply, not sure exactly reason cause the ‘pending’ state, I just use another sandbox account, and everything works fine.
Thanks for your reminder on sensitive information on the log, all of these test account are fake, no worry 🙂- This reply was modified 9 years, 5 months ago by cms90.