CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • DB Error: already exists/Contribute Page using Auth-net failing
Pages: [1]

Author Topic: DB Error: already exists/Contribute Page using Auth-net failing  (Read 4290 times)

dnobendno

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 3.3.5
  • CMS version: Joomla
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
DB Error: already exists/Contribute Page using Auth-net failing
March 14, 2011, 03:26:12 pm
So we had our contribution page working in test mode with authorize no problem. And then we started getting this Duplicate Entry error. I have both the error and the Backtrace for reference.

Here is the error:

Quote
Sorry. A non-recoverable error has occurred.
DB Error: already exists
Error Details
Database Error Code: Duplicate entry 'test00000001' for key 2, 1062
Additional Details:

Array
(
    [callback] => Array
        (
           
  • => CRM_Core_Error
  • [1] => handle
            )

        code => -5
Please note, I removed the brackets to prevent the code effect from happening here.
    [message] => DB Error: already exists
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_financial_trxn (trxn_date , trxn_type , total_amount , net_amount , currency , payment_processor , trxn_id ) VALUES ( ******0231 , 'Debit' ,  200.00 ,  200.00 , 'USD' , 'AuthNet' , 'test00000001' )  [nativecode=1062 ** Duplicate entry 'test00000001' for key 2]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_financial_trxn (trxn_date , trxn_type , total_amount , net_amount , currency , payment_processor , trxn_id ) VALUES ( ******0231 , 'Debit' ,  200.00 ,  200.00 , 'USD' , 'AuthNet' , 'test00000001' )  [nativecode=1062 ** Duplicate entry 'test00000001' for key 2]
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_financial_trxn (trxn_date , trxn_type , total_amount , net_amount , currency , payment_processor , trxn_id ) VALUES ( 20110314160231 , 'Debit' ,  200.00 ,  200.00 , 'USD' , 'AuthNet' , 'test00000001' )  [nativecode=1062 ** Duplicate entry 'test00000001' for key 2]"]
)

Return to home page.

and here is the backtrace with the root directory x-d out

Quote
backTrace

/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php, backtrace, 159
, handle,
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/PEAR.php, call_user_func, 931
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/DB.php, PEAR_Error, 968
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/PEAR.php, DB_Error, 564
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/DB/common.php, raiseError, 1903
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/DB/mysql.php, raiseError, 898
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/DB/mysql.php, mysqlRaiseError, 327
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/DB/common.php, simpleQuery, 1216
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php, query, 2421
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php, _query, 1053
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php, insert, 281
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Core/BAO/FinancialTrxn.php, save, 73
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php, create, 1017
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Contribute/BAO/Contribution/Utils.php, processContribution, 256
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php, processConfirm, 1034
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php, postProcessMembership, 583
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php, postProcess, 250
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Core/StateMachine.php, mainProcess, 167
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php, perform, 64
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/home/xxxxx/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php, handle, 284
/home/xxxxx/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php, run, 219
/home/xxxxx/components/com_civicrm/civicrm.php, invoke, 81
/home/xxxxx/components/com_civicrm/civicrm.php, civicrm_invoke, 24
/home/xxxxx/libraries/joomla/application/component/helper.php, require_once, 162
/home/xxxxx/includes/application.php, renderComponent, 124
/home/xxxxx/index.php, dispatch, 68

Any thoughts on what happened or how to address this?

Thanks,
Dean
« Last Edit: March 15, 2011, 05:54:28 am by dnobendno »

dnobendno

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 3.3.5
  • CMS version: Joomla
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: DB Error: already exists/Contribute Page using Auth-net failing
March 15, 2011, 09:05:34 am
Okay,

This is resolved and I thought I would say how.

We are setting this site up to accept recurring payments (on authorize). Once we activated those in the contribution page, we started getting the errors.

Once we turned off the test server in the authorize account, the error went away.

Clearly there is a relationship there. I cannot tell you exactly what it is. I know that you cannot test recurring transactions on Authorize's server. You have to do that with a live card. But it was the non-recurring transactions that were failing.

Hope this helps someone.

abid.ali

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal
  • MySQL version: 5.0.51b
  • PHP version: 5.2.6
Re: DB Error: already exists/Contribute Page using Auth-net failing
March 17, 2011, 01:12:41 am
dnobendno this is not all that you are saying.

Last day i was having the same problem but resolved by making empty "civicrm_financial_trxn" civicrm table.

I am using civicrm 3.3 with drupal. This all happens because when we make some successful transactions with Authorize.Net test account then we remove all the contribution and donation etc that we made for testing. After that we again try to make transaction but that time this error happen because when we delete all the contribution and donations etc that we made, have already an entry in the civicrm financial table with a auto generated unique id that is not auto remove when we remove contribution and donations from admin.

Hope it'll help you guys...

Cheers  :)
« Last Edit: March 17, 2011, 01:14:33 am by abid.ali »

