When your batch completes, erase the cust_pay_batch records in that batch and add any necessary paymants to the cust_pay table. Example code to add payments is:
use FS::cust_pay;
# loop over all records in batch
my $payment=create FS::cust_pay (
'invnum' => $invnum,
'paid' => $paid,
'_date' => $_date,
'payby' => $payby,
'payinfo' => $payinfo,
'paybatch' => $paybatch,
);
my $error=$payment->insert;
if ( $error ) {
#process error
}
# end loop
All fields except paybatch are contained in the cust_pay_batch table. You can use paybatch field to track particular batches and/or particular transactions within a batch.