소스 검색

RpnReq renamed to RpnOut

master
patrick 5 년 전
부모
커밋
ca04f634ac
4개의 변경된 파일19개의 추가작업 그리고 19개의 파일을 삭제
  1. +3
    -3
      checksum.go
  2. +3
    -3
      db.go
  3. +1
    -1
      purchase.go
  4. +12
    -12
      rpn.go

+ 3
- 3
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 + "|"

+ 3
- 3
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
}

+ 1
- 1
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")

+ 12
- 12
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
}

Loading…
취소
저장