postgresql – postgres does not save all data after committing

In my golang project that use gorm as ORM and posgress as database, in some sitution when I begin transaction to change three tables and commiting, just one of tables changes. two other tables data does not change. any idea how it might happen?

you can see example below

o := *gorm.DB
tx := gorm.Begin()
invoice.Number = 1
err := tx.Save(&invoice)
if err != nil {
    err2 := tx.RollBack().Error()
    return err
}


receipt.Ref = "1331"
err = tx.Save(&receipt)
if err != nil {
    err2 := tx.RollBack().Error()
    return err
}

payment.status = "succeed"
err = tx.Save(&payment)
if err != nil {
    err2 := tx.RollBack().Error()
    return err
}

err = tx.Commit()
if err != nil {
    err2 := tx.Rollback()
    return err
}

Just payment data changed and I’m not getting any error.