Zend certified PHP/Magento developer

Payment Gateway sales_order Foreign Key Integrity Constraint Violation

I’m developing a payment gateway module and would like to persist some of the payment provider’s return data to a custom table named xxx_yyy_transaction_log. The field order_id is a foreign key to the table sales_order in this table. I used the placeRequest method on ClientInterface class to persist the data. The issue is that when the placeRequest method is called, the sales_order entity has not yet been persisted, resulting in an integrity constraint violation. I’d like to know if there is a way to incorporate my persistence into the gateway database transaction or if there is another class where I could store my data to database.