Skip to main content

Payment Request

Code samples to generate Signature hash while initiating payment, Use the generate signature in Init-Payment API

import (
type RequestObj struct {
ClientKey string
Currency string
Amount string
MerchantOrderId string
SuccessUrl string
FailureUrl string
func GenerateSignature(requestObj RequestObj, secretKey string) string {
params := make(url.Values)
params.Add("client_key", requestObj.ClientKey)
params.Add("currency", requestObj.Currency)
params.Add("amount", requestObj.Amount)
params.Add("merchant_order_id", requestObj.MerchantOrderId)
params.Add("success_url", requestObj.SuccessUrl)
params.Add("failure_url", requestObj.FailureUrl)
data := params.Encode()
secret := []byte(secretKey)
message := []byte(data)
hash := hmac.New(sha256.New, secret)
// to base64
hash_value := base64.StdEncoding.EncodeToString(hash.Sum(nil))
return hash_value