WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] How can i get my IPN works in woocommerce payment (56 posts)

  1. queenielow
    Member
    Posted 2 years ago #

    Hi Everyone,

    I'm using the paypal gateway that comes with woocommerce, and i noticed that the order won't turn to processing or complete when i make payment to paypal (successful).

    Any idea where could go wrong? I check on IPN but there's no IPN field to key in.

    Thanks everyone

    http://wordpress.org/extend/plugins/woocommerce/

  2. queenielow
    Member
    Posted 2 years ago #

    how can it be resolve when no one replying?

  3. Roy Ho
    Member
    Posted 2 years ago #

    From what I know, you do not need to set the IPN. The IPN is automatically passed to Paypal along with the purchase information so Paypal knows the callback URL without you having to explicitly setting it.

    If your IPN is not getting any response, there are other issues. Perhaps your site is on maintenance mode? That will usually prevent IPN from successfully connecting to your site.

  4. queenielow
    Member
    Posted 2 years ago #

    Hi Royho,

    Thanks for the head ups.
    When i check on the IPN txt file, they only show this, which doesnt seems to be right.

    08-20-2012 @ 01:03:06 - Generating payment form for order #946. Notify URL: http://www.website.com.au/?paypalListener=paypal_standard_IPN

    Any idea where i was missing?

    Cheers,

  5. Nadun
    Member
    Posted 2 years ago #

    Hi queenielow,

    How did you fix it?

  6. queenielow
    Member
    Posted 2 years ago #

    Hi Nadun,

    I didn't manage to fix it.. but i work around with it. Because this woocommerce that i'm using was modified heavily by the other developer. so i have to work around it.

    If your woocommerce was not modified, you wont have any problem with ur IPN because it's automatically captured in woocommerce.

    Cheers,
    Queenie

  7. Nadun
    Member
    Posted 2 years ago #

    Hey queenielow,

    Thanks for replying.

    No I have not modified any code in woocommerce yet. When I buy a product, I can pay for the item and come back to my site but in "My Account" section it says that I have to pay until I go on the back-end and change the state to processing. It doesn't automatically set it or reduce stock.

    Not sure what is going on. Can you give me a starting point if I want to try go modify stuff in the back-end?

    Thank you very much!

    Cheers,
    Nadun.

  8. queenielow
    Member
    Posted 2 years ago #

    Hi Nadun,

    I presume u are using paypal to make payment? When you go into your "Woocommerce" --> "Orders" , does the status stated as "Pending"?

  9. Nadun
    Member
    Posted 2 years ago #

    Hey queenielow,

    Yes I use paypal for payments.

    The order stays in "Pending" until I manually click the "processing" button in "Woocommerce" --> "Orders".

    If the order is in "pending", as the customer I see in "My account" under actions "Pay" and "view" which is wrong because it's already paid. I can't go and manually click "processing" for every order I get :( (the stock doesn't reduce also)

    Any help would be much appreciated.
    Thank you.

    Cheers,
    Nadun.

  10. queenielow
    Member
    Posted 2 years ago #

    Hi Nadun ,

    I'm having exactly problem as u..
    What i did is working on the thank you page in /wp-content/plugins/woocommerce/templates/checkout/thankyou.php

    For me, once the payment in paypal is paid, it will redirect me to the thankyou page. so i use that page to write couple of script.

    Are you enable ajax in this page "wp-admin/admin.php?page=woocommerce" and is "Enable AJAX add to cart buttons on product archives " ticked?

  11. Nadun
    Member
    Posted 2 years ago #

    Hi queenielow,

    So what kind of script do I need to add in the thankyou.php file? Is it too big to put here?

    In settings I have all script options enabled(ticked).

    • Enable AJAX add to cart buttons on product archives
    • Enable WooCommerce lightbox on the product page
    • Enable enhanced country select boxes
  12. queenielow
    Member
    Posted 2 years ago #

    Hi Nadun,

    This is my script but mine doesn't have inventory to minus for each purchase.

    Place these script after "<?php else : ?>"

    <?php

    //To make pending payment to processing ( after paypal redirect) **START**
    global $wpdb;

    $fivesdrafts = $wpdb->get_results("SELECT COUNT(*) as cnt FROM wp_term_relationships where object_id=$order->id and term_taxonomy_id=7;");

    foreach ( $fivesdrafts as $no_of_term )
    {
    $cnt=$no_of_term->cnt;
    if ($cnt!=0){
    add_post_meta($order->id,'Download Permissions Granted',1);
    add_post_meta($order->id,'_recorded_sales','yes');

    $wpdb->update(
    'wp_term_relationships',
    array(
    'term_taxonomy_id' => 10),
    array( 'object_id' => $order->id ),
    array( '%d'),
    array('%d')
    );
    }

    }

    $item_meta=get_post_meta($order->id,'_order_items');

  13. queenielow
    Member
    Posted 2 years ago #

    For those who looking for some guidelines on the function for woocommerce.. Here is the link
    http://wcdocs.woothemes.com/apidocs/source-function-woocommerce_pay_action.html#474

    Just found out last nite.. good luck

  14. Nadun
    Member
    Posted 2 years ago #

    Hey queenielow,

    Thank you very much for the code. I was going through it and code files in woocommerce last night. My PHP is a bit rusty but understood most of your code.

    Is the variable $order an object of "WC_Order" (woocommerce/classes/class-wc-order.php) class? If so can we just call $order->payment_complete() ?

    It will update status and reduce stock if it works. Of course this all maybe wrong as I am so out of touch in PHP.

    What do you think? Can we call that function from thankyou.php?

  15. queenielow
    Member
    Posted 2 years ago #

  16. Nadun
    Member
    Posted 2 years ago #

    Hey queenielow,

    My IPN is enabled and set to "/checkout/order-received" in paypal but still doesn't work.

    Do you think what I said above it valid?

    payment_complete()
    http://wcdocs.woothemes.com/apidocs/source-class-WC_Order.html#1134

  17. queenielow
    Member
    Posted 2 years ago #

    same here.. my IPN not working either.
    did u tried IPN set to
    "http://yoursite.com/?paypalListener=paypal_standard_IPN" ?

    Yeah you could try $order->payment_complete() . i'll try that too.. thanks for the headups

  18. queenielow
    Member
    Posted 2 years ago #

    Hey Nadun, IT WORKS!!!!

    I just place this $order->payment_complete() at the end of my insert script. ( not sure should i remove my script and just put that in )

  19. Nadun
    Member
    Posted 2 years ago #

    Hey queenielow,

    I haven't tried "http://yoursite.com/?paypalListener=paypal_standard_IPN" will try tonight.

    wow! Good that it worked!! If your custom code only change the order status $order->payment_complete() should do that and reducing the stock. Make sure your stock levels are not reducing twice.

    There is a "update_status()" method also if you only wanna do that.
    http://wcdocs.woothemes.com/apidocs/source-class-WC_Order.html#1066

    Hope it works for me too!

  20. queenielow
    Member
    Posted 2 years ago #

    Hey Nadun,

    U dont need anything.. just $order->payment_complete() will do all the calculation , i think.. but try it at ur side to see if it works on minus stock.

    Thanks for the update_status().. i need it to go directly to complete.

    Cheers

  21. angelostudios
    Member
    Posted 2 years ago #

    I'm having trouble with this too. I am still using a sandbox for testing PayPal, and the IPN is working without errors. Still my orders do not reduce stock, and they say "pending" even though the money is transferred to my test account.

    I'm redirecting users to order-received/ as well. Where can I put your code in the template to make this work for me?

    Edit

    I just added the code to the top of the page and it worked! Thanks SO MUCH for posting this.

    <?php
    /**
     * Order details
     *
     * @author 		WooThemes
     * @package 	WooCommerce/Templates
     * @version     1.6.4
     */
    
    global $woocommerce;
    
    $order = new WC_Order( $order_id );
    
    $order->payment_complete()
    
    ?>
  22. queenielow
    Member
    Posted 2 years ago #

    glad that help. No worries :)

  23. WeddingAlbumCafe
    Member
    Posted 2 years ago #

    Please help me my orders are being completed via paypal but i am not receiving any notification of the orders. also the customer is not being emailed an invoice.

    I am not sure what pages you are adding these codes to. Can someone please tell me what page you are editing to get this to work?

    I have added

    http://www.mysite.com/?paypalListener=paypal_standard_IPN

    to paypal and paypal has verified that the notifications are going thru sucessfuly.

    I don't have a need to reduce stock as i have only digital goods. I just want to be notified when someone makes a purchase. Currently i get an email if someone checks out with a coupon but NOT when they check out with paypal

    Please help me

  24. angelostudios
    Member
    Posted 2 years ago #

    @WeddingAlbumCafe

    The best way to fix this is:

    1. Create a folder called Woocommerce under your theme folder. (ex. twentyten/woocommerce)

    2. Go to the woocommerce plugin folder and copy the contents of woocommerce/templates into the new folder (ex. twentyten/woocommerce)

    3. Open up the Order Details file in your editor. (ex /twentyten/woocommerce/order/order-details.php)

    4. Add the code at the top, right before the ?>

    $order->payment_complete()

    5. Save it and upload it back to the theme folder. (ex. /twentyten/woocommerce/order/order-details.php)

    Copying the files to your theme folder will prevent these changes from being overwritten if you ever upgrade Woocommerce.

    I believe this will fix the emails and the stock as well.

    Hopefully that helps.

  25. WeddingAlbumCafe
    Member
    Posted 2 years ago #

    thanks so much angelo, that did not work for me.

    do you know the name of the file that processes orders completed by coupon code? Maybe i could see if there are any differences in the two files that determines why one sends nofiications and the other does not

  26. angelostudios
    Member
    Posted 2 years ago #

    You should make sure you have auto redirect set up in PayPal to redirect them to the order-received page.

    Also, setup a developer account with PayPal so you can run tests (if you haven't done so yet)

  27. WeddingAlbumCafe
    Member
    Posted 2 years ago #

    it is set up to take them to the thank you page is that not correct?

  28. angelostudios
    Member
    Posted 2 years ago #

    if so, make the code change to the thank you template.

  29. WeddingAlbumCafe
    Member
    Posted 2 years ago #

    I have amended my thankyou template can you please verify if this correct for me. I still can't get this to work.

    this is file /templates/checkout/thankyou.php

    <?php
    /**
     * Thankyou page
     *
     * @author 		WooThemes
     * @package 	WooCommerce/Templates
     * @version     1.6.4
     */
    
    global $woocommerce;
    
    $order->payment_complete()
    ?>
    
    <?php if ($order) : ?>
    
    	<?php if (in_array($order->status, array('failed'))) : ?>
    
    		<p><?php _e('Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction.', 'woocommerce'); ?></p>
    
    		<p><?php
    			if (is_user_logged_in()) :
    				_e('Please attempt your purchase again or go to your account page.', 'woocommerce');
    			else :
    				_e('Please attempt your purchase again.', 'woocommerce');
    			endif;
    		?></p>
    
    		<p>
    			<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e('Pay', 'woocommerce') ?></a>
    			<?php if (is_user_logged_in()) : ?>
    			<a href="<?php echo esc_url( get_permalink(woocommerce_get_page_id('myaccount')) ); ?>" class="button pay"><?php _e('My Account', 'woocommerce'); ?></a>
    			<?php endif; ?>
    		</p>
    
    	<?php else : ?>
    
    		<p><?php _e('Thank you. Your order has been received.', 'woocommerce'); ?></p>
    
    		<ul class="order_details">
    			<li class="order">
    				<?php _e('Order:', 'woocommerce'); ?>
    				<strong><?php echo $order->get_order_number(); ?></strong>
    			</li>
    			<li class="date">
    				<?php _e('Date:', 'woocommerce'); ?>
    				<strong><?php echo date_i18n(get_option('date_format'), strtotime($order->order_date)); ?></strong>
    			</li>
    			<li class="total">
    				<?php _e('Total:', 'woocommerce'); ?>
    				<strong><?php echo $order->get_formatted_order_total(); ?></strong>
    			</li>
    			<?php if ($order->payment_method_title) : ?>
    			<li class="method">
    				<?php _e('Payment method:', 'woocommerce'); ?>
    				<strong><?php
    					echo $order->payment_method_title;
    				?></strong>
    			</li>
    			<?php endif; ?>
    		</ul>
    		<div class="clear"></div>
    
    	<?php endif; ?>
    
    	<?php do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id ); ?>
    	<?php do_action( 'woocommerce_thankyou', $order->id ); ?>
    
    <?php else : ?>
    
    	<p><?php _e('Thank you. Your order has been received.', 'woocommerce'); ?></p>
    
    <?php endif; ?>
  30. queenielow
    Member
    Posted 2 years ago #

    HI there,

    You should put this $order->payment_complete(); after <?php else : ?>

    so it will be like this
    <?php else : ?>
    <?php $order->payment_complete(); ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic