WooCommerce Paypal 标准网关 - 已收到 IPN 但订单状态停留在 'processing'
WooCommerce Paypal Standard Gateway - IPN Received but order status stuck on 'processing'
我有一个使用标准 Paypal 网关的 WooCommerce 的 Wordpress 设置。正在收到付款并通过罚款。网站正在接收 Paypal IPN 并将订单标记为 "Completed",但订单状态在 WooCommerce 中保持不变,仍显示为 "Processing"。
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网关设置的其他内容:
- 贝宝API详情
- 贝宝身份令牌
- 客户Paypal登录邮箱作为收件人邮箱和paypal邮箱
- 付款设置为捕获
贝宝ReturnURL:
贝宝通知URL:
已安装其他相关 Woo 插件:
- https://woocommerce.com/products/woocommerce-bookings/
- https://woocommerce.com/products/smart-coupons/
我有点困惑还有什么可以尝试的,因为 IPN 显然已经收到,但无论出于何种原因,WooCommerce 都没有使用此信息更新订单状态。有一些 PHP 关于其他模板中不相关点的通知,但没有任何应该干扰 WooCommerce 的内容。任何帮助或尝试的想法将不胜感激!
我遇到了同样的问题,发现这对于 WooCommerce 来说可能是正常的,因为产品应该发货然后设置为已完成。您可以使用插件自动完成订单。
WooCommerce 自动完成订单
https://wordpress.org/plugins/woocommerce-autocomplete-order/
如何自动将 WooCommerce PayPal 订单设置为已完成
http://biostall.com/how-to-automatically-set-woocommerce-paypal-orders-as-completed/
注意:您必须确保您的产品是虚拟的,并在 WooCommerce > 设置 > 额外选项下将模式设置为 "Paid orders of virtual products only"
感谢您的回复,我确实看到了自动完成插件,但手头的客户要求这是一种手动方法。基于以下资源,我设法找到了一种适用于 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');
}
}
}
我有一个使用标准 Paypal 网关的 WooCommerce 的 Wordpress 设置。正在收到付款并通过罚款。网站正在接收 Paypal IPN 并将订单标记为 "Completed",但订单状态在 WooCommerce 中保持不变,仍显示为 "Processing"。
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网关设置的其他内容:
- 贝宝API详情
- 贝宝身份令牌
- 客户Paypal登录邮箱作为收件人邮箱和paypal邮箱
- 付款设置为捕获
贝宝ReturnURL:
贝宝通知URL:
已安装其他相关 Woo 插件:
- https://woocommerce.com/products/woocommerce-bookings/
- https://woocommerce.com/products/smart-coupons/
我有点困惑还有什么可以尝试的,因为 IPN 显然已经收到,但无论出于何种原因,WooCommerce 都没有使用此信息更新订单状态。有一些 PHP 关于其他模板中不相关点的通知,但没有任何应该干扰 WooCommerce 的内容。任何帮助或尝试的想法将不胜感激!
我遇到了同样的问题,发现这对于 WooCommerce 来说可能是正常的,因为产品应该发货然后设置为已完成。您可以使用插件自动完成订单。
WooCommerce 自动完成订单
https://wordpress.org/plugins/woocommerce-autocomplete-order/
如何自动将 WooCommerce PayPal 订单设置为已完成
http://biostall.com/how-to-automatically-set-woocommerce-paypal-orders-as-completed/
注意:您必须确保您的产品是虚拟的,并在 WooCommerce > 设置 > 额外选项下将模式设置为 "Paid orders of virtual products only"
感谢您的回复,我确实看到了自动完成插件,但手头的客户要求这是一种手动方法。基于以下资源,我设法找到了一种适用于 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');
}
}
}