I am not 100% sure why you need to do this in two lists as it would be easier to achieve in one unless you need the second list for a lookup column for other reasons.
For your question I suggest removing any calculated columns and using workflows. I have used the following setup.
- List A has two columns, "Title" & "Custom ID"
- List B has two columns, "Next Number" & "Unique ID"
See image of both lists
The workflow is separated into three stages for ease of reading but can be done as one stage:
- Create Item ID: Create an item in List B with the "Create List Item" action.
Set the "Text Number (*)" field value to "Variable: ItemID" and click ok.
- Update List B Unique ID: Update item in ListB with "update item in this list" action.
Select "ListB" from the List drop down menu.
You will need to firstly add the field value for "Next Number" to "Variable: ItemID" and "Unique ID" to "PAY-000[Variable: ItemID]".
Then you will need to find the list item.
To do this select the field "ID" from the drop down Field at the bottom of the window.
Then select the value of "Variable ItemID".
You will need to swap the data source from Current Item to "Workflow Variables and Parameters" then select the variable.
- Update List A Custom ID: Use the action "Set Field in Current Item" and choose the "Custom ID" field and for the value click on the function icon "Fx".
Change the data source to "List B".
Select "Unique ID" from "Field From Source"
In the find the list item section select the field of "ID" and the value of "Variable ItemID"
Publish your workflow (remember to set the workflow settings to start on creation unless you want to do it manually).
The workflow should now create the unique ID in the new list and then bring that unique ID into the Custom ID field.
If the number needs to be increased by 1 I can edit this post to add the calculation. Also prefixing "000" in your unique number will require you to add more actions in your workflow e.g. If ID < 10 prefix "000" if ID < 100 prefix "00".