Skip to content

Instantly share code, notes, and snippets.

@jincod
Created August 22, 2014 07:30
Show Gist options
  • Save jincod/56b3f7aa7562b3d3c02f to your computer and use it in GitHub Desktop.
Save jincod/56b3f7aa7562b3d3c02f to your computer and use it in GitHub Desktop.
Internet magazine
app.post '/pay', (req, res) ->
payment =
account: req.body.account
value: req.body.value
transactionId: (Math.random() * 1e18).toString(36)
res.redirect "#{appUrl}/#{payment.account}/#{payment.value}/#{payment.transactionId}?returnUrl=#{returnUrl}"
app.post '/payment', (req, res) ->
input = req.body.account + req.body.value + req.body.transactionId + secureKey
sign = crypto.createHash("md5").update(input).digest("hex")
isTrue = sign is req.body.hash
result =
account: req.body.account
value: req.body.value
transactionId: req.body.transactionId
hash: req.body.hash
isTrue: isTrue
res.render 'payment', result
<h1>Перевод</h1>
<form action="/pay" method="post" class="form-horizontal" role="form">
<div class="form-group">
<label class="col-sm-1 control-label">Сумма: </label>
<div class="col-sm-5">
<input type="text" class="form-control" name="value" value="10">
</div>
</div>
<div class="form-group">
<div class="col-sm-5">
<div class="radio">
<label class="control-label">
<input type="radio" checked="true" name="account" value="5598191477">Cash4Pay
</label>
</div>
</div>
</div>
<input class="btn btn-primary btn-lg" type="submit" value="Оплатить">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment