| s += form["customerId"][0] | s += form["customerId"][0] | ||||
| s += Config.LeanWork.MD5Key | s += Config.LeanWork.MD5Key | ||||
| } | } | ||||
| fmt.Println("leanwork form: " + s) | |||||
| return md5str(s) | return md5str(s) | ||||
| } | } | ||||
| "UrlCallBack": "http://debug.biukop.com:8080/rpn_notify" | "UrlCallBack": "http://debug.biukop.com:8080/rpn_notify" | ||||
| }, | }, | ||||
| "LeanWork": { | "LeanWork": { | ||||
| "MD5KEY2": "370296119874502", | |||||
| "MD5Key": "492815086935204", | "MD5Key": "492815086935204", | ||||
| "MD5P2P": "370296119874502", | "MD5P2P": "370296119874502", | ||||
| "MD5FAT": "207841502473198" | "MD5FAT": "207841502473198" |
| log.Println("Fatal: Cannot read leanwork Http Response " + err.Error()) | log.Println("Fatal: Cannot read leanwork Http Response " + err.Error()) | ||||
| } | } | ||||
| bodyString := string(bodyBytes) | bodyString := string(bodyBytes) | ||||
| m.LeanworkResp = bodyString | |||||
| m.add2db() | |||||
| if strings.Contains(strings.ToLower(bodyString), "success") { | if strings.Contains(strings.ToLower(bodyString), "success") { | ||||
| retry = false | retry = false | ||||
| } else { | } else { | ||||
| log.Println("Leanwork response without success word : " + bodyString) | log.Println("Leanwork response without success word : " + bodyString) | ||||
| } | } | ||||
| retry = false | |||||
| } | } | ||||
| return | return | ||||
| } | } |
| POST /rpn_notify HTTP/1.1 | |||||
| Host: debug.biukop.com:8080 | |||||
| Accept: */* | |||||
| Content-Length: 207 | |||||
| Content-Type: application/x-www-form-urlencoded | |||||
| User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20110619 Firefox/5.0 | |||||
| order_id=200311012853TW002184000000000001&order_time=20200311012906&order_amount=120000&deal_id=135104086958&deal_time=20200311013317&pay_amount=120000&pay_result=3&signature=4fd8f8e81e35d679370b957b019d4c7d |
| "fmt" | "fmt" | ||||
| "log" | "log" | ||||
| "net/http" | "net/http" | ||||
| "net/http/httputil" | |||||
| ) | ) | ||||
| func rpnNotify(w http.ResponseWriter, r *http.Request) { | func rpnNotify(w http.ResponseWriter, r *http.Request) { | ||||
| logRequestDebug(httputil.DumpRequest(r, true)) | |||||
| if r.Method != "POST" { | if r.Method != "POST" { | ||||
| errPage(w, http.StatusMethodNotAllowed, "invalid request") | errPage(w, http.StatusMethodNotAllowed, "invalid request") | ||||
| return | return | ||||
| return | return | ||||
| } | } | ||||
| func logRequestDebug(data []byte, err error) { | |||||
| if err == nil { | |||||
| fmt.Printf("%s\n\n", string(data)) | |||||
| } else { | |||||
| log.Fatalf("%s\n\n", err) | |||||
| } | |||||
| } | |||||
| //receive RPN user name and card number | //receive RPN user name and card number | ||||
| func rpnNameAndCard(w http.ResponseWriter, r *http.Request) { | func rpnNameAndCard(w http.ResponseWriter, r *http.Request) { | ||||
| if r.Method != "POST" { | if r.Method != "POST" { |
| s += "|pay_result=" + m.Pay_result | s += "|pay_result=" + m.Pay_result | ||||
| s += "|key=" + m.md5key() | s += "|key=" + m.md5key() | ||||
| sig = md5str(s) | sig = md5str(s) | ||||
| //log.Println("signature of rpnIn = " + sig + " using key " + m.md5key()) | |||||
| log.Println("signature of rpnIn = " + sig + " using key " + m.md5key()) | |||||
| return | return | ||||
| } | } | ||||
| func (m *RpnOut) getMD5Key() string { | func (m *RpnOut) getMD5Key() string { | ||||
| if m.Mid == Config.Rpn.MIDP2P { | if m.Mid == Config.Rpn.MIDP2P { | ||||
| return Config.Rpn.MD5P2P | return Config.Rpn.MD5P2P | ||||
| } else if m.Mid == Config.Rpn.MD5FAT { | |||||
| } else if m.Mid == Config.Rpn.MIDFAT { | |||||
| return Config.Rpn.MD5FAT | return Config.Rpn.MD5FAT | ||||
| } else { | } else { | ||||
| return "" | return "" |