-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
64 lines (62 loc) · 1.53 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import(
"net/http"
)
func main(){
http.HandleFunc("/search", handler)
http.ListenAndServe("", nil)
}
func handler(w http.ResponseWriter, r *http.Request) {
server:= newServer(&w,r)
IDTokenStr, err := server.getStr.header("IDToken")
if err!=nil{
logger.Printf(err.Error())
server.execStr.respond(err.Error())
return
}
context := r.Context()
firebase, err := newFirebase(&context)
if err!=nil{
logger.Printf(err.Error())
server.execStr.respond(err.Error())
return
}
firebaseToken, err := firebase.getToken.fromTokenStr(IDTokenStr)
if err!=nil{
logger.Printf(err.Error())
server.execStr.respond(err.Error())
return
}
mysql, err := newMysql()
if err!=nil{
logger.Printf(err.Error())
server.execStr.respond(err.Error())
return
}
UID := firebase.getStr.UIDFromToken(firebaseToken)
paymentID, err := mysql.getStr.paymentIDFromUID(UID)
if err!=nil{
logger.Printf(err.Error())
server.execStr.respond(err.Error())
return
}
paypal, err := newPaypal()
accessToken, err := paypal.getStr.accessToken()
if err!=nil{
logger.Printf(err.Error())
server.execStr.respond(err.Error())
return
}
varifiedPayment, err := paypal.getBool.varifyPaymentFromPaymentID(paymentID,accessToken)
if err!=nil{
logger.Printf(err.Error())
server.execStr.respond(err.Error())
return
}
if varifiedPayment{
//아래 줄은 보안상 나중에 꼭 삭제하기!!!!! cors!!!!
server.setStr.header("Access-Control-Allow-Origin","*")
//all is varified. Respond and give result!!!!
server.execStr.respond("results")
}
}