64 lines
2.6 KiB
Go
64 lines
2.6 KiB
Go
|
|
// Package web serves the broker's minimal hosted pages (RTL Persian). Clients
|
||
|
|
// normally redirect users back to their OWN return_url; these pages are a
|
||
|
|
// branded landing + a fallback result screen for direct visits.
|
||
|
|
package web
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"html"
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
const shell = `<!doctype html><html lang="fa" dir="rtl"><head><meta charset="utf-8">
|
||
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
|
|
<title>%s</title>
|
||
|
|
<style>
|
||
|
|
:root{color-scheme:dark}
|
||
|
|
body{margin:0;font-family:Tahoma,Vazirmatn,system-ui,sans-serif;background:#0b0d17;color:#e7e9f3;
|
||
|
|
display:flex;min-height:100vh;align-items:center;justify-content:center;text-align:center}
|
||
|
|
.card{background:#141726;border:1px solid #232742;border-radius:20px;padding:40px 32px;max-width:420px;width:90%%}
|
||
|
|
.logo{font-weight:800;font-size:22px;letter-spacing:.5px;color:#7c8cff}
|
||
|
|
h1{font-size:20px;margin:18px 0 8px}
|
||
|
|
p{color:#9aa0bd;line-height:1.9;font-size:14px;margin:6px 0}
|
||
|
|
.badge{display:inline-block;padding:6px 16px;border-radius:999px;font-size:13px;margin-top:14px}
|
||
|
|
.ok{background:rgba(34,197,94,.15);color:#4ade80}
|
||
|
|
.fail{background:rgba(239,68,68,.15);color:#f87171}
|
||
|
|
.muted{font-size:12px;color:#6a708f;margin-top:18px}
|
||
|
|
</style></head><body><div class="card">%s</div></body></html>`
|
||
|
|
|
||
|
|
func page(title, inner string) string {
|
||
|
|
return "<!--FlatPay-->" + fmt.Sprintf(shell, html.EscapeString(title), inner)
|
||
|
|
}
|
||
|
|
|
||
|
|
func Landing(c *gin.Context) {
|
||
|
|
inner := `<div class="logo">FlatRender Pay</div>
|
||
|
|
<h1>درگاه پرداخت امن</h1>
|
||
|
|
<p>این سرویس پرداختهای آنلاین را از طریق زرینپال پردازش میکند.</p>
|
||
|
|
<p class="muted">برای پرداخت، از طریق وبسایت مربوطه اقدام کنید.</p>`
|
||
|
|
c.Header("Content-Type", "text/html; charset=utf-8")
|
||
|
|
c.String(http.StatusOK, page("FlatRender Pay", inner))
|
||
|
|
}
|
||
|
|
|
||
|
|
// Result is an optional fallback screen a client may point its return_url at.
|
||
|
|
func Result(c *gin.Context) {
|
||
|
|
status := c.Query("status")
|
||
|
|
ref := c.Query("ref_id")
|
||
|
|
var inner string
|
||
|
|
if status == "Paid" {
|
||
|
|
inner = `<div class="logo">FlatRender Pay</div>
|
||
|
|
<h1>پرداخت موفق</h1>
|
||
|
|
<span class="badge ok">پرداخت با موفقیت انجام شد</span>`
|
||
|
|
if ref != "" {
|
||
|
|
inner += `<p class="muted">کد پیگیری: ` + html.EscapeString(ref) + `</p>`
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
inner = `<div class="logo">FlatRender Pay</div>
|
||
|
|
<h1>پرداخت ناموفق</h1>
|
||
|
|
<span class="badge fail">پرداخت انجام نشد یا لغو شد</span>`
|
||
|
|
}
|
||
|
|
c.Header("Content-Type", "text/html; charset=utf-8")
|
||
|
|
c.String(http.StatusOK, page("نتیجه پرداخت", inner))
|
||
|
|
}
|