Tagih.id

Hash-Based Signature

A signature is a unique code used to ensure the security and authenticity of data during a transaction. The signature is created using cryptographic algorithms such as RSA and SHA-256. Each time a request is received, Espay will validate the signature to ensure that the transaction data originates from you and has not been altered during transmission.
Each Espay service has a different parameter format for generating its signature. Below is the parameter combination format along with its corresponding services:
Service Message Combination
Merchant Check Invoice
Visit the service here.
Request
Signature Key + rq_uuid + trx_id + MERCHANTCHECKINVOICE
Payment Notification
Visit the service here.
Request
signature key + rq_datetime + order_id + PAYMENTREPORT
Response
signature key + rq_uuid + rs_datetime + error_code + PAYMENTREPORT-RS
Reject Billing Multiple
Visit the service here.
Request
rq_uuid + rq_datetime + comm_code + signature key + RejectBilling
Send Invoice Multiple
Visit the service here.
Request
rq_uuid + rq_datetime + comm_code + signature key + SENDINVOICEMULTI
Create Member
Visit the service here.
Request
rq_uuid + rq_datetime + comm_code + signature key + CreateMemberTagih
Signature Component
Component Description
comm_code
Member region code.
rq_datetime
Date and time of the transaction request.

Format:
Y-m-d H:i:s

Example:
2024-01-01 14:39:11
rq_uuid
Request identifier. A unique ID used to identify messages.
Signature Key
Signature key from Espay team.

Example:
s8qndd0ghZdrl04r
total_amount
Total paid amount.

Format:
250000
trx_id
Transaction ID from Espay.
How to Create a Signature

Here are the steps to create a signature based on the service requirements being used

  1. Combine the signature parameters specified by Espay using "##" as the separator.
  • Send Multiple Invoice Service Example
Combination format
##rq_uuid##rq_datetime##comm_code##signature key##SENDINVOICEMULTI##
##4445a53b-4bac-4159-ac69-f02149f53302##2021-06-2313:29:49##SGWYESSISHOP##zwvqhkqqo4gvfwwk##SENDINVOICEMULTI##
  1. Convert the combined string from step 1 into uppercase.
  • Send Multiple Invoice Service Example
Format before uppercase
##4445a53b-4bac-4159-ac69-f02149f53302##2021-06-2313:29:49##SGWYESSISHOP##zwvqhkqqo4gvfwwk##SENDINVOICEMULTI##
Format after uppercase
##4445A53B-4BAC-4159-AC69-F02149F53302##2021-06-2313:29:49##SGWYESSISHOP##ZWVQHKQQO4GVFWWK##SENDINVOICEMULTI##
  1. Apply the SHA-256 hashing algorithm to the formatted string from step 2.
  • Send Multiple Invoice Service Example
Format before uppercase
##4445A53B-4BAC-4159-AC69-F02149F53302##2021-06-2313:29:49##SGWYESSISHOP##ZWVQHKQQO4GVFWWK##SENDINVOICEMULTI##
Format after hash SHA-256
adceabc20f3d11ba1c0e9ea3c2fd58c59406823a5644222ca5cfabd56194f157




Generate Signature for Payment Notification

// Input parameter
$signature_key   = 'zwvqhkqqo4gvfwwk';
$rq_datetime     = '2021-06-2313:29:49';
$order_id        = 'ESP1624429732I2O3';
$action          = 'PAYMENTREPORT';

// 1. Gabungkan dengan '##' sebagai pemisah
$rawString = "##$signature_key##$rq_datetime##$order_id##$action##";

// 2. Ubah ke UPPERCASE
$upperString = strtoupper($rawString);

// 3. Hash dengan SHA-256
$signature = hash('sha256', $upperString);

// Tampilkan hasil (opsional)
echo "Format awal:\n " . $rawString;
echo "\n\nFormat setelah uppercase:\n " . $upperString;
echo "\n\nSignature key:\n " . $signature;
                
            




Generate Signature untuk Payment Notification

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SignatureGenerator {
    public static void main(String[] args) {
        // Input parameter
        String signatureKey  = "zwvqhkqqo4gvfwwk";
        String rqDatetime    = "2021-06-2313:29:49";
        String orderId       = "ESP1624429732I2O3";
        String action        = "PAYMENTREPORT";

        // 1. Gabungkan dengan '##' sebagai pemisah
        String rawString = "##" + signatureKey + "##" + rqDatetime + "##" + orderId + "##" + action + "##";

        // 2. Ubah ke UPPERCASE
        String upperString = rawString.toUpperCase();

        // 3. Hash dengan SHA-256
        String signature = sha256(upperString);

        // Tampilkan hasil
        System.out.println("Format awal:\n" + rawString);
        System.out.println("\nFormat setelah uppercase:\n" + upperString);
        System.out.println("\nSignature key:\n" + signature);
    }

    // Fungsi untuk menghasilkan hash SHA-256
    public static String sha256(String input) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] hash = digest.digest(input.getBytes(StandardCharsets.UTF_8));

            // Konversi byte array ke hex string
            StringBuilder hexString = new StringBuilder();
            for (byte b : hash) {
                String hex = String.format("%02x", b);
                hexString.append(hex);
            }
            return hexString.toString();

        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("SHA-256 algorithm not found");
        }
    }
}
                
              




Generate Signature untuk Payment Notification

const crypto = require('crypto');

// Input parameter
const signatureKey  = 'zwvqhkqqo4gvfwwk';
const rqDatetime    = '2021-06-2313:29:49';
const orderId       = 'ESP1624429732I2O3';
const action        = 'PAYMENTREPORT';

// 1. Gabungkan dengan '##' sebagai pemisah
const rawString = `##${signatureKey}##${rqDatetime}##${orderId}##${action}##`;

// 2. Ubah ke UPPERCASE
const upperString = rawString.toUpperCase();

// 3. Hash dengan SHA-256
const hash = crypto.createHash('sha256').update(upperString).digest('hex');

// Tampilkan hasil
console.log('Format awal:\n', rawString);
console.log('\nFormat setelah uppercase:\n', upperString);
console.log('\nSignature key:\n', hash);
                
              
Scroll to Top