Forums / Managing Customers and Orders / ID missing after capture transaction

ID missing after capture transaction

Views: 2,966

Results 1 to 5 of 5
27 Apr 2022, 6:34 PM
#1
panzc2020 avatar

panzc2020

New Zenner

Join Date:
May 2014
Posts:
68
Plugin Contributions:
0

ID missing after capture transaction

I know ZC156 is outdated, but I am still testing for ZC157, but still have to keep old site for time being.

The host migrating to new server with new PHP 7.4, but due to the old ZC156 does not fully support 7.4, I asked host to stay with the old server PHP version until testing is fully complete. However, while the old site is running... when customer checked out, it gave out this error on backend.

(Customer would be asked to refresh, it would ended up have this error 3 times before "timed out.")

[B]1048 Column 'id' cannot be null[/B]
in:
[INSERT INTO authorizenet (id, customer_id, order_id, response_code, response_text, authorization_type, transaction_id, sent, received, time, session_id) VALUES ([B]NULL[/B], 3661, 14939, 1, '(TESTMODE) This transaction has been approved.', 'auth_capture', '', 'Array\n(\n [x_login] => *******\n [x_tran_key] => *******\n [x_relay_response] => FALSE\n [x_delim_data] => TRUE\n [x_delim_char] => |\n [x_encap_char] => *\n [x_version] => 3.1\n [x_solution_id] => A1000003\n [x_method] => CC\n [x_amount] => 20.08\n [x_currency_code] => USD\n [x_market_type] => 0\n [x_card_num] => XXXXXXXXXXXXX0027\n [x_exp_date] => ... )]

*removed the rest due to sensitive data

So for some reasons, I tried to find out why 'id' is all sudden became 'null' when it supposed to be +1 from the database. I am trying to find out where the trigger is, but I'm not positive if whether it is in authorizenet.php or in other files that deal with SQL connection.

28 Apr 2022, 1:07 AM
#2
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: ID missing after capture transaction

PanZC2020:

I know ZC156 is outdated, but I am still testing for ZC157, but still have to keep old site for time being.

The host migrating to new server with new PHP 7.4, but due to the old ZC156 does not fully support 7.4, I asked host to stay with the old server PHP version until testing is fully complete. However, while the old site is running... when customer checked out, it gave out this error on backend.

(Customer would be asked to refresh, it would ended up have this error 3 times before "timed out.")

[B]1048 Column 'id' cannot be null[/B]
in:
[INSERT INTO authorizenet (id, customer_id, order_id, response_code, response_text, authorization_type, transaction_id, sent, received, time, session_id) VALUES ([B]NULL[/B], 3661, 14939, 1, '(TESTMODE) This transaction has been approved.', 'auth_capture', '', 'Array\n(\n [x_login] => *******\n [x_tran_key] => *******\n [x_relay_response] => FALSE\n [x_delim_data] => TRUE\n [x_delim_char] => |\n [x_encap_char] => *\n [x_version] => 3.1\n [x_solution_id] => A1000003\n [x_method] => CC\n [x_amount] => 20.08\n [x_currency_code] => USD\n [x_market_type] => 0\n [x_card_num] => XXXXXXXXXXXXX0027\n [x_exp_date] => ... )]

> 
> *removed the rest due to sensitive data
> 
> So for some reasons, I tried to find out why 'id' is all sudden became 'null' when it supposed to be +1 from the database. I am trying to find out where the trigger is, but I'm not positive if whether it is in authorizenet.php or in other files that deal with SQL connection.

i would venture a guess that you are now on a server where mysql is in strict mode.  i would look at this line of code:

<https://github.com/zencart/zencart/blob/e60c81b6dbac7b1a61fb891397fe20de7b02c623/includes/modules/payment/authorizenet.php#L656>

remove the 'id' and the 'NULL' from the line.  it should now look like:

```php
$sql = "insert into " . TABLE_AUTHORIZENET . "  (customer_id, order_id, response_code, response_text, authorization_type, transaction_id, sent, received, time, session_id) values (:custID, :orderID, :respCode, :respText, :authType, :transID, :sentData, :recvData, :orderTime, :sessID )";

report back if that works. id is an index that auto increments, so it is not necessary on an insert statement.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

28 Apr 2022, 3:08 PM
#3
panzc2020 avatar

panzc2020

New Zenner

Join Date:
May 2014
Posts:
68
Plugin Contributions:
0

Re: ID missing after capture transaction

That work around does work. However, I did have to change on the authorizenet_aim.php file, which also have that SQL statement since the site using the one with (AIM) and not (SIM) one.

Now, at least customer can orders while I'm working on the upgrade!

28 Apr 2022, 3:46 PM
#4
panzc2020 avatar

panzc2020

New Zenner

Join Date:
May 2014
Posts:
68
Plugin Contributions:
0

Re: ID missing after capture transaction

While we at it, I do wonder why Zen Cart developers did not use this SQL instead of the one with 'NULL' as it seems that the one that you suggested is more proper for SQL statements and able to get through even host using strict mode.

28 Apr 2022, 5:07 PM
#5
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: ID missing after capture transaction

PanZC2020:

While we at it, I do wonder why Zen Cart developers did not use this SQL instead of the one with 'NULL' as it seems that the one that you suggested is more proper for SQL statements and able to get through even host using strict mode.

that line of code goes back 10 years. mysql and php were completely different languages back then.

the code that you are using also makes use of the 2 value pairs, which authorize has deprecated many moons ago. as to when that code will cease to work.... who knows...

my biased opinion would be to move to my plugin here:

https://www.zen-cart.com/downloads.php?do=file&id=2272

card on file transactions and using a more current version of the authorize sdk....

but your call...

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.