woocommerce plugin add_action always return -1

Problem

add_action( 'woocommerce_api_wc_gateway_test', 'check_response');
function check_response() {
    echo 'test';
    return 'test';
}

when call https://loaclhost/index.php/wc-api/WC_Gateway_Test, always return httpCode: 200, response body: -1

Solution

add_action( 'woocommerce_api_wc_gateway_test', 'check_response');

function check_response() {
    echo '{"code": 200}';
    exit;
}

参考:https://github.com/woocommerce/woocommerce/issues/28830
参考:https://docs.woocommerce.com/document/payment-gateway-api/
参考:https://woocommerce.github.io/code-reference/files/woocommerce-includes-gateways-paypal-includes-class-wc-gateway-paypal-ipn-handler.html

上一篇 WordPress插件开发注意事项
下一篇 提升WooCommerce商店的安全性
目录
文章列表
1 Atlas Dex分包配置
Atlas Dex分包配置
2
WordPress插件开发注意事项
WordPress插件开发注意事项
3
Flutter实现SearchBar搜索框效果
Flutter实现SearchBar搜索框效果
4
Activity的重建(recreate)与恢复
Activity的重建(recreate)与恢复
5
Appium自动化测试(8)—— 定位控件
Appium自动化测试(8)—— 定位控件
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。