Tarlanpayments
Eng
Eng
  • Acquiring
    • General information
      • Structure of payment processing
      • Kinds of operations
      • 3D-Secure
      • PCI DSS
    • Types of transactions
    • Structure of system responses
    • Error code
    • Transaction statuses
    • Signature Creation
    • Additional parameters
    • Interaction with the payment method
      • Initiating funds receipts
      • Initiating pay out
      • Card link
      • Initiating funds using Apple Pay
      • Initiating funds using Google Pay
      • Iframe
    • Payments without form of payment
      • One click
    • Smart Pay
      • Google pay
    • Supplementary methods
      • Removal of a linked user card
      • Verification of transaction status
      • Receiving a list of cards
      • Refund
      • Upper fee calculation
    • Webhook of the payment system
      • Payment Status
      • Payment ready to be made
    • Tilda Publishing
    • Edit summary
  • AGWS
    • Account Status Codes Guide
    • Error Codes
    • Reason for operation rejection
    • Transaction Lifetime
    • Transaction Status Guide
    • Creating a Signature
    • Check account status
    • Make a payment
    • Checking the refill status
    • Checking the remaining balance on the account
    • Confirmation of funds debit
    • Creating a payment link
    • Showcase Flow
    • Service Provider Flow
    • Payment System Callback
    • Payment Processing Scheme
  • Receiving a fiscal receipt
  • Calculation of the upper commission
Powered by GitBook
On this page
  1. AGWS

Creating a Signature

Requests to interact with the service are signed using the SHA256 algorithm. The signature is created separately for each request.

To create a signature, the following steps must be taken:

  1. The request body is sorted alphabetically and encoded in BASE64.

  2. Concatenate the encoded request body and the secret_key (provided separately).

  3. By using the SHA256 hash function, hash the concatenation result.

  4. Add X-signature to the request headers.

Request fields filled with "" do not participate in creating the signature.

import json
import base64
import hashlib
#Тело запроса меняется в зависимости от запроса

request_data = {
  "agent": "tarlan",
  "project": "mobile",
  "service_code": "101",
}
#Для примера взяли secret 12345
secret = "12345"

sorted_data = json.dumps(
      request_data,
      sort_keys=True,
      ensure_ascii=False,
      separators=(',', ':'),
  )


base64_encoded_data = base64.b64encode(sorted_data.encode()).decode()

data_to_sign = base64_encoded_data + secret

sha256_hash = hashlib.sha256(data_to_sign.encode()).hexdigest()

print("Sign:",sha256_hash)
package main

import (
  "crypto/sha256"
  "encoding/base64"
  "encoding/json"
  "fmt"
) 
//Тело запроса меняется в зависимости от запроса

type Request struct {
  Agent       string `json:"agent"`
  Project     string `json:"project"`
  ServiceCode string `json:"service_code"`
}
//Для примера secret 12345
const secret = "12345"

func main() {
  request := Request{
      Agent:       "tarlan",
      Project:     "mobile",
      ServiceCode: "101",
  }

  notSortedJson, err := json.Marshal(&request)
  if err != nil {
      panic(err)
  }

  var notSortedMap map[string]interface{}

  if err = json.Unmarshal(notSortedJson, &notSortedMap); err != nil {
      panic(err)
  }

  sortedJson, err := json.Marshal(&notSortedMap)
  if err != nil {
      panic(err)
  }

  signData := base64.StdEncoding.EncodeToString(sortedJson)

  sign := sha256.Sum256([]byte(signData + secret))
fmt.Printf("Sign: %x", sign) }

Last updated 8 months ago