Przeglądaj źródła

compilation bug fix

tags/v0.5
patrick 5 lat temu
rodzic
commit
aaf0bd96e3
2 zmienionych plików z 23 dodań i 8 usunięć
  1. +5
    -3
      db.go
  2. +18
    -5
      rpn.go

+ 5
- 3
db.go Wyświetl plik

@@ -58,9 +58,11 @@ func (m *TransactionDB) addRequest(r *http.Request) error {
}

func (m *TransactionDB) addRpnOut(r RpnReq) error {
return nil
}

func (m *TransactionDB) updateRpnOutNameAndCard(orderid string, signature string, name string, card string) error {

func (m *TransactionDB) updateRpnOutNameAndCard(orderid string, signature string, name string, card string) (row RpnReq, err error) {
err = nil
row = RpnReq{}
return
}

+ 18
- 5
rpn.go Wyświetl plik

@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"
"net/http"
"net/url"
@@ -98,6 +99,18 @@ func (m *RpnReq) encode() string {
return s
}

func retrieveFormValue(form url.Values, key string) (r string, err error) {

if _, ok := form[key]; ok {
r = form[key][0]
err = nil
} else {
r = ""
err = errors.New("Key [" + key + "] not found in HTTP request")
}
return r, err
}

//receive RPN user name and card number
func rpnNameAndCard(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
@@ -105,12 +118,12 @@ func rpnNameAndCard(w http.ResponseWriter, r *http.Request) {
return
}
r.ParseForm()
order_id, ok1 := r.Form["id"][0]
signature, ok2 := r.Form["si"][0]
user_name, ok3 := r.Form["name"][0]
user_card, ok4 := r.Form["card"][0]
order_id, ok1 := retrieveFormValue(r.Form, "id")
signature, ok2 := retrieveFormValue(r.Form, "si")
user_name, ok3 := retrieveFormValue(r.Form, "name")
user_card, ok4 := retrieveFormValue(r.Form, "card")

if !(ok1 && ok2 && ok3 && ok4) {
if !(ok1 == nil && ok2 == nil && ok3 == nil && ok4 == nil) {
fmt.Fprintf(w, "missing parameters")
return
}

Ładowanie…
Anuluj
Zapisz