Cannot save code snippet in functions.php

So, I got this piece of code from a developer. He is now unresponsive.

When I paste this code in the functions.php file and try to save the file, I get an error :
“Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.”

Can anyone have a look and help with the code?



function wooac_added_text() {

return 'View Your Cart';

}



function wooac_check_in_cart( $product ) {

if ( ! class_exists( 'WPCleverWooac' ) || ! isset( WC()->cart ) ) {

return false;

}

if ( is_a( $product, 'WC_Product' ) ) {

$product_id = $product->get_id();

} else {

$product_id = absint( $product );

}

foreach ( WC()->cart->get_cart() as $cart_item ) {

if ( $cart_item['product_id'] == $product_id ) {

return true;

}

}



return false;

}



add_filter( 'woocommerce_product_add_to_cart_text', function ( $text, $product ) {

if ( wooac_check_in_cart( $product ) ) {

$text = wooac_added_text();

}



return $text;

}, 99, 2 );



add_filter( 'woocommerce_product_add_to_cart_url', function ( $url, $product ) {

if ( wooac_check_in_cart( $product ) ) {

$url = wc_get_cart_url();

}



return $url;

}, 99, 2 );



add_filter( 'woocommerce_product_single_add_to_cart_text', function ( $text, $product ) {

if ( wooac_check_in_cart( $product ) ) {

$text = wooac_added_text();

}



return $text;

}, 99, 2 );



add_filter( 'woocommerce_loop_add_to_cart_args', function ( $args, $product ) {

if ( wooac_check_in_cart( $product ) ) {

$args['class'] = str_replace( 'ajax_add_to_cart', '', $args['class'] );

}



return $args;

}, 99, 2 );



add_filter( 'woocommerce_add_to_cart_form_action', function ( $action ) {

global $product;



if ( wooac_check_in_cart( $product ) ) {

$action = wc_get_cart_url();

}



return $action;

}, 99 );



add_action( 'woocommerce_before_add_to_cart_button', function () {

global $product;



if ( wooac_check_in_cart( $product ) ) {

?>

<button type="submit" class="single_add_to_cart_button button alt<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?>"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>

<?php

echo '<div class="wooac-added-to-cart" style="display: none">';

}

} );



add_action( 'woocommerce_after_add_to_cart_button', function () {

global $product;



if ( wooac_check_in_cart( $product ) ) {

echo '</div><!-- /wooac-added-to-cart -->';

}

} );



add_action( 'wp_enqueue_scripts', function () {

wp_localize_script( 'wooac-frontend', 'wooac_added_vars', [

'added_text' => wooac_added_text(),

'cart_url' => wc_get_cart_url(),

] );

}, 99 );



add_action( 'wp_footer', function () {

?>

<script>

(function($) {

$(document.body).on('added_to_cart', function(e, fragments, cart_hash, $button) {

$button.text(wooac_added_vars.added_text).

removeClass('ajax_add_to_cart').

attr('href', wooac_added_vars.cart_url);

});

})(jQuery);

</script>

<?php

} );

I am no coder so what I’m looking for is someone to look at the code and tell me what I need to change to make the code work

Best approach to call external procedures (Python, Node.js, Go) from Laravel with large data transfers on the same server [closed]

I am working on a Laravel application that needs to offload some heavy computations to external services written in other programming languages (e.g., Python, Node.js, Go). The key requirements for my setup are:

Data Transfer: I need to pass potentially large datasets (several MBs or more) to these external services.

Same Machine: All scripts and services will run on the same physical/virtual machine as my Laravel application.

Performance: The solution should be efficient in terms of speed and memory usage, given the potential size of the data.

Scalability: While the services will run on a single machine for now, I’d like a solution that can scale to multiple services or machines in the future if needed.
What I’ve considered:

HTTP REST API: I could expose the external scripts via a REST API, but I’m concerned about the overhead of serializing large amounts of data in JSON format and potential performance bottlenecks.
CLI calls: Using exec() in PHP to directly run scripts, but this approach doesn’t seem robust or flexible for large data transfers or future scalability.
Queueing system: Setting up a queue (e.g., Redis, RabbitMQ) to pass data to external services. However, I’m not sure if this is the most efficient method for large data sets on the same machine.

