Преглед изворни кода

handling name and cards info and start redirect using template

tags/v0.5
patrick пре 5 година
родитељ
комит
2c455aec1c
1 измењених фајлова са 30 додато и 39 уклоњено
  1. +30
    -39
      rpn.go

+ 30
- 39
rpn.go Прегледај датотеку

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

import (
"fmt"
"net/http"
"net/url"
"strconv"
@@ -24,6 +25,7 @@ type RpnReq struct {
user_name string
user_cardno string
signature string
url string //where to post entire data structure
}

//build request from leanwork request forms
@@ -96,45 +98,34 @@ func (m *RpnReq) encode() string {
return s
}

// <?php
// $data = array(
// 'version'=>'1.1',
// 'sign_type'=> 'MD5',
// 'mid' => 'EU85201311P2P', //must to use your mid
// 'notify_url' => 'https://lawipac.com/dumprequest.php',
// 'order_id' => "demo-" . date('YmdHis'),
// 'order_amount' => 120000 , //round($_POST['amount']*100),
// 'order_time' => date('YmdHis'),
// 'user_id'=> 'supertraderP2P', //$_POST['user_id'],
// 'user_name'=>"zhang3", //urlencode($_POST['user_name']),
// 'user_cardno'=>"6212262002002377849" //$_POST['user_cardno'],
// );
//receive RPN user name and card number
func rpnNameAndCard(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
fmt.Fprintf(w, "invalid 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]

// $params = array();
// foreach ($data as $field => $value) {
// if( $value == '' ) continue;
// $params[] = "$field=$value";
// }
// $params[] = "key=p1j4A3mEMj+ft0xkSfVULQ"; //must to use your key
if !(ok1 && ok2 && ok3 && ok4) {
fmt.Fprintf(w, "missing parameters")
return
}

// $data['signature'] = md5(implode('|', $params));
// ?>
row, err := db.updateRpnOutNameAndCard(order_id, signature, user_name, user_card)
if err != nil {
fmt.Fprintf(w, "cannot update transaction")
return
}

// <html>
// <head>
// <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
// </head>
// <body>
// <form id="payment" name="payment" action="https://deposit.paylomo.net/pay.php?r=payEasy" method="POST">
// <?php
// foreach ($data as $key => $val) {
// echo '<input type="hidden" name="'.$key.'" value="'.$val.'" />';
// }
// ?>
// <input type="submit" value="submit">
// </form>
// </body>
// <script type="text/javascript">
// // document.getElementById('payment').submit();
// </script>
// some text
//build rpn redirect page and send it
row.sendRedirect(w)
}

func (m *RpnReq) sendRedirect(w http.ResponseWriter) {
m.url = Config.Rpn.Url
tmpl.ExecuteTemplate(w, "rpnCallOutRedirect", *m)
}

Loading…
Откажи
Сачувај