sandys

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 1
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 6.26
  • MySQL version: 5.0.92
Re: DB Error: already exists/Contribute Page using Auth-net failing
April 15, 2011, 07:59:36 am
I'm getting the same error using Authorize.net in test mode.  I searched and found this thread http://forum.civicrm.org/index.php?topic=486.0 which indicates it was fixed in version 1.8.  However, I'm using 3.3.6 and still receiving the error.

Clearing out the  "civicrm_financial_trxn" civicrm table does resolve the issue and allow test cases to go through.

xcf33

  • I post frequently
  • ***
  • Posts: 181
  • Karma: 7
  • CiviCRM version: 3.3.2
  • CMS version: Drupal 6.19/6.20
  • MySQL version: 5.x
  • PHP version: 5.2.6
Re: DB Error: already exists/Contribute Page using Auth-net failing
April 15, 2011, 08:37:30 am
abid.ali

is correct in his assessment,

If you have your payment gateway in testing mode, you should not delete any test contribution since test contribution will not show up when you do contribution search or any reports.

When you delete a transaction the corresponding financial_trxn table record does not get deleted because that table serves an important purposes of keeping financial records and "technically" does not have a relationship with the contribution table.

The best practice to test payment gateway IMO is to create a sandbox account from authorize.net (sandbox.authorize.net) and DO NOT put it in test mode and set up a payment processor with live API login/key for that test account. So that way everything is still simulated in real world (With unique transaction ID's from authorize.net, ETC)


Cheers!

sandys

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 1
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 6.26
  • MySQL version: 5.0.92
Re: DB Error: already exists/Contribute Page using Auth-net failing
April 15, 2011, 09:38:00 am
changx - good advice, and I do generally use my developer account for testing.  However, in this case my client had just set up a brand new authorize.net account and wanted to ensure that it was working. 

I tried this both ways.  The first time, I did delete the contribution (a membership) and so I wasn't surprised to get the error.  I then deleted the corresponding financial_trxn table record. 

Then, with both the membership and corresponding financial transaction removed, I tried twice more.  In both cases I received the error message, even though I did not remove the membership record (or the financial transaction). 

Personally, I'm not that concerned about it.  As I said, I typically use my own developer account for testing.  And if I need to test a client's account, I don't mind removing the records from the database if I want to use test mode on a non-developer authorize.net account (and if I need to do it again, I'll most likely remember).  But, for someone unfamiliar with Civi/phpMyAdmin/MySQL, this could be an issue.   Perhaps it should be noted on the settings screen not to use TEST mode?  Or at least that you can only do a single test transaction.

fearlsgroove

  • I’m new here
  • *
  • Posts: 25
  • Karma: 2
Re: DB Error: already exists/Contribute Page using Auth-net failing
August 23, 2011, 07:59:26 am
Dredging up an old issue here, but this shouldn't be left as a workaround. The underlying problem is that the trxn system is relying on externally supplied IDs to be unique and just blindly inserting them into the database, causing a user-visible failure if there's a dupe. So far as we can tell this is only a problem on test auth.net transactions, but who's to say that's true in the future, or that the trxn IDs from some other, production payment processor don't suddenly become non-unique for who knows what reason? That's a bug and should be fixed somehow. I'll add an issue to JIRA when I get a chance.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: DB Error: already exists/Contribute Page using Auth-net failing
August 23, 2011, 03:08:59 pm

would be great if you can investigate and supply a patch. The code for that is fairly localized to the payment / contribution code

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Osvaldo

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • Open source rocks!
Re: DB Error: already exists/Contribute Page using Auth-net failing
November 13, 2012, 10:21:31 am
Hi guys,

Just FYI. I just had this same error occur in the 4.1.5 version. I went in, deleted the deleted transaction's record from the financial_trxn table and that fixed it.
Osvaldo Gomez
Upleaf LLC

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: DB Error: already exists/Contribute Page using Auth-net failing
May 07, 2013, 07:18:49 pm
Issue observed in 4.3.1 as well - investigating now.

EDIT:

This was happening because the Authorize.net code failed to increment contributions with trxn_id like 'test%' which were not of the format 'test[0-9]+'. If your DB contained one of these, you'd run into this and test contributions would fail.

Fix submitted @ https://issues.civicrm.org/jira/browse/CRM-12560

Crude SQL workaround if you aren't on 4.3.x and want to solve the problem without blowing away all your contributions using TRUNCATE -

Code: [Select]
UPDATE civicrm_contribution SET trxn_id = REPLACE(trxn_id, 'test', 'sdgsdgsdgsdg') WHERE trxn_id LIKE 'test%' AND trxn_id NOT RLIKE 'test[0-9]+'
« Last Edit: May 07, 2013, 07:56:00 pm by grobot »
@xurizaemon ● www.fuzion.co.nz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • DB Error: already exists/Contribute Page using Auth-net failing

This forum was archived on 2017-11-26.