My question:
What is the best way to organize calls to external scripts or services (Python, Node.js, Go, etc.) from a Laravel application, especially when handling large volumes of data, all running on the same server? Are there specific patterns, libraries, or communication protocols (e.g., gRPC, WebSockets, message queues) that would work best for this use case?

Any advice or examples would be greatly appreciated!

The goal:
I receive data from a third-party API and save it to the database. Then, I apply user data and generate a preliminary response in Laravel. After that, I want to pass part of the data for further processing to an external script. This script is located on the same machine. It will not duplicate or implement any server logic from Laravel or interact with third-party APIs. The goal is to obtain processed data that has already gone through server-side logic and perform post-processing on it, which will then be returned back to PHP (Laravel) to provide to the client.

add partial curved text to image with php imagick

I need to create an image with two lines of text using PHP imagick.

And the texts could be arched texts (curved) and I do not know how to do that.

I’ve managed to do it when both texts is normal or curved. But no idea if only one line of text needs to be curved / arched.

The following is my code:

<?php

$text1 = "TITLE HERE";
$text2 = "CUSTOM TEXT";

$textColor = "#ffb81c";

$text1_Pos = -40;
$text2_Pos = 40;

/* Create some objects */
$image = new Imagick();
$draw = new ImagickDraw();

$image->setResolution(300, 300);

/* New image */
$image->newImage(800, 200, new ImagickPixel('transparent'));

/* Add text color */
$draw->setFillColor($textColor);

/* Font properties */
$draw->setFont('Bookman-DemiItalic');
$draw->setFontSize( 57 );

/* Center text horizontally and vertically */
$draw->setGravity(Imagick::GRAVITY_CENTER);

/* Create text 1 */
$image->annotateImage($draw, 0, $text1_Pos, 0, $text1);

/* Create text 2 */
$image->annotateImage($draw, 0, $text2_Pos, 0, $text2);

/* curved text */
$distort = array(120);
$image->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);

$image->setImageMatte(true);
$image->distortImage(Imagick::DISTORTION_ARC, $distort, false);

$image->trimImage(0);
$image->setImagePage($image->getimageWidth(), $image->getimageheight(), 0, 0);

/* Give image a format */
$image->setImageFormat('png');

/* Output the image with headers */
header('Content-type: image/png');
echo $image;

Adding custom CKEditor build produces Uncaught SyntaxError: Cannot use import statement outside a module error

I am trying to add a custom CKEditor to a ckeditor field in my setupCreateOperation() in laravel Backpack. I am following the guide in the documentation. However, I get the following error in my javascript console: Uncaught SyntaxError: Cannot use import statement outside a module.

As far as I can deduce the problem stems from the fact that the javascript code which the CKEditor Builder generates includes several import statements for the plugins:

import {
    ClassicEditor,
    AccessibilityHelp,
    Autoformat,
    AutoImage,
    AutoLink,
    Autosave,
    Base64UploadAdapter,
    Bold,
    Code,
    CodeBlock,
    Essentials,
    GeneralHtmlSupport,
    Heading,
    HtmlComment,
    HtmlEmbed,
    ImageBlock,
    ImageCaption,
    ImageInline,
    ImageInsert,
    ImageInsertViaUrl,
    ImageResize,
    ImageStyle,
    ImageTextAlternative,
    ImageToolbar,
    ImageUpload,
    Italic,
    Link,
    LinkImage,
    List,
    ListProperties,
    Markdown,
    MediaEmbed,
    Paragraph,
    SelectAll,
    ShowBlocks,
    SourceEditing,
    Table,
    TableCaption,
    TableCellProperties,
    TableColumnResize,
    TableProperties,
    TableToolbar,
    TextTransformation,
    Undo
} from 'ckeditor5';


