• We noticed on our website that purchases were being correctly transacted into Stripe, however, they were reaching a fatal error on the WordPress side. So although Stripe was capturing the payment, WordPress was showing the user a fatal error, and not re-directing them to the thank-you page. And the orders were not being captured/shown in the WP-admin backend “orders” section.

    I did some digging in the error logs and it seemed to be related to “Surchage” coding.
    I was getting this error:
    Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /public_html/wp-content/plugins/stripe-payments/includes/class-asp-payment-data.php:58


    For the moment I have manually updated the code of the plugin myself, editing this file:
    /includes/class-asp-payment-data.php


    FROM:

    public function get_surcharge_data( string $key ) {
    if ( empty($this->surcharge_data) ) {
    $metadata = isset($this->obj->charges->data[0]->metadata) ? $this->obj->charges->data[0]->metadata : array();
    if (isset($metadata['Surcharge Amount'])){
    $this->surcharge_data['amount'] = $metadata['Surcharge Amount'];
    }
    if (isset($metadata['Surcharge Label'])){
    $this->surcharge_data['label'] = $metadata['Surcharge Label'];
    }
    }
    return isset($this->surcharge_data[$key]) ? (string) $this->surcharge_data[$key] : '';
    }

    TO:

    public function get_surcharge_data( string $key ) {
    // Ensure surcharge_data is initialized as an array if not already
    if (!is_array($this->surcharge_data)) {
    $this->surcharge_data = array();
    }

    if ( empty($this->surcharge_data) ) {
    // Check if metadata exists and is an object
    $metadata = isset($this->obj->charges->data[0]->metadata) ? (array) $this->obj->charges->data[0]->metadata : array();

    if (isset($metadata['Surcharge Amount'])) {
    $this->surcharge_data['amount'] = $metadata['Surcharge Amount'];
    }

    if (isset($metadata['Surcharge Label'])) {
    $this->surcharge_data['label'] = $metadata['Surcharge Label'];
    }
    }

    return isset($this->surcharge_data[$key]) ? (string) $this->surcharge_data[$key] : '';
    }

    I hope that helps, can you double check if your plugin is setup correctly to handle PHP8 in this regard, or if any other tweaks are necessary?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Thank you for reaching out to us. I have submitted a message to the developers to investigate further your code.

    Kind regards.

    Plugin Author mra13

    (@mra13)

    Thank you for that. We will check it out and make the necessary adjustment.

    Plugin Author mra13

    (@mra13)

    @wigster We’re working to replicate the error you’re experiencing so we can test the code on our end. Could you please provide the following details to help us recreate the issue?

    1. What is the exact PHP version that your site is using?
    2. The surcharge and product price values for the product in question, so we can set up a test product with identical values.
    3. Any other details that you think will relevant for us to set it up on our end to reproduce the error.
    Plugin Author mra13

    (@mra13)

    @wigster one more question:

    Does the code you applied correctly capture the surcharge amount when saving the order details? Specifically, does the order details page display the applied surcharge accurately?

    • This reply was modified 1 month, 4 weeks ago by mra13.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.