Answers.Body: <p>Table civicrm_iats_customer_codes does not have the correct Customer id to match what iATS has on file. This is likely because you edited or merged the customer at some point and something got messed up in the process.
  You can use the iATS web portal to view what customer code (I know you said you found it already--but the next person might not know where to find it) iATS has associated with that donation. You can look under reports for the donation or in the Virtual Terminal for the customer name.
  You can use the API Explorer to find what civi has for the iATS customer id in the civicrm_iatscustomer_codes table. I used the settings below to find what customer ID is currently in Civi. Locate the invoice id associated with the failed transactions. Then search for that. Click the Execute button and search for "cstc": "AXXXXXXXX",in the returned data. 
  WARNING; you can change your data via the API so poke around in there with caution. Generally a Get action should be safe but create, edit, or replace actions will make changes.
  <a href="https://i.sstatic.net/CWtxe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CWtxe.png" alt="enter image description here"></a></p>
  
  <p>To fix the problem you will need to change the Customer Code for that entry in your civicrm_iats_customer_code table so it matches what iATS. iATS does not let you edit the customer code at their end so you have to do it on the civi end.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-08T19:30:00.727Z
Answers.Text: Thanks for this, cool that you're using the api in this way! Not quite the right answer to this specific issue, though.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-05T05:19:14.837Z
Answers.LastActivityDate: 2019-10-05T05:19:14.837Z
Answers.UserDisplayName: Iowa Boy
Answers.Body: <p>This sanity test and message is generated within the extension during the recurring payment job, as a precaution before talking to the iATS server. It doesn't depend on the customer record saved on the iATS server, and changing that won't have any effect.</p>
  
  <p>For details see line 240 of this file:
  <a href="https://github.com/iATSPayments/com.iatspayments.civicrm/blob/1.6.2/api/v3/Job/Iatsrecurringcontributions.php" rel="nofollow noreferrer">https://github.com/iATSPayments/com.iatspayments.civicrm/blob/1.6.2/api/v3/Job/Iatsrecurringcontributions.php</a></p>
  
  <p>The extension itself saves the id of the original contact that signs up and saves it in the table, and compares it before generating/running a recurring contribution. When you merge contacts, it should update the contact id in the iats table, so merging will not normally generate this issue.</p>
  
  <p>A more likely source of the problem is if you've been doing some kind of import of your recurring contribution data and not setting the contact id correctly.</p>
  
  <p>To correct it, you just need to update the cid field in the table civicrm_iats_customer_codes to match the corresponding contact for the recurring contribution.</p>
  
  <p>There is also an email address in this table which is sometimes useful as a reference to help you track down the real donor - looking at the record on the iATS server might also help if you need a name, etc.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-08T19:28:40.093Z
Answers.LastActivityDate: 2019-10-08T19:28:40.093Z
Answers.UserDisplayName: Alan Dixon
Body: <p>During some auditing of membership payments earlier today, we found an interesting error message on one of our members:</p>
  
  <blockquote>
    <p>iATS Payments Recurring Contribution (id=<em>nnn</em>) Errors: Recur id <em>nnn</em>
    is has a mismatched contact id for the customer code.</p>
  </blockquote>
  
  <p>There's one of these messages per day for the last week or so. The original payment did go through, we can see that on both sides (Civi and iATS). The errored attempts aren't getting sent through to iATS (which is probably a good thing). </p>
  
  <ul>
  <li>How do I go about finding the details of the recurring payment so I can compare both sides? I've found what is likely the customer record on the iATS side, but that's only showing me the customer code. </li>
  <li>Alternately, what exactly is being compared and found wanting here, and how possibly did it get messed up? </li>
  </ul>
  
  <p>Thanks in advance for any assistance!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-05T12:20:46.887Z
Comments.Text: We added some additional paranoia in the CiviCRM iATS Extension so we store the contact id associated with the tokenized credit card (iats customer code) and flag it (pop up this error message) - when they no longer match.
Comments.UserDisplayName: KarinG - Semper IT
Tags: <recurring-contributions><iats>
Title: iATS recurring payments: "mismatched contact id for the customer code"
ThreadText: # iATS recurring payments: "mismatched contact id for the customer code"
  
  (Asked by: username_0 on 2019-10-05)
  
  During some auditing of membership payments earlier today, we found an interesting error message on one of our members:
  
  > iATS Payments Recurring Contribution (id=*nnn*) Errors: Recur id *nnn*
  > is has a mismatched contact id for the customer code.
  
  There's one of these messages per day for the last week or so. The original payment did go through, we can see that on both sides (Civi and iATS). The errored attempts aren't getting sent through to iATS (which is probably a good thing).
  
  * How do I go about finding the details of the recurring payment so I can compare both sides? I've found what is likely the customer record on the iATS side, but that's only showing me the customer code.
  * Alternately, what exactly is being compared and found wanting here, and how possibly did it get messed up?
  
  Thanks in advance for any assistance!
  
  **Tags:** recurring-contributions, iats
  
  > **Comments:**
  > **username_1**: We added some additional paranoia in the CiviCRM iATS Extension so we store the contact id associated with the tokenized credit card (iats customer code) and flag it (pop up this error message) - when they no longer match.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-10-05. Score: 3
  
  Table civicrm\_iats\_customer\_codes does not have the correct Customer id to match what iATS has on file. This is likely because you edited or merged the customer at some point and something got messed up in the process.
  You can use the iATS web portal to view what customer code (I know you said you found it already--but the next person might not know where to find it) iATS has associated with that donation. You can look under reports for the donation or in the Virtual Terminal for the customer name.
  You can use the API Explorer to find what civi has for the iATS customer id in the civicrm\_iatscustomer\_codes table. I used the settings below to find what customer ID is currently in Civi. Locate the invoice id associated with the failed transactions. Then search for that. Click the Execute button and search for "cstc": "AXXXXXXXX",in the returned data.
  WARNING; you can change your data via the API so poke around in there with caution. Generally a Get action should be safe but create, edit, or replace actions will make changes.
  [![enter image description here](https://i.sstatic.net/CWtxe.png)](https://i.sstatic.net/CWtxe.png)
  
  To fix the problem you will need to change the Customer Code for that entry in your civicrm\_iats\_customer\_code table so it matches what iATS. iATS does not let you edit the customer code at their end so you have to do it on the civi end.
  
  > **Comments:**
  > **username_3**: Thanks for this, cool that you're using the api in this way! Not quite the right answer to this specific issue, though.  
  
  ---
  
  ### Answer by username_3 on 2019-10-08. Score: 3
  
  This sanity test and message is generated within the extension during the recurring payment job, as a precaution before talking to the iATS server. It doesn't depend on the customer record saved on the iATS server, and changing that won't have any effect.
  
  For details see line 240 of this file:
  <https://github.com/iATSPayments/com.iatspayments.civicrm/blob/1.6.2/api/v3/Job/Iatsrecurringcontributions.php>
  
  The extension itself saves the id of the original contact that signs up and saves it in the table, and compares it before generating/running a recurring contribution. When you merge contacts, it should update the contact id in the iats table, so merging will not normally generate this issue.
  
  A more likely source of the problem is if you've been doing some kind of import of your recurring contribution data and not setting the contact id correctly.
  
  To correct it, you just need to update the cid field in the table civicrm\_iats\_customer\_codes to match the corresponding contact for the recurring contribution.
  
  There is also an email address in this table which is sometimes useful as a reference to help you track down the real donor - looking at the record on the iATS server might also help if you need a name, etc.
  
  
  ---
  
  