const editorConfig = {
    toolbar: {
        items: [
            'undo',
            'redo',
            '|',
            'sourceEditing',
            'showBlocks',
            '|',
            'heading',
            '|',
            'bold',
            'italic',
            'code',
            '|',
            'link',
            'insertImage',
            'mediaEmbed',
            'insertTable',
            'codeBlock',
            'htmlEmbed',
            '|',
            'bulletedList',
            'numberedList'
        ],
        shouldNotGroupWhenFull: false
    },
    plugins: [
        AccessibilityHelp,
        Autoformat,
        AutoImage,
        AutoLink,
        Autosave,
        Base64UploadAdapter,
        Bold,
        Code,
        CodeBlock,
        Essentials,
        GeneralHtmlSupport,
        Heading,
        HtmlComment,
        HtmlEmbed,
        ImageBlock,
        ImageCaption,
        ImageInline,
        ImageInsert,
        ImageInsertViaUrl,
        ImageResize,
        ImageStyle,
        ImageTextAlternative,
        ImageToolbar,
        ImageUpload,
        Italic,
        Link,
        LinkImage,
        List,
        ListProperties,
        Markdown,
        MediaEmbed,
        Paragraph,
        SelectAll,
        ShowBlocks,
        SourceEditing,
        Table,
        TableCaption,
        TableCellProperties,
        TableColumnResize,
        TableProperties,
        TableToolbar,
        TextTransformation,
        Undo
    ],
    heading: {
        options: [
            {
                model: 'paragraph',
                title: 'Paragraph',
                class: 'ck-heading_paragraph'
            },
            {
                model: 'heading1',
                view: 'h1',
                title: 'Heading 1',
                class: 'ck-heading_heading1'
            },
            {
                model: 'heading2',
                view: 'h2',
                title: 'Heading 2',
                class: 'ck-heading_heading2'
            },
            {
                model: 'heading3',
                view: 'h3',
                title: 'Heading 3',
                class: 'ck-heading_heading3'
            },
            {
                model: 'heading4',
                view: 'h4',
                title: 'Heading 4',
                class: 'ck-heading_heading4'
            },
            {
                model: 'heading5',
                view: 'h5',
                title: 'Heading 5',
                class: 'ck-heading_heading5'
            },
            {
                model: 'heading6',
                view: 'h6',
                title: 'Heading 6',
                class: 'ck-heading_heading6'
            }
        ]
    },
    htmlSupport: {
        allow: [
            {
                name: /^.*$/,
                styles: true,
                attributes: true,
                classes: true
            }
        ]
    },
    image: {
        toolbar: [
            'toggleImageCaption',
            'imageTextAlternative',
            '|',
            'imageStyle:inline',
            'imageStyle:wrapText',
            'imageStyle:breakText',
            '|',
            'resizeImage'
        ]
    },
    initialData:
        'Test',
    link: {
        addTargetToExternalLinks: true,
        defaultProtocol: 'https://',
        decorators: {
            toggleDownloadable: {
                mode: 'manual',
                label: 'Downloadable',
                attributes: {
                    download: 'file'
                }
            }
        }
    },
    list: {
        properties: {
            styles: true,
            startIndex: true,
            reversed: true
        }
    },
    placeholder: 'Type or paste your content here!',
    table: {
        contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells', 'tableProperties', 'tableCellProperties']
    }
};

ClassicEditor.create(document.querySelector('#editor'), editorConfig);

When adding the file to the custom_build option for the ckeditor field, the field then calls the directive @basset(public_path('assets/js/ckeditor/ckeditor.js')) in the ckeditor field blade. The directive then smartly finds that it is a javascript file and ads the following script to the page:

<script src="http://0.0.0.0:5173/public/assets/js/ckeditor.js"></script>

However there are no type=’module’ on this script, so the error occurs.

Does anyone know if there are anyway to force a type=”module” on the script tag without manipulating with laravel backpack’s source files?

502 Bad Gateway on Nginx with Laravel, PHP 8.3, and Ubuntu 24.04

I’ve set up Nginx 1.24.0 on Ubuntu 24.04 LTS, installed PHP 8.3 (PHP 8.3.6), and deployed a fresh Laravel 11.2 project. I created a virtual host on port 82 for telegrambot.test. However, when I try to access http://telegrambot.test:82, I get a 502 Bad Gateway error.

Here’s my Nginx config (nginx.conf):

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    # server_tokens off;

    server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#   server {
#       listen     localhost:110;
#       protocol   pop3;
#       proxy      on;
#   }
#
#   server {
#       listen     localhost:143;
#       protocol   imap;
#       proxy      on;
#   }
#}

# configuration file /etc/nginx/mime.types:

