// NextPay.IR Go Sample // docs : https://nextpay.org/nx/docs //////////// // step 1 // //////////// package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://nextpay.org/nx/gateway/token" method := "POST" payload := strings.NewReader("api_key=b11ee9c3-d23d-414e-8b6e-f2370baac97b&amount=74250&order_id=85NX85s427&customer_phone=09121234567&custom_json_fields=%7B%20%22productName%22%3A%22Shoes752%22%20%2C%20%22id%22%3A52%20%7D&callback_uri=https%3A%2F%2FyourWebsite.com%2Fcallback") client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) return } req.Header.Add("Content-Type", "application/x-www-form-urlencoded") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } //////////// // step 5 // //////////// package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://nextpay.org/nx/gateway/verify" method := "POST" payload := strings.NewReader("api_key=b11ee9c3-d23d-414e-8b6e-f2370baac97b&amount=74250&trans_id=f7c07568-c6d1-4bee-87b1-4a9e5ed2e4c1") client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) return } req.Header.Add("Content-Type", "application/x-www-form-urlencoded") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }