Error in code when going from PHP 7.2 to PHP 7.4

Hi All

I have my code that works fine in PHP 7.2 however in PHP 7.4 I get an error in my error_log file.

My code is:

$result = $gateway->creditCard()->update($creditCardToken, [
‘cardholderName’ => ‘New Holder’,
‘cvv’ => $cvv,
‘number’ => $cardNumber,
‘expirationDate’ => $expMonth.‘/’.$expYear,
‘options’ => [
‘verifyCard’ => true
]
]);

if ($result.success) { DO WHAT I WANT }

The error is:

[01-Dec-2020 06:10:14 UTC] PHP Warning: Use of undefined constant success - assumed ‘success’ (this will throw an Error in a future version of PHP) in /home/filepath/account.php on line 72

Does anyone know how I fix this?

Thanks for any help.

@mrmbarnes - you need to format your code!

set the constant or use a string.

Thanks… can you please give me an example?

Is there literally $result.success in your code? That is java/javascript notation. I think you’re looking for $result->success here?

If this is in production I would really double check that you didn’t accept orders that weren’t really paid for …

1 Like

Thanks… no, this is not production yet and I had someone else help me with this code and this is what they gave me… I will change it to what you have suggested… thank you so much.

I would advice to test the code thoroughly! If this mistake is in there there is high chance there are more mistakes …

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.