types {
    text/html                                        html htm shtml;
    text/css                                         css;
    text/xml                                         xml;
    image/gif                                        gif;
    image/jpeg                                       jpeg jpg;
    application/javascript                           js;
    application/atom+xml                             atom;
    application/rss+xml                              rss;

    text/mathml                                      mml;
    text/plain                                       txt;
    text/vnd.sun.j2me.app-descriptor                 jad;
    text/vnd.wap.wml                                 wml;
    text/x-component                                 htc;

    image/avif                                       avif;
    image/png                                        png;
    image/svg+xml                                    svg svgz;
    image/tiff                                       tif tiff;
    image/vnd.wap.wbmp                               wbmp;
    image/webp                                       webp;
    image/x-icon                                     ico;
    image/x-jng                                      jng;
    image/x-ms-bmp                                   bmp;

    font/woff                                        woff;
    font/woff2                                       woff2;

    application/java-archive                         jar war ear;
    application/json                                 json;
    application/mac-binhex40                         hqx;
    application/msword                               doc;
    application/pdf                                  pdf;
    application/postscript                           ps eps ai;
    application/rtf                                  rtf;
    application/vnd.apple.mpegurl                    m3u8;
    application/vnd.google-earth.kml+xml             kml;
    application/vnd.google-earth.kmz                 kmz;
    application/vnd.ms-excel                         xls;
    application/vnd.ms-fontobject                    eot;
    application/vnd.ms-powerpoint                    ppt;
    application/vnd.oasis.opendocument.graphics      odg;
    application/vnd.oasis.opendocument.presentation  odp;
    application/vnd.oasis.opendocument.spreadsheet   ods;
    application/vnd.oasis.opendocument.text          odt;
    application/vnd.openxmlformats-officedocument.presentationml.presentation
                                                     pptx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
                                                     xlsx;
    application/vnd.openxmlformats-officedocument.wordprocessingml.document
                                                     docx;
    application/vnd.wap.wmlc                         wmlc;
    application/wasm                                 wasm;
    application/x-7z-compressed                      7z;
    application/x-cocoa                              cco;
    application/x-java-archive-diff                  jardiff;
    application/x-java-jnlp-file                     jnlp;
    application/x-makeself                           run;
    application/x-perl                               pl pm;
    application/x-pilot                              prc pdb;
    application/x-rar-compressed                     rar;
    application/x-redhat-package-manager             rpm;
    application/x-sea                                sea;
    application/x-shockwave-flash                    swf;
    application/x-stuffit                            sit;
    application/x-tcl                                tcl tk;
    application/x-x509-ca-cert                       der pem crt;
    application/x-xpinstall                          xpi;
    application/xhtml+xml                            xhtml;
    application/xspf+xml                             xspf;
    application/zip                                  zip;

    application/octet-stream                         bin exe dll;
    application/octet-stream                         deb;
    application/octet-stream                         dmg;
    application/octet-stream                         iso img;
    application/octet-stream                         msi msp msm;

    audio/midi                                       mid midi kar;
    audio/mpeg                                       mp3;
    audio/ogg                                        ogg;
    audio/x-m4a                                      m4a;
    audio/x-realaudio                                ra;

    video/3gpp                                       3gpp 3gp;
    video/mp2t                                       ts;
    video/mp4                                        mp4;
    video/mpeg                                       mpeg mpg;
    video/ogg                                        ogv;
    video/quicktime                                  mov;
    video/webm                                       webm;
    video/x-flv                                      flv;
    video/x-m4v                                      m4v;
    video/x-matroska                                 mkv;
    video/x-mng                                      mng;
    video/x-ms-asf                                   asx asf;
    video/x-ms-wmv                                   wmv;
    video/x-msvideo                                  avi;
}

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html index.php;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    location ~ .php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
    }

    # pass PHP scripts to FastCGI server
    #
    # location ~ .php$ {
    #   include snippets/fastcgi-php.conf;
    
    #   # With php-fpm (or other unix sockets):
    #   fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    #   # With php-cgi (or other tcp sockets):
    #   fastcgi_pass 127.0.0.1:9000;
    # }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /.ht {
    #   deny all;
    #}
}

# configuration file /etc/nginx/fastcgi.conf:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  REMOTE_USER        $remote_user;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

# configuration file /etc/nginx/sites-enabled/telegrambot:
server {
    listen 82;
    listen [::]:82;

    server_name telegrambot.test;

    root /var/www/telegrambot/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php index.nginx-debian.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    charset utf-8;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ .php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /.(?!well-known).* {
        deny all;
    }
}

