Hi,
Yes, you can do what you are looking to do using the API.
1. Create a new order with the option to generate invoice for the order using API:addOrder method.
2. Generate a page to list the invoice along with payment options to the client.
3. Redirect the client to payment page which would connect to your payment gateway.
4. Your gateway then processes the payment and redirects/sends the response back.
5. Receive the response and use API:addInvoicePayment method to capture a successfull payment.
You might as well have to do other tasks depending on what these methods actually do. Keep in mind it is a lot more work to accomplish everything using the API.
Hope this helps.
Thanks.