Xdebug 不会在 Stripe webhook 的断点处停止

问题描述 投票:0回答:1

我正在尝试使用 PHP Eclipse 和 Xdebug 2 调试 Stripe Webhook 事件处理程序。我通过回显确认正在输入函数,但调试器不会在我设置的断点处停止。

我将 WAMP 与 ngrok 结合使用。 WP Simple Pay 插件处理与 Stripe 的通信。接收Stripe发出的webhook事件,返回200

我也把

xdebug_break()
插入我的休息时间,但它也不止于此。

我修改了我的 php.ini 以包含以下内容:

[xdebug]
zend_extension="c:/wamp64/bin/php/php7.4.9/zend_ext/php_xdebug-2.9.6-7.4-vc15-x86_64.dll"
; modified by Robert Bethge 9/20/21
;xdebug.remote_enable = off
xdebug.remote_enable = on
; added by Robert Bethge 9/20/21
xdebug.remote_host=localhost
; added by Robert Bethge 4/7/2023
xdebug.remote_autostart=on
xdebug.remote_connect_back=on

xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0

我的事件处理程序挂钩到 Simple Pay 插件提供的

simpay_webhook_payment_intent_succeeded
操作。

add_action('simpay_webhook_payment_intent_succeeded', 'rb_simpay_webhook_payment_intent_succeeded', 1, 2);
    
/*** To update credits for a customer after a purchase we have to know the credits we need to add to his existing credits. We derive that from the form_id that Stripe gives
 * us in a query variable added to the URL. The user we get by getting the customer_id from the paymentintent, retrieve the customer from Stripe and get to the email. Then we
 * can get the WP user id to update the credits user meta.
 */

function rb_simpay_webhook_payment_intent_succeeded ($event, $paymentintent) {
    global $stripe_api_key;
    echo "Robert Bethge: In function now.";    
    if ( $paymentintent && is_object($paymentintent) && $paymentintent->id ) {
        echo "first if";
        if ( "succeeded" == $paymentintent->status ) {
            echo "second if";
            // get # of credits we have to add to customer
            // WP Simple Pay form_id to make purchase
            // Stripe returns form_id in query variable
            xdebug_break();
            $form_id = (get_query_var('form_id')) ? get_query_var('form_id') : '';
            echo "form_id = " . $form_id;
            $credits_purchased = rb_credits_for_form($form_id);
            echo "credits purchased: " . $credits_purchased;
            // find customer who purchased in WP. Since Webhooks are asynchronous events initiated by Stripe, can't assume customer is logged in            
            if ( property_exists($paymentintent, 'customer')) {
                echo "third if";
                $customer_id = $paymentintent->customer;
                echo "customer id: " . $customer_id;
                $stripe = new \Stripe\StripeClient($stripe_api_key);
                try {
                    $customer = $stripe->customers->retrieve($customer_id);
                    var_dump($customer);
                } catch (\Stripe\Exception\ApiConnectionException $e) {
                    error_log("Stripe API Connection Exception: " {$e->getError()->message});
                    wp_die();
                } catch (\Stripe\Exception\ApiErrorException $e) {
                    error_log("Stripe API Error: " {$e->getError()->message});
                    wp_die();
                }
                if ( property_exists($customer, 'email') ) {
                    $email = $customer->email;
                    $user_id = get_user_by('email', $email);
                    $previous_credits = get_user_meta($user_id, 'credits', true);
                    update_user_meta($user_id, 'credits', $previous_credits + $credits_purchased);
                }                
            }
        }
    }
}

我该怎么做才能让调试器在我的函数中停止?

这是 phpinfo() 的输出:

xdebug.auto_trace   Off Off
xdebug.cli_color    0   0
xdebug.collect_assignments  Off Off
xdebug.collect_includes On  On
xdebug.collect_params   0   0
xdebug.collect_return   Off Off
xdebug.collect_vars Off Off
xdebug.coverage_enable  On  On
xdebug.default_enable   On  On
xdebug.dump.COOKIE  no value    no value
xdebug.dump.ENV no value    no value
xdebug.dump.FILES   no value    no value
xdebug.dump.GET no value    no value
xdebug.dump.POST    no value    no value
xdebug.dump.REQUEST no value    no value
xdebug.dump.SERVER  no value    no value
xdebug.dump.SESSION no value    no value
xdebug.dump_globals On  On
xdebug.dump_once    On  On
xdebug.dump_undefined   Off Off
xdebug.file_link_format no value    no value
xdebug.filename_format  no value    no value
xdebug.force_display_errors Off Off
xdebug.force_error_reporting    0   0
xdebug.gc_stats_enable  Off Off
xdebug.gc_stats_output_dir  C:\Windows\Temp C:\Windows\Temp
xdebug.gc_stats_output_name gcstats.%p  gcstats.%p
xdebug.halt_level   0   0
xdebug.idekey   no value    no value
xdebug.max_nesting_level    256 256
xdebug.max_stack_frames -1  -1
xdebug.overload_var_dump    2   2
xdebug.profiler_append  Off Off
xdebug.profiler_enable  Off Off
xdebug.profiler_enable_trigger  Off Off
xdebug.profiler_enable_trigger_value    no value    no value
xdebug.profiler_output_dir  c:/wamp64/tmp   c:/wamp64/tmp
xdebug.profiler_output_name cachegrind.out.%t.%p    cachegrind.out.%t.%p
xdebug.remote_addr_header   no value    no value
xdebug.remote_autostart On  On
xdebug.remote_connect_back  On  On
xdebug.remote_cookie_expire_time    3600    3600
xdebug.remote_enable    On  On
xdebug.remote_host  ce00-42-112-244-183.ngrok.io    ce00-42-112-244-183.ngrok.io
xdebug.remote_log   c:\wamp64\logs\remote_debug.log c:\wamp64\logs\remote_debug.log
xdebug.remote_log_level 7   7
xdebug.remote_mode  req req
xdebug.remote_port  9000    9000
xdebug.remote_timeout   200 200
xdebug.scream   Off Off
xdebug.show_error_trace Off Off
xdebug.show_exception_trace Off Off
xdebug.show_local_vars  Off Off
xdebug.show_mem_delta   Off Off
xdebug.trace_enable_trigger Off Off
xdebug.trace_enable_trigger_value   no value    no value
xdebug.trace_format 0   0
xdebug.trace_options    0   0
xdebug.trace_output_dir C:\Windows\Temp C:\Windows\Temp
xdebug.trace_output_name    trace.%c    trace.%c
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth    3   3
php webhooks xdebug
1个回答
0
投票

只需发布对我有用的输入:

;xdebug.remote_connect_back=on
xdebug.remote_host=127.0.0.1

感谢@LazyOne!

© www.soinside.com 2019 - 2024. All rights reserved.