# configuration file /etc/nginx/fastcgi_params:

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  REMOTE_USER        $remote_user;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

# configuration file /etc/nginx/sites-enabled/tutorial:
server {
       listen 81;
       listen [::]:81;

       server_name example.ubuntu.com;

       root /var/www/tutorial;
       index index.html;

       location / {
               try_files $uri $uri/ =404;
       }
}

My /etc/hosts file is configured as follows:

127.0.0.1       localhost
127.0.1.1       Amyr-Linux
127.0.0.1       telegrambot.test

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

I installed a fresh Laravel application under /var/www/telegrambot and set the public folder as the document root. I expected to be able to access the Laravel app by visiting http://telegrambot.test:82, but instead, I got a 502 Bad Gateway error.

My /var/log/nginx/error.log output:

2024/09/24 21:00:35 [error] 58482#58482: *4 open() "/home/amyr/Desktop/Sites/telbot/public/favicon.ico" failed (13: Permission denied), client: 127.0.0.1, server: telegrambot, request: "GET /favicon.ico HTTP/1.1", host: "telegrambot:82", referrer: "http://telegrambot:82/"
2024/09/24 21:00:37 [error] 58485#58485: *5 directory index of "/var/www/telbot/public/" is forbidden, client: 127.0.0.1, server: telbot, request: "GET / HTTP/1.1", host: "127.0.0.1:85"
2024/09/24 21:14:24 [error] 61674#61674: *2 directory index of "/var/www/telbot/public/" is forbidden, client: 127.0.0.1, server: telbot, request: "GET / HTTP/1.1", host: "telbot:85"
2024/09/24 21:20:52 [error] 61673#61673: *3 directory index of "/var/www/telbot/public/" is forbidden, client: 127.0.0.1, server: telbot, request: "GET / HTTP/1.1", host: "telbot:85"
2024/09/24 21:44:11 [error] 71158#71158: *2 directory index of "/var/www/telbot/public/" is forbidden, client: 127.0.0.1, server: telbot, request: "GET / HTTP/1.1", host: "telbot:85"
2024/09/24 22:26:27 [crit] 83369#83369: *3 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 22:29:15 [crit] 84798#84798: *1 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 22:29:19 [crit] 84799#84799: *3 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 22:29:20 [crit] 84801#84801: *5 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 22:29:20 [crit] 84800#84800: *7 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 22:32:35 [crit] 84803#84803: *9 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 22:32:36 [crit] 84804#84804: *11 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 22:33:03 [crit] 84804#84804: *11 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 23:25:47 [crit] 84805#84805: *14 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 23:26:11 [crit] 90146#90146: *1 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 23:27:14 [crit] 90436#90436: *1 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test:81"
2024/09/24 23:27:40 [crit] 90623#90623: *2 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/24 23:35:20 [crit] 93355#93355: *1 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/24 23:35:21 [crit] 93356#93356: *3 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/24 23:35:58 [crit] 93614#93614: *1 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/25 01:01:58 [crit] 107195#107195: *3 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/25 01:01:59 [crit] 107196#107196: *5 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/25 01:02:33 [crit] 107197#107197: *7 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/25 01:02:35 [crit] 107198#107198: *9 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/25 01:06:52 [crit] 107199#107199: *11 connect() to unix:/var/run/php/php8.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm.sock:", host: "telegrambot.test"
2024/09/25 01:16:07 [crit] 112771#112771: *1 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "telegrambot.test"
2024/09/25 01:17:09 [crit] 113375#113375: *2 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "127.0.0.1:82"
2024/09/25 01:17:11 [crit] 113378#113378: *4 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "127.0.0.1:82"
2024/09/25 01:48:35 [crit] 121423#121423: *1 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "127.0.0.1:82"
2024/09/25 01:48:37 [crit] 121424#121424: *3 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "127.0.0.1:82"
2024/09/25 01:57:44 [crit] 121427#121427: *5 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "127.0.0.1:82"
2024/09/25 02:02:05 [crit] 2658#2658: *1 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "127.0.0.1:82"
2024/09/25 02:02:35 [crit] 2660#2660: *3 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "127.0.0.1:82"
2024/09/25 02:02:37 [crit] 2661#2661: *5 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "127.0.0.1:82"
2024/09/25 02:03:06 [crit] 2659#2659: *7 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "telegrambot.test:82"
2024/09/25 11:20:33 [crit] 2854#2854: *4 connect() to unix:/var/run/php/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: telegrambot.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "telegrambot.test:82"

