"DB Error: already exists" for existing records in civicrm_stripe_customers table
Based on my troubleshooting this occurs if I submit a contribution as a logged-in user and the user already exists in the civicrm_stripe_customers table.
` Nov 03 16:30:01 [info] $Fatal Error Details = Array ( [callback] => Array ( [0] => CRM_Core_Error [1] => handle )
[code] => -5
[message] => DB Error: already exists
[mode] => 16
[debug_info] => INSERT INTO civicrm_stripe_customers
(contact_id, id, is_live, processor_id) VALUES ('2', 'cus_DuNJGylmc4uMLX', 1, 5) [nativecode=1062 ** Duplicate
entry '2' for key 'contact_id'] [type] => DB_Error [user_info] => INSERT INTO civicrm_stripe_customers (contact_id, id, is_live, processor_id) VALUES ('2', 'cus_DuNJGylmc4uMLX', 1, 5) [nativecode=1062 ** Duplicate entry '2' for key 'contact_id'] [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle p refix="" info="INSERT INTO civicrm_stripe_customers (contact_id, id, is_live, processor_id) VALUES ('2', 'cus_DuNJGylmc4uMLX', 1, 5) [nativecode=1062 ** Duplicate entry '2' for key 'contact_id']"] )
Nov 03 16:30:01 [info] $backTrace = #0 /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/E rror.php(232): CRM_Core_Error::backtrace("backTrace", TRUE) #1 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(921): CRM_Core_Error::handle( Object(DB_Error)) #2 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/DB.php(985): PEAR_Error->__construct(" DB Error: already exists", -5, 16, (Array:2), "INSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...") #3 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(- 5, 16, (Array:2), "INSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...") #4 /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(223): PEAR->_raiseError(Objec t(DB_mysqli), NULL, -5, 16, (Array:2), "INSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro... ", "DB_Error", TRUE) #5 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1907): PEAR->__call("rai seError", (Array:7)) #6 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseEr ror(-5, NULL, NULL, "INSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...", "1062 ** Duplica te entry '2' for key 'contact_id'") #7 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliR aiseError() #8 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simple Query("INSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...") #9 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2415): DB_common->qu ery("INSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...") #10 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1607): DB_DataObjec t->_query("INSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...") #11 /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(438): DB_DataObject->query("I NSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...") #12 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1411): CRM_Core_DAO->query("I NSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...", TRUE) #13 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/civicrm/ext/stripe/CRM/Stripe/Customer.php(56): CRM_Core_DAO:: executeQuery("INSERT INTO civicrm_stripe_customers\n (contact_id, id, is_live, pro...", (Array:4)) #14 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/civicrm/ext/stripe/CRM/Stripe/Customer.php(94): CRM_Stripe_Cus tomer::add((Array:4)) #15 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/civicrm/ext/stripe/CRM/Core/Payment/Stripe.php(470): CRM_Strip e_Customer::create((Array:4), Object(CRM_Core_Payment_Stripe)) #16 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/Payment.php(1199): CRM_Core_Payment_S tripe->doDirectPayment((Array:93), "contribute") #17 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution.php(1176): CR M_Core_Payment->doPayment((Array:93), "contribute") #18 /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution.php(1552): CR M_Contribute_Form_Contribution->processCreditCard((Array:53), (Array:1), "2") #19 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution.php(960): CRM _Contribute_Form_Contribution->submit((Array:53), 1, NULL) #20 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(489): CRM_Contribute_Form_Co ntribution->postProcess() #21 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(169): CRM _Core_Form->mainProcess() #22 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php(136): CRM Core_QuickForm_Action_Upload->realPerform(Object(CRM_Contribute_Form_Contribution), "upload") #23 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): C RM_Core_QuickForm_Action_Upload->perform(Object(CRM_Contribute_Form_Contribution), "upload") #24 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_Qu ickForm_Controller->handle(Object(CRM_Contribute_Form_Contribution), "upload") #25 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_P age->handle("upload") #26 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Page/Tab.php(320): CRM_Core_Con troller->run() #27 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Page/Tab.php(371): CRM_Contribu te_Page_Tab->edit() #28 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(309): CRM_Contribute_Page Tab->run((Array:4), NULL) #29 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runI tem((Array:13)) #30 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_inv oke((Array:4)) #31 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm.php(1248): CRM_Core_Invoke::invoke((Array:4)) #32 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-includes/class-wp-hook.php(286): CiviCRM_For_WordPress->invoke("") #33 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters("", (Array:1)) #34 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-includes/plugin.php(453): WP_Hook->do_action((Array:1)) #35 (closed) /opt/bitnami/apps/wordpress/htdocs/wp-admin/admin.php(224): do_action("toplevel_page_CiviCRM") #36 (closed) {main}`