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) »
  • recurring contribution duplicate line item error
Pages: [1]

Author Topic: recurring contribution duplicate line item error  (Read 5178 times)

civi5

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 3
  • CiviCRM version: 4.1
  • CMS version: Drupal 7
  • MySQL version: MySQL 5
  • PHP version: 5.3.6
recurring contribution duplicate line item error
August 06, 2013, 10:25:28 am
We have recurring contributions setup using authorize.net and most of them go through without a problem.  Others however just fail and do not show up in the contribution list.  I setup logging so it records all the incoming callbacks from authorize and writes them to a file.  All the transactions hit the server callback URL.  After looking over the logs I noticed that the failing transactions all seem to error out on a duplicate error in the line_item table.

This is the error in the log

Aug 04 04:22:53  [info] $Fatal Error Details = Array
(
    [callback] => Array
        (
           
  • => CRM_Core_Error
  • [1] => handle
            )

       
Code: [Select]
=> -5
    [message] => DB Error: already exists
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_line_item (entity_table , entity_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id ) VALUES ('civicrm_contribution' ,  42224 ,  1 , 'Contribution Amount' ,  1 ,  5.00 ,  5.00 ,  1 ,  2 )  [nativecode=1062 ** Duplicate entry 'civicrm_contribution-42224-1-1' for key 'UI_line_item_value']
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_line_item (entity_table , entity_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id ) VALUES ('civicrm_contribution' ,  42224 ,  1 , 'Contribution Amount' ,  1 ,  5.00 ,  5.00 ,  1 ,  2 )  [nativecode=1062 ** Duplicate entry 'civicrm_contribution-42224-1-1' for key 'UI_line_item_value']
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_line_item (entity_table , entity_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id ) VALUES ('civicrm_contribution' ,  42224 ,  1 , 'Contribution Amount' ,  1 ,  5.00 ,  5.00 ,  1 ,  2 )  [nativecode=1062 ** Duplicate entry 'civicrm_contribution-42224-1-1' for key 'UI_line_item_value']"]
)


Im not sure why it is trying to add the line_item twice. I looked in the line_item table and there are not any rows for the entityID specified.  I see entries for the previous contribution and the contributions after this one.  I looked over the table and it seems that the problem specifically is the index UL_line_item_value that requires a unique value.  If I just adjust the index so that its not unique will that break things?  I am not sure if the line item needs to be unique specifically or if the index is just for searching.

Anyone have any suggestions on how to correct this?  I am not sure why its seeing 2 lines to begin with since I cant find even one line in the table.  Where in the code should I look for this?  Any pointers are welcome.  Thanks



civi5

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 3
  • CiviCRM version: 4.1
  • CMS version: Drupal 7
  • MySQL version: MySQL 5
  • PHP version: 5.3.6
Re: recurring contribution duplicate line item error
August 10, 2013, 06:50:18 am
I wanted to update this post as I realized my paste looks pretty bad. 

I am running into duplicate line error when processing  callback requests from the authorize.net API with price sets. On some transactions it seems to create 2 line items.  I am not sure this should be a problem specifically.   Why is it not possible to create 2 of the same line item on a transaction?  I see that it errors out due to the unique index defined on the table.  Does anyone know if I can adjust this index to make it non unique and if so what will that effect further down the line? 


Specifically the problem happens in baseIPN when completeTransaction is called.  The call in this function to RecordFinancialAccounts is where it errors out.  I dont see any loops for recording multiple line items but somehow it is adding the same line item more than one as is indicated by the error in the output below.

Anyone have any suggestions or insight on where to look next? 

 I do not see any rows in the database that conflict so its all being added as a single transaction that errors out I assume.  If I look afterwards there is not a single line item for the entity_id in question so the duplicate must be created in the same process.


Code: [Select]
INSERT INTO civicrm_line_item (entity_table , entity_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id ) VALUES ('civicrm_contribution' ,  42269 ,  1 , 'Contribution Amount' ,  1 ,  5.00 ,  5.00 ,  1 ,  2 )  [nativecode=1062 ** Duplicate entry 'civicrm_contribution-42269-1-1' for key 'UI_line_item_value']
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_line_item (entity_table , entity_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id ) VALUES ('civicrm_contribution' ,  42269 ,  1 , 'Contribution Amount' ,  1 ,  5.00 ,  5.00 ,  1 ,  2 )  [nativecode=1062 ** Duplicate entry 'civicrm_contribution-42269-1-1' for key 'UI_line_item_value']
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_line_item (entity_table , entity_id , price_field_id , label , qty , unit_price , line_total , price_field_value_id , financial_type_id ) VALUES ('civicrm_contribution' ,  42269 ,  1 , 'Contribution Amount' ,  1 ,  5.00 ,  5.00 ,  1 ,  2 )  [nativecode=1062 ** Duplicate entry 'civicrm_contribution-42269-1-1' for key 'UI_line_item_value']"]
)
« Last Edit: August 10, 2013, 06:58:19 am by civi5 »

Anum Goel

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.1.5
  • CMS version: Drupal 6
  • MySQL version: 5.0.8
  • PHP version: 5.3.8
Re: recurring contribution duplicate line item error
December 27, 2013, 06:51:09 am
Hi - I am also facing the exact same issue with Authorize.net. Were you able to resolve it?

Thanks

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • recurring contribution duplicate line item error

This forum was archived on 2017-11-26.