0

Undefined array key is successful' in /vendor/magento/module-payment-services-paypal/Model/Sdk Service.php on line 122 in magento 2

1
  • Can you add full stack trace of Log ? Commented Jul 9, 2024 at 8:29

1 Answer 1

0

@Pinkesh Kuwal

Hey,

The warning you are encountering in Magento 2 is specifically related to an undefined array key in the SdkService.php file within the PayPal module. To address this issue, you need to ensure that the array key is_successful and is checked for existence before accessing it.

Here's how you can modify the SdkService.php file to include this check:

  1. Open the SdkService.php file
  2. Navigate to the file located at /vendor/magento/module-payment-services-paypal/Model/SdkService.php.

Locate the line causing the warning: The warning is occurring on line 122. Find this line in the file.

Add a check for the array key: Before accessing $result['is_successful'], ensure that the key exists.

Here's an example of how you can modify the code:

// ... other code ...

// Before line 122 where $result['is_successful'] is being accessed
if (isset($result['is_successful'])) {
    // The key exists, so you can safely use it
    if ($result['is_successful']) {
        // Handle successful result
    } else {
        // Handle unsuccessful result
    }
} else {
    // Log the error or set a default value
    $this->logger->error('Key "is_successful" is not set in the result array.');
    $result['is_successful'] = false; // Default value
    // Handle the missing key case
}

// ... other code ...

Get all your queries solved here. Thank You!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.