After reviewing my configuration, I noticed that the fastcgi_pass directive in my Nginx configuration is pointing to the PHP 7.4 FPM socket, while I am using PHP 8.3. I think this might be the root cause of the issue.

I ran the following command to check for the correct PHP 8.3 FPM socket:

sudo find /var/run/php/ -name "php8.3-fpm.sock"

Based on the result, I updated my Nginx configuration to:

fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;

However, the problem persists, and I am still getting the 502 Bad Gateway error. I also confirmed that both the Nginx and PHP-FPM services are running correctly.

I’ve tried a simple php script (phpinfo()) and it works perfect

I’m expecting Laravel to load properly when I access http://telegrambot.test:82, but instead, I keep getting this gateway error. Any suggestions on what else I should check or configure?

Laravel/Dusk-Tests: keys() not working (e.g. ARROW_DOWN, ENTER, ..)

I’m kind of new to Laravel and Dusk-Tests and encountering issues with the LaravelDuskBrowser keys()-method. It looks like, that the sent commands are ignored by Chrome. This is the code:

$browser->visit('/index')
    ->assertSee('secret phrase')
    ->pause(300)
    ->click('#selector')
    ->pause(1000)
    ->keys('#selector', [
        WebDriverKeys::DOWN,
        WebDriverKeys::DOWN,
        WebDriverKeys::ENTER,
    ])

What I try to do is to select the second element of a -field. While click() works and opens the dropdown, the keys() simply does nothing.

I’m wondering if this maybe related to me using a Mac (macOS 14.7) or with the current Chrome or Chromedriver (129.0.6668.58)

Thanks for your help!

I’ve setup a plain Laravel 11 project with a fresh Dusk installation and a sample page. The problem remains. Also tried to Debug the communication between Dusk and the Chromedriver. I can see, that the commands should be sent, but yeah. Nothing happens when I watch how Chrome is remotely controlled by the test.

upi deeplink how to general this sign? [closed]

paytmmp://pa=1193735 3@cbin&pn=xxxxxx&am=500.00&tn=3T 9V&cu=INR&mc=4468&url=&mode=02&purpose=00&orgid=159002&sign=xDwsVR2KhslLdE10==

How to sign sign=xDwsVR2KhslLdE10==

If u can help me i will payment 50k to you,thanks.

paytmmp://pa=1193735 3@cbin&pn=xxxxxx&am=500.00&tn=3T 9V&cu=INR&mc=4468&url=&mode=02&purpose=00&orgid=159002&sign=xDwsVR2KhslLdE10==

How to sign sign=xDwsVR2KhslLdE10==

If u can help me i will payment 50k to you,thanks.

Laravel Upgradation issue

While upgrading laravel from 6.2 to 7 this error occurs.
My current php version: 7.2.34

Fatal error: Uncaught Error: Class ‘Auth’ not found in /opt/lampp/htdocs/localApp/app/Exceptions/Handler.php:40

Enable custom taxonomy and product_tag in WooCommerce product search

I’m hoping that one of you geniuses can help me.

I have a site: https://lifesourcebookshop.co.uk/ that I want to modify the WooCommerce product search on.

What I want: To modify the query of the WooCommerce search form (in frontend) to display the products by searching in the name, description, product_tag and a custom taxonomy called book_author of the products.

What I have: I’ve tried with this code inspired from this answer that returns results for the name and description of the product. But if I search with the tag names or the book author, then the results aren’t correct.

How to reproduce this issue (put the code below in functions.php file of your active theme):

add_filter('posts_search', 'woocommerce_search_product_tag_extended', 999, 2);
function woocommerce_search_product_tag_extended($search, $query) {
    global $wpdb, $wp;
    $qvars = $wp->query_vars;
    if (is_admin() || empty($search) ||  !(isset($qvars['s']) && isset($qvars['post_type']) && !empty($qvars['s']) && $qvars['post_type'] === 'product')) {
        return $search;
    }
    $taxonomies = array('product_tag', 'book_author');
    $tax_query  = array('relation' => 'OR');
    foreach($taxonomies as $taxonomy) {
        $tax_query[] = array(
            'taxonomy' => $taxonomy,
            'field'    => 'name',
            'terms'    => esc_attr($qvars['s']),
        );
    }
    $ids = get_posts(array(
        'posts_per_page'  => -1,
        'post_type'       => 'product',
        'post_status'     => 'publish',
        'fields'          => 'ids',
        'tax_query'       => $tax_query,
    ));
    if (sizeof($ids) > 0) {
        $search = str_replace('AND (((', "AND ((({$wpdb->posts}.ID IN (" . implode( ',', $ids ) . ")) OR (", $search);
    }
    return $search;
}

