• Francia
Back Office Vendedor
asistencia
FAQcontacte el soporte tecnico
Buscar
Categoria
Tags
Perú
Perú
Página principal
Casos de uso
Crear un pago
Crear un pago en cuotas
Crear un pago por token
Crear un enlace de pago
Crear una suscripción
Gestione sus suscripciones
Gestione sus transacciones
Analizar los diarios
Docs API
Formulario incrustado
API REST
API REST PCI-DSS
Formulario en redirección
Pago móvil
Intercambio de ficheros
Ejemplo de código
Módulos de pago
Guías
Back Office Vendedor
Guías funcionales

Ejemplo de implementación en JAVA

Definición de una clase de utilidad Sha utilizando el algoritmo HMAC-SHA-256 para calcular la firma:

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.TreeMap;
public class VadsSignatureExample {
 /**
  * Build signature (HMAC SHA-256 version) from provided parameters and secret key.
  * Parameters are provided as a TreeMap (with sorted keys).
  */
 public static String buildSignature(TreeMap<String, String> formParameters, String
  secretKey) throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException {
   // Build message from parameters
   String message = String.join("+", formParameters.values());
   message += "+" + secretKey;
   // Sign
   return hmacSha256Base64(message, secretKey);
  }	                    
    /**
    * Actual signing operation.
    */
 public static String hmacSha256Base64(String message, String secretKey) throws
  NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException {
   // Prepare hmac sha256 cipher algorithm with provided secretKey
   Mac hmacSha256;
   try {
    hmacSha256 = Mac.getInstance("HmacSHA256");
   } catch (NoSuchAlgorithmException nsae) {
    hmacSha256 = Mac.getInstance("HMAC-SHA-256");
   }
   SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA256");
   hmacSha256.init(secretKeySpec);
   // Build and return signature
   return Base64.getEncoder().encodeToString(hmacSha256.doFinal(message.getBytes("UTF-8")));
  }
}
© 2025 Todos los derechos reservados de Izipay
25.17-1.11