private void persistPayment(Details details, String[] lastPayerID,
			String[] lastRecipientID, long lastDetailID) throws SQLException {

		Connection connection = null;
		PreparedStatement preparedStatement = null;

		String insertSQL = "INSERT INTO payments"
				+ "(id_physical_payer,id_legal_payer,id_physical_recipient,id_legal_recipient,id_detail,payment_code) VALUES"
				+ "(?,?,?,?,?,?)";

		try {
			connection = provider.getConnection();
			preparedStatement = connection.prepareStatement(insertSQL);

			preparedStatement.setString(1, lastPayerID[0]);
			preparedStatement.setString(2, lastPayerID[1]);
			preparedStatement.setString(3, lastRecipientID[0]);
			preparedStatement.setString(4, lastRecipientID[1]);
			preparedStatement.setString(5, String.valueOf(lastDetailID));
			preparedStatement.setString(6, details.getPaymentCode());

			preparedStatement.executeUpdate();

		} catch (SQLException e) {
			if (e.getSQLState().equals(IConnectionProvider.DUPLICATE_STATE)) {
				logger.warn("Duplicate entry. Keep working");
				return;
			} else {
				logger.error("SQL error during 'persistDetails'", e);
				throw e;

			}

		} finally {

			if (preparedStatement != null) {
				preparedStatement.close();
			}

			if (connection != null) {
				connection.close();
			}

		}
	}