Modern cardiac pacemaker can sense electrical activity in both atrium and ventricle, and deliver precisely timed stimulations to one or both chambers on demand. However, little is known about how the external cardiac pacing interacts with the heart's intrinsic activity. In this study, we present an integrated dual-chamber heart and pacer (IDHP) model to simulate atrial and ventricular rhythms in the presence of dual chamber cardiac pacing and sensing. The IDHP model is an extension and improvement of a previously developed open source model for simulating ventricular rhythms in atrial fibrillation and ventricular pacing. The new model takes into account more realistic properties of atrial and ventricular rhythm generators, as well as bi-directional conductions in atrium, ventricle, and the atrio-ventricular junction. Moreover, an industry-standard dual-chamber pacemaker timing control logic is incorporated in the model. We present examples to show that the new model can generate realistic cardiac rhythms in both physiologic and pathologic conditions, and simulate various interactions between intrinsic heart activity and extrinsic cardiac pacing. Among many applications, the IDHP model provides a new simulation platform where it is possible to bench test advanced pacemaker algorithms in the presence of different types of cardiac rhythms.