From ca04f634ac64f08612445352fe647164dd6b285a Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 10 Mar 2020 23:23:17 +1100 Subject: [PATCH] RpnReq renamed to RpnOut --- checksum.go | 6 +++--- db.go | 6 +++--- purchase.go | 2 +- rpn.go | 24 ++++++++++++------------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/checksum.go b/checksum.go index 2283a51..bcee0d0 100644 --- a/checksum.go +++ b/checksum.go @@ -34,15 +34,15 @@ func isLeanworkFormValid(form url.Values) bool { return r == sign } -func md5RpnFormP2P(r RpnReq) string { +func md5RpnFormP2P(r RpnOut) string { return md5RpnForm(r, Config.Rpn.MD5P2P) } -func md5RpnFormFAT(r RpnReq) string { +func md5RpnFormFAT(r RpnOut) string { return md5RpnForm(r, Config.Rpn.MD5FAT) } -func md5RpnForm(r RpnReq, md5key string) string { +func md5RpnForm(r RpnOut, md5key string) string { s := "" s += "version=" + r.Version + "|" s += "sign_type=" + r.Sign_type + "|" diff --git a/db.go b/db.go index 8609b81..e3c1b38 100644 --- a/db.go +++ b/db.go @@ -90,7 +90,7 @@ func (m *TransactionDB) addRequest(r *http.Request) (row LeanworkRequest, err er return row, err } -func (m *TransactionDB) addRpnOut(r RpnReq) (row RpnReq, err error) { +func (m *TransactionDB) addRpnOut(r RpnOut) (row RpnOut, err error) { if err = m.conn(Config); err != nil { return row, err } @@ -137,8 +137,8 @@ func (m *TransactionDB) addRpnOut(r RpnReq) (row RpnReq, err error) { return row, err } -func (m *TransactionDB) updateRpnOutNameAndCard(orderid string, signature string, name string, card string) (row RpnReq, err error) { +func (m *TransactionDB) updateRpnOutNameAndCard(orderid string, signature string, name string, card string) (row RpnOut, err error) { err = nil - row = RpnReq{} + row = RpnOut{} return } diff --git a/purchase.go b/purchase.go index a76b977..9776b56 100644 --- a/purchase.go +++ b/purchase.go @@ -29,7 +29,7 @@ func StartPay(w http.ResponseWriter, r *http.Request) { askForPaymentSelection(w, row) return - // m := RpnReq{} + // m := RpnOut{} // resp, err := m.SendReq(r.Form) // if err != nil { // fmt.Fprintf(w, "invalid response from RPN") diff --git a/rpn.go b/rpn.go index 5c05ce0..294d48b 100644 --- a/rpn.go +++ b/rpn.go @@ -14,7 +14,7 @@ import ( "github.com/go-sql-driver/mysql" ) -type RpnReq struct { +type RpnOut struct { Version string Sign_type string Mid string @@ -37,8 +37,8 @@ type RpnReq struct { } // //build request from leanwork request forms -// func (m *RpnReq) buildReqByForm(form url.Values) RpnReq { -// r := RpnReq{} +// func (m *RpnOut) buildReqByForm(form url.Values) RpnOut { +// r := RpnOut{} // r.version = "1.1" // r.sign_type = "MD5" // r.mid = "EU85201311P2P" @@ -54,7 +54,7 @@ type RpnReq struct { // return r // } -func (m *RpnReq) buildReqByLeanworkRequestP2P(row LeanworkRequest, user_name string, user_cardno string) RpnReq { +func (m *RpnOut) buildReqByLeanworkRequestP2P(row LeanworkRequest, user_name string, user_cardno string) RpnOut { m.Version = "1.1" m.Sign_type = "MD5" @@ -72,7 +72,7 @@ func (m *RpnReq) buildReqByLeanworkRequestP2P(row LeanworkRequest, user_name str return *m } -func (m *RpnReq) buildReqByLeanworkRequestFAT(row LeanworkRequest, user_name string, user_cardno string) RpnReq { +func (m *RpnOut) buildReqByLeanworkRequestFAT(row LeanworkRequest, user_name string, user_cardno string) RpnOut { m.Version = "1.1" m.Sign_type = "MD5" m.Mid = Config.Rpn.MIDFAT @@ -89,7 +89,7 @@ func (m *RpnReq) buildReqByLeanworkRequestFAT(row LeanworkRequest, user_name str } //from 0.1 to 10 cents -func (m *RpnReq) translateAmountFromLeanwork(from string) string { +func (m *RpnOut) translateAmountFromLeanwork(from string) string { f, _ := strconv.ParseFloat(from, 32) f = f * 100 //convert to cents t := int(math.Ceil(f)) @@ -97,13 +97,13 @@ func (m *RpnReq) translateAmountFromLeanwork(from string) string { return s } -func (m *RpnReq) now() string { +func (m *RpnOut) now() string { t := time.Now() return t.Format("20060102150405") } //send request to RPN to initiate transaction -func (m *RpnReq) SendReq(form url.Values) (*http.Response, error) { +func (m *RpnOut) SendReq(form url.Values) (*http.Response, error) { return nil, nil // r := m.buildReqByForm(form) // hc := http.Client{Timeout: 15 * time.Second} @@ -136,7 +136,7 @@ func (m *RpnReq) SendReq(form url.Values) (*http.Response, error) { } //encode without disturbing it's original order -func (m *RpnReq) encode() string { +func (m *RpnOut) encode() string { s := "version=" + m.Version s += "&sign_type=" + m.Sign_type s += "&mid=" + m.Mid @@ -191,7 +191,7 @@ func rpnNameAndCard(w http.ResponseWriter, r *http.Request) { return } - ro := RpnReq{} + ro := RpnOut{} ro.Ip4 = getClientIPLong(r) ro.Leanwork = row.Id if rpn_type == "rpnp2p" { @@ -206,13 +206,13 @@ func rpnNameAndCard(w http.ResponseWriter, r *http.Request) { ro.sendRedirect(w, row) } -func (m *RpnReq) sendRedirect(w http.ResponseWriter, row LeanworkRequest) { +func (m *RpnOut) sendRedirect(w http.ResponseWriter, row LeanworkRequest) { //execute redirect m.Url = Config.Rpn.Url tmpl.ExecuteTemplate(w, "rpnCallOutRedirect", *m) } -func getRpnOutByOrderId(order_id string) (ret RpnReq, err error) { +func getRpnOutByOrderId(order_id string) (ret RpnOut, err error) { if err = db.conn(Config); err != nil { return }