Example: If you search for murphy (an author) – https://lifesourcebookshop.co.uk/?s=murphy&post_type=product then it only shows 2 products. However, if I look at the archive for that author (https://lifesourcebookshop.co.uk/book_author/abigail-murphy/), then there are actually 5 books.

I’m hoping you can help.

Thanks,
Rob

Deprecation notice for “dynamic properties” in PHP 8.3 in spite of documented exemption / workaround?

As of PHP 8.2, “dynamic properties” have been deprecated and will be removed in PHP 9.0, see https://php.watch/versions/8.2
Before refactoring dynamic properties into a WeakMap, there are supposed to be a few exemptions from the deprecation (cf. the above link), and one of these exemptions are classes with __getand __set magic methods. And indeed, while on PHP 8.2, my code produced no deprecation notice.

However, it seems that after upgrade to PHP 8.3, the deprecation notice is issued in the body of the following, i.e., in the very implementation of those exempting magics:

 public function __set($property_name, $value)
 {
    $this->$property_name = $value;
 }

On https://php.watch/versions/8.3 and https://www.php.net/releases/8.3/en.php , I find no hints that the exemption was removed.

Question: Is this a negligience in the PHP 8.3 documentation, or am I missing some reason why “my” __set(and similar __get) are not good enough to count for the exemption?

(Meanwhile, I added the #[AllowDynamicProperties] to the class, but am still curious)

Generate PDF with placeholders [closed]

I’m looking for a method to generate a PDF in Laravel that has placeholders in it. I have found a lot of information about parsing existing documents and filling in the placeholders but can’t find anything about how to generate a PDF with placeholders in it.

The use case for this is the ability to programatically create a PDF that can be then sent to a third part signing agent (such as DocuSign) to be digitally signed and sent back. The third party we’re working with requires a placeholder to be created (named “ParsingIdentifer”) that their software can then read.

I have found instructions on how to create a placeholder using something like Microsoft Word, but I can’t find any way to generate this PDF using code.

I’ve looked into Laravel libraries for DomPdf and FPDF but neither of these has a clear way of adding in Placeholders.

How to make Xdebug (v3) work with VSCode and Docker (or Podman) on a Windows host?

When I use Xdebug with VSCode (and the PHP Debug extension) locally on my Windows host, it works fine.
But when I try to use Xdebug on a docker/podman container, it doesn’t work – it won’t stop on breakpoints, even though the connection is succesful.

This is my Dockerfile:

# Use official PHP image with FPM and CLI
FROM php:8.2-fpm

# Install system dependencies and PHP extensions for Laravel
RUN apt-get update && apt-get install -y 
    git 
    unzip 
    libpq-dev 
    libonig-dev 
    libxml2-dev 
    libzip-dev 
    && docker-php-ext-install pdo pdo_mysql pdo_pgsql zip mbstring xml

# Install Xdebug
RUN pecl install xdebug && docker-php-ext-enable xdebug

# Configure Xdebug
RUN echo "zend_extension=xdebug.so" >> /usr/local/etc/php/php.ini 
    && echo "xdebug.mode=debug" >> /usr/local/etc/php/php.ini 
    && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/php.ini 
    && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/php.ini 
    && echo "xdebug.client_port=9003" >> /usr/local/etc/php/php.ini 
    && echo "xdebug.remote_port=9003" >> /usr/local/etc/php/php.ini 
    && echo "xdebug.log=/tmp/xdebug.log" >> /usr/local/etc/php/php.ini  
    && echo "xdebug.idekey=VSCODE" >> /usr/local/etc/php/php.ini 

# Install Composer globally
COPY --from=composer:2.4 /usr/bin/composer /usr/bin/composer

# Set the working directory to /var/www
WORKDIR /var/www

# Copy the Laravel project to the container
COPY . .

# Install Laravel dependencies
RUN composer install --no-interaction --prefer-dist --optimize-autoloader

# Set permissions for storage and cache
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache

# Expose port 8000 for Laravel's Artisan serve
EXPOSE 8000

# Start the Laravel development server
CMD php artisan serve --host=0.0.0.0 --port=8000

And this is how I build and run the container:

podman build . -t=xdebug

podman run -d -p 8000:8000 -p 9003:9003 xdebug

The output of xdebug_info() shows that the connection is successful and no errors.

I read somewhere that it might have to do with pathMappings: https://github.com/xdebug/vscode-php-debug/issues/653#issuecomment-919385770

Though I tried a few options and it still didn’t work (Maybe the issue is related to pathMappings, but couldn’t make it work still. What should my values be in this case? It’s a Laravel project if that matters)

What is the posibility for Str::random to create same string upon each app isntance in multi-server webapp?

I am making this model in my laravel Application.


namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;
use IlluminateSupportStr;

class ApiKeys extends Model
{
    use HasFactory;

    const TABLE = 'api_keys';
    protected $table = self::TABLE;

    public static function boot()
    {
        parent::boot();

        self::creating(function ($model) {
            $model->identifier = Str::random(16);
        });
    }
}

And upon Identifier I want to ensure that contains a unique random string:


use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('api_keys', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('identifier')->unique('unique_identifier');
            $table->boolean('active');
            $table->timestamps();

        });
    }

    public function down(): void
    {
        Schema::dropIfExists('api_keys');
    }
};

