| m.h = nil //clear it, very important to prevent multiple opening | m.h = nil //clear it, very important to prevent multiple opening | ||||
| } | } | ||||
| func (m *TransactionDB) addRequest(r *http.Request) (row LeanworkIn, err error) { | |||||
| func (m *TransactionDB) addRequest(r *http.Request, md5key string) (row LeanworkIn, err error) { | |||||
| if err = m.conn(Config); err != nil { | if err = m.conn(Config); err != nil { | ||||
| return row, err | return row, err | ||||
| } | } | ||||
| orderCurrency := r.FormValue("orderCurrency") | orderCurrency := r.FormValue("orderCurrency") | ||||
| customerId := r.FormValue("customerId") | customerId := r.FormValue("customerId") | ||||
| sign := r.FormValue("sign") | sign := r.FormValue("sign") | ||||
| valid := isLeanworkFormValid(r.Form) | |||||
| valid := isLeanworkFormValid(r.Form, md5key) | |||||
| ip4 := getClientIPLong(r) | ip4 := getClientIPLong(r) | ||||
| insForm, err := m.h.Prepare("INSERT INTO leanworkIn (pickupUrl, receiveUrl, signType, orderNo, orderAmount, orderCurrency, customerId, sign, valid, ip4) VALUES(?,?,?,?,?,?,?,?,?,?)") | |||||
| insForm, err := m.h.Prepare("INSERT INTO leanworkIn (pickupUrl, receiveUrl, signType, orderNo, orderAmount, orderCurrency, customerId, sign, valid, ip4, md5key) VALUES(?,?,?,?,?,?,?,?,?,?,?)") | |||||
| if err != nil { | if err != nil { | ||||
| log.Printf("Failed to prepare SQL statment for insert") | log.Printf("Failed to prepare SQL statment for insert") | ||||
| return | return | ||||
| } | } | ||||
| res, err := insForm.Exec(pickupUrl, receiveUrl, signType, orderNo, orderAmount, orderCurrency, customerId, sign, valid, ip4) | |||||
| res, err := insForm.Exec(pickupUrl, receiveUrl, signType, orderNo, orderAmount, orderCurrency, customerId, sign, valid, ip4, md5key) | |||||
| if err != nil { | if err != nil { | ||||
| log.Printf("Error inserting leanworkIn with orderNo =%s \n", orderNo) | log.Printf("Error inserting leanworkIn with orderNo =%s \n", orderNo) | ||||
| return | return | ||||
| row.Sign = sign | row.Sign = sign | ||||
| row.Valid = valid | row.Valid = valid | ||||
| row.Ip4 = ip4 | row.Ip4 = ip4 | ||||
| row.MD5Key = md5key | |||||
| log.Println("INSERT[" + strconv.FormatInt(row.Id, 10) + "]: customerId: " + customerId + " | orderAmount: " + orderCurrency + " " + orderAmount) | log.Println("INSERT[" + strconv.FormatInt(row.Id, 10) + "]: customerId: " + customerId + " | orderAmount: " + orderCurrency + " " + orderAmount) | ||||
| return row, err | return row, err |