【问题标题】:WooCommerce Paypal Standard Gateway - IPN Received but order status stuck on 'processing'WooCommerce Paypal 标准网关 - 已收到 IPN,但订单状态停留在“处理中”
【发布时间】:2017-02-12 12:57:58
【问题描述】:

我使用标准的 Paypal 网关在 WooCommerce 上设置了 Wordpress。正在收到付款并通过罚款。网站正在接收 Paypal IPN 并将订单标记为“已完成”,但 WooCommerce 中的订单状态保持不变,仍显示为“处理中”。

10-04-2016 @ 11:04:18 - Received valid response from PayPal
10-04-2016 @ 11:04:18 - Found order #1303
10-04-2016 @ 11:04:18 - Payment status: completed

在 Paypal 网关设置中输入的其他内容:

  • Paypal API 详细信息
  • 贝宝身份令牌
  • 客户Paypal登录邮箱作为接收邮箱和paypal邮箱
  • 付款设置为捕获

Paypal 返回网址:

Paypal 通知网址:

已安装其他相关 Woo 插件:


我有点难过还有什么可以尝试的,因为显然已收到 IPN,但无论出于何种原因,WooCommerce 都没有使用此信息更新订单状态。有一些关于其他模板中不相关点的 PHP 通知,但没有任何应该干扰 WooCommerce 的内容。任何帮助或尝试的想法将不胜感激!

【问题讨论】:

    标签: php wordpress paypal woocommerce woocommerce-bookings


    【解决方案1】:

    感谢您的回复,我确实看到了自动完成插件,但客户端要求这是手动方法。根据以下资源,我设法找到了一种适用于 Paypal 标准付款的方法:

    http://codecharismatic.com/run-your-own-damn-code-after-paypal-calls-woocommerce-back/

    <?php
    /**
    * Auto Complete Woocommerce 'processing' orders
    */
    
    add_action( 'valid-paypal-standard-ipn-request', 'handle_paypal_ipn_response', 50, 1 );
    
    function handle_paypal_ipn_response( $formdata ) {
    
        if ( !empty( $formdata['invoice'] ) && !empty( $formdata['custom'] ) ) {
    
            if( $formdata['payment_status'] == 'Completed' ) {
    
                // decode data
                $order_data = json_decode($formdata['custom'], true);
    
                // get order
                $order_id = ($order_data) ? $order_data['order_id'] : '';
                $order = new WC_Order( $order_id );
    
                // got something to work with?
                if ( $order ) {
    
                    if ($order->post->post_status == 'wc-processing'){
    
                        // Status success
                            WC_Gateway_Paypal::log( 'Changing order #' . $order->id . ' status from processing to completed');
                          $order->update_status( 'completed' );
    
                    } else {
    
                        // Status fail
                            WC_Gateway_Paypal::log( 'Status fail, order #' . $order->id . ' status is set to ' . $order->post->post_status . ', not processing');
    
                    }
    
                } else {
    
                    // Order fail
                        WC_Gateway_Paypal::log( 'Fail, no order found');
    
                }
    
            } else {
    
                // Payment fail
                    WC_Gateway_Paypal::log( 'Payment status fail, not completed');
    
            }
        }
    
    
    }
    

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,发现这对于 WooCommerce 来说可能是正常的,因为产品应该被运出然后设置为已完成。您可以使用插件自动完成订单。

      WooCommerce 自动完成订单
      https://wordpress.org/plugins/woocommerce-autocomplete-order/

      如何自动将 WooCommerce PayPal 订单设置为已完成
      http://biostall.com/how-to-automatically-set-woocommerce-paypal-orders-as-completed/

      注意:您必须确保您的产品是虚拟的,并在 WooCommerce > 设置 > 额外选项下将模式设置为“仅限虚拟产品的付费订单”

      【讨论】:

        猜你喜欢
        • 2020-11-03
        • 2013-02-13
        • 2019-05-06
        • 2013-09-19
        • 2010-11-08
        • 2019-02-01
        • 2021-07-26
        • 2016-08-04
        • 2012-01-06
        相关资源
        最近更新 更多