But my application runs in multiple instances behind load balancer:

enter image description here

Would this cause not unique random strings be generated, in other words could Str::random(16) (and the underlying function openssl_random_bytes) generate non unique string if both executed from multiple instances?

In order to avoid this usually I prepend the hostname:

  $model->identifier = gethostname()."_".Str::random(16);

But this makes the identifier look ugly or even expose some infrastructure information. How I could avoid this?

Custom product type – add Product to WooCommerce Cart

I am trying to add my product to cart.
I have created product type bookable_product. So when I executed below code

function add_bookable_product_to_cart()
{
   if (! is_admin()) {
      $product_id = 38; // Your bookable product ID
      $product_cart_id = WC()->cart->generate_cart_id($product_id);

      if (! WC()->cart->find_product_in_cart($product_cart_id)) {
         // Add the bookable product to the cart
         $added = WC()->cart->add_to_cart($product_id);

         if (!$added) {
            // Handle failure to add, maybe log or display an error
            error_log('Could not add product to cart: ' . $product_id);
         }
      }
   }
}
add_action("wp", "add_bookable_product_to_cart", 10);

As per this doc

I have used WooCommerce for only product management purpose all fields I have created my self. So in default product I have not added any data of WC.

Stripe: default payment method not retrievable via API

With the Stripe API, I’m trying to retrieve the default payment method of a customer via first via the subscription, then via the customer profile. Like so:

try {
            $subscription = StripeSubscription::retrieve($subscriptionId);
            $defaultPaymentMethodId = $subscription->default_payment_method;

            if (empty($defaultPaymentMethodId)) {
                $customer = StripeCustomer::retrieve($customerId);
                $defaultPaymentMethodId = $customer->invoice_settings->default_payment_method;
            }

            if (!empty($defaultPaymentMethodId)) {
                $paymentMethod = StripePaymentMethod::retrieve($defaultPaymentMethodId);
                $last4 = $paymentMethod->card->last4;
                $exp_year = $paymentMethod->card->exp_year;
                $exp_month = sprintf("%02d", $paymentMethod->card->exp_month);
                $brand = ucwords($paymentMethod->card->brand);
                $has_payment_method = true; // Set to true if a payment method is found
            } else {
                $last4 = $exp_year = $exp_month = $brand = null; // Set these to null to avoid potential issues
            }
        } catch (Exception $e) {
            logError('Stripe API error trying to get payment method details: ' . $e->getMessage());
        }

In both cases, I’m getting a ‘null’ result, even though I can see in the Stripe dashboard that the customer has, in fact, a default payment method set: (I only accept cards, so it has to be a card)

screenshot from the dashboard

I have tried all sort of trouble shooting. API works fine for other work, I can retrieve all the other info of customers, just not the default payment method.

Any ideas what else I could try?