[20-Oct-2026 13:55:14 US/Eastern] PHP Warning: Undefined array key "intent" in /...../shop/modules/tbpaypalcheckout/src/Model/PayPalOrder.php on line 125
This occurred at the same time a user was making a purchase.
Here is the source block - possibly change to use the Null Coalescing Operator as a fix?
public static function createFromPayPalOrder(Logger $logger, int $cartId, array $paypalOrder): ?PayPalOrder
{
$order = new static();
$order->id_cart = (int)$cartId;
$order->paypal_order_id = (string)$paypalOrder['id'];
$order->paypal_status = (string)$paypalOrder['status'];
$order->intent = (string)$paypalOrder['intent'];
// Extract amount and currency
if (isset($paypalOrder['purchase_units'][0]['amount'])) {
$order->amount = (float)$paypalOrder['purchase_units'][0]['amount']['value'];
$order->currency = (string)$paypalOrder['purchase_units'][0]['amount']['currency_code'];
}
Question
Rhapsody
The following warning is in the error log:
[20-Oct-2026 13:55:14 US/Eastern] PHP Warning: Undefined array key "intent" in /...../shop/modules/tbpaypalcheckout/src/Model/PayPalOrder.php on line 125
This occurred at the same time a user was making a purchase.
Here is the source block - possibly change to use the Null Coalescing Operator as a fix?
public static function createFromPayPalOrder(Logger $logger, int $cartId, array $paypalOrder): ?PayPalOrder
{
$order = new static();
$order->id_cart = (int)$cartId;
$order->paypal_order_id = (string)$paypalOrder['id'];
$order->paypal_status = (string)$paypalOrder['status'];
$order->intent = (string)$paypalOrder['intent'];
// Extract amount and currency
if (isset($paypalOrder['purchase_units'][0]['amount'])) {
$order->amount = (float)$paypalOrder['purchase_units'][0]['amount']['value'];
$order->currency = (string)$paypalOrder['purchase_units'][0]['amount']['currency_code'];
}
$order->date_add = date('Y-m-d H:i:s');
$order->date_upd = date('Y-m-d H:i:s');
if ($order->save()) {
$logger->debug('PayPal order saved to database', [
'id_tbpaypal_order' => $order->id,
'paypal_order_id' => $order->paypal_order_id,
'cart_id' => $cartId
]);
return $order;
}
return null;
}
0 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now