That's exactly how it works.
The contact with the credit card processor is done on the background while the users get a "loading screen"
When the server replies, the response is parsed and shown based on it's result
So your users never have to leave your page when paying, plus, you get transaction information for you to store, or handle to your needs.