diff --git a/checksum.go b/checksum.go index 4979286..2283a51 100644 --- a/checksum.go +++ b/checksum.go @@ -44,16 +44,16 @@ func md5RpnFormFAT(r RpnReq) string { func md5RpnForm(r RpnReq, md5key string) string { s := "" - s += "version=" + r.version + "|" - s += "sign_type=" + r.sign_type + "|" - s += "mid=" + r.mid + "|" - s += "notify_url=" + r.notify_url + "|" - s += "order_id=" + r.order_id + "|" - s += "order_amount=" + r.order_amount + "|" - s += "order_time=" + r.order_time + "|" - s += "user_id=" + r.user_id + "|" - s += "user_name=" + r.user_name + "|" - s += "user_cardno=" + r.user_cardno + "|" + s += "version=" + r.Version + "|" + s += "sign_type=" + r.Sign_type + "|" + s += "mid=" + r.Mid + "|" + s += "notify_url=" + r.Notify_url + "|" + s += "order_id=" + r.Order_id + "|" + s += "order_amount=" + r.Order_amount + "|" + s += "order_time=" + r.Order_time + "|" + s += "user_id=" + r.User_id + "|" + s += "user_name=" + r.User_name + "|" + s += "user_cardno=" + r.User_cardno + "|" s += "key=" + md5key fmt.Println(s) fmt.Println(md5str(s)) diff --git a/form/rpnAskNameAndCard.tmpl b/form/rpnAskNameAndCard.tmpl index afa7031..7e919d4 100644 --- a/form/rpnAskNameAndCard.tmpl +++ b/form/rpnAskNameAndCard.tmpl @@ -3,7 +3,6 @@ {{ template "Menu" }}

-

diff --git a/form/rpnCallOutRedirect.tmpl b/form/rpnCallOutRedirect.tmpl index 9568a0c..24432b6 100644 --- a/form/rpnCallOutRedirect.tmpl +++ b/form/rpnCallOutRedirect.tmpl @@ -1,18 +1,20 @@ {{ define "rpnCallOutRedirect" }} - - - - - - - - - - - - + + + + + + + + + + + + +
+ {{ end }} \ No newline at end of file diff --git a/rpn.go b/rpn.go index 8c28e94..42f285d 100644 --- a/rpn.go +++ b/rpn.go @@ -15,18 +15,18 @@ import ( // var md5p2p = "370296119874502" // var md5fat = "207841502473198" type RpnReq struct { - version string - sign_type string - mid string - notify_url string - order_id string - order_amount string - order_time string //YYYYMMDDHHMMSS - user_id string - user_name string - user_cardno string - signature string - url string //where to post entire data structure + Version string + Sign_type string + Mid string + Notify_url string + Order_id string + Order_amount string + Order_time string //YYYYMMDDHHMMSS + User_id string + User_name string + User_cardno string + Signature string + Url string //where to post entire data structure } // //build request from leanwork request forms @@ -49,34 +49,34 @@ type RpnReq struct { func (m *RpnReq) buildReqByLeanworkRequestP2P(row LeanworkRequest, user_name string, user_cardno string) RpnReq { r := RpnReq{} - r.version = "1.1" - r.sign_type = "MD5" - r.mid = Config.Rpn.MIDP2P - r.notify_url = "http://rpn.supertraderfx.ayvwd8em49pvoa3g.com/rpn_notify" - r.order_id = row.OrderNo - r.order_amount = m.translateAmountFromLeanwork(row.OrderAmount) - r.order_time = m.now() - r.user_id = row.CustomerId - r.user_name = user_name - r.user_cardno = user_cardno - r.signature = md5RpnFormP2P(r) + r.Version = "1.1" + r.Sign_type = "MD5" + r.Mid = Config.Rpn.MIDP2P + r.Notify_url = "http://rpn.supertraderfx.ayvwd8em49pvoa3g.com/rpn_notify" + r.Order_id = row.OrderNo + r.Order_amount = m.translateAmountFromLeanwork(row.OrderAmount) + r.Order_time = m.now() + r.User_id = row.CustomerId + r.User_name = user_name + r.User_cardno = user_cardno + r.Signature = md5RpnFormP2P(r) *m = r return r } func (m *RpnReq) buildReqByLeanworkRequestFAT(row LeanworkRequest, user_name string, user_cardno string) RpnReq { r := RpnReq{} - r.version = "1.1" - r.sign_type = "MD5" - r.mid = Config.Rpn.MIDFAT - r.notify_url = "http://rpn.supertraderfx.ayvwd8em49pvoa3g.com/rpn_notify" - r.order_id = row.OrderNo - r.order_amount = m.translateAmountFromLeanwork(row.OrderAmount) - r.order_time = m.now() - r.user_id = row.CustomerId - r.user_name = user_name - r.user_cardno = user_cardno - r.signature = md5RpnFormFAT(r) + r.Version = "1.1" + r.Sign_type = "MD5" + r.Mid = Config.Rpn.MIDFAT + r.Notify_url = "http://rpn.supertraderfx.ayvwd8em49pvoa3g.com/rpn_notify" + r.Order_id = row.OrderNo + r.Order_amount = m.translateAmountFromLeanwork(row.OrderAmount) + r.Order_time = m.now() + r.User_id = row.CustomerId + r.User_name = user_name + r.User_cardno = user_cardno + r.Signature = md5RpnFormFAT(r) *m = r return r } @@ -130,17 +130,17 @@ func (m *RpnReq) SendReq(form url.Values) (*http.Response, error) { //encode without disturbing it's original order func (m *RpnReq) encode() string { - s := "version=" + m.version - s += "&sign_type=" + m.sign_type - s += "&mid=" + m.mid - s += "¬ify_url=" + url.QueryEscape(m.notify_url) - s += "&order_id=" + m.order_id - s += "&order_amount=" + m.order_amount - s += "&order_time=" + m.order_time - s += "&user_id=" + m.user_id - s += "&user_name=" + m.user_name - s += "&user_cardno=" + m.user_cardno - s += "&signature=" + m.signature + s := "version=" + m.Version + s += "&sign_type=" + m.Sign_type + s += "&mid=" + m.Mid + s += "¬ify_url=" + url.QueryEscape(m.Notify_url) + s += "&order_id=" + m.Order_id + s += "&order_amount=" + m.Order_amount + s += "&order_time=" + m.Order_time + s += "&user_id=" + m.User_id + s += "&user_name=" + url.QueryEscape(m.User_name) + s += "&user_cardno=" + m.User_cardno + s += "&signature=" + m.Signature return s } @@ -195,7 +195,6 @@ func rpnNameAndCard(w http.ResponseWriter, r *http.Request) { func (m *RpnReq) sendRedirect(w http.ResponseWriter, row LeanworkRequest) { //create db record - - m.url = Config.Rpn.Url + m.Url = Config.Rpn.Url tmpl.ExecuteTemplate(w, "rpnCallOutRedirect", *m) }