Skip to main content
Skip table of contents

Connection Examples

Signature generation

JAVA
public static String getStringSHA(String cadena) {
	try {
		MessageDigest md = MessageDigest.getInstance("SHA-512");
		md.reset();
		md.update(cadena.getBytes());
		return new String(Hex.encode(md.digest()));
	} catch (NoSuchAlgorithmException e) {
		e.printStackTrace();
		System.out.println("Problema en la Encriptacion"); 
		return null;
	} 
}
C
public static String getStringSHA(String cadena) {
	try {
		MessageDigest md = MessageDigest.getInstance("SHA-512");
		md.reset();
		md.update(cadena.getBytes());
		return new String(Hex.encode(md.digest()));
	} catch (NoSuchAlgorithmException e) {
		e.printStackTrace();
		System.out.println("Problema en la Encriptacion"); 
		return null;
	} 
}
VB
Public Shared Function getStringSHA(ByVal cadena As String) As String
    Dim enc As Encoding = Encoding.UTF8
    Using sha2 As New SHA512CryptoServiceProvider()
        Dim data As Byte() = enc.GetBytes(cadena)
        Dim hash As Byte() = sha2.ComputeHash(data)
        Dim sb As New StringBuilder(hash.Length * 2)
        For Each b As Byte In hash
           sb.Append(b.ToString("x2"))
        Next
        Return sb.ToString()
    End Using
End Function

VPOS2 Connection Form

JS
<head>
<script type="text/javascript" src="https://integracion.alignetsac.com/VPOS2/js/modalcomercio.js" ></script>
</head>
<form name="f1" id="f1" action="#" method="post" class="alignet-form-vpos2">
<input type="hidden" name="acquirerId" value="144" />
<input type="hidden" name="idCommerce" value="7886" />
<input type="hidden" name="purchaseAmount" value="10000" />
<input type="hidden" name="purchaseCurrencyCode" value="604" />
<input type="hidden" name="purchaseOperationNumber" value="123456" />
<input type="hidden" name="language" value="SP" />
<input type="hidden" name="shippingFirstName" value=”Juan" />
<input type="hidden" name="shippingLastName" value="Perez" />
<input type="hidden" name="shippingEmail" value="perez.juan@test.com" />
<input type="hidden" name="shippingAddress" value="Direcion ABC" />
<input type="hidden" name="shippingZIP" value="ZIP 123" />
<input type="hidden" name="shippingCity" value="CITY ABC" />
<input type="hidden" name="shippingState" value="STATE ABC" />
<input type="hidden" name="shippingCountry" value="PE" />
<input type="hidden" name="userCommerce" value="modal123" />
<input type="hidden" name="userCodePayme" value="1--510--1010" />
<input type="hidden" name="descriptionProducts" value="Producto ABC" />
<input type="hidden" name="programmingLanguage" value="Java" />
<input type="hidden" name="purchaseVerification" value="ca9bfba5b7a3c8d197501989c1fe694ad109d5d34c5297e3…" />
<input type="hidden" name="reserved1" value="Valor Reservado 123" />
<input type="button" onclick="javascript:AlignetVPOS2.openModal('https://integracion.alignetsac.com/')" value="Comprar">
</form>

Capture of VPOS2 Response Data

JAVA
String authorizationResult = request.getParameter("authorizationResult");
String authorizationCode = request.getParameter("authorizationCode");
String errorCode = request.getParameter("errorCode");
String errorMessage = request.getParameter("errorMessage");
String bin = request.getParameter("bin");
String brand = request.getParameter("brand");
String paymentReferenceCode = request.getParameter("paymentReferenceCode");
String acquirerId = request.getParameter("acquirerId");
String idCommerce = request.getParameter("idCommerce");
String purchaseAmount = request.getParameter("purchaseAmount");
String purchaseCurrencyCode = request.getParameter("purchaseCurrencyCode");
String purchaseOperationNumber = request.getParameter("purchaseOperationNumber");
String shippingFirstName = request.getParameter("shippingFirstName");
String shippingLastName = request.getParameter("shippingLastName");
String shippingEmail = request.getParameter("shippingEmail");
String shippingAddress = request.getParameter("shippingAddress");
String shippingZIP = request.getParameter("shippingZIP");
String shippingCity = request.getParameter("shippingCity");
String shippingState = request.getParameter("shippingState");
String shippingCountry = request.getParameter("shippingCountry");
String descriptionProducts = request.getParameter("descriptionProducts");
String purchaseVerification = request.getParameter("purchaseVerification");
String purchaseVerificationComercio = Sha2.getStringSHA(acquirerId + idCommerce + purchaseOperationNumber + purchaseAmount + purchaseCurrencyCode + authorizationResult + "kBJSJbScFtxzhTYCRun?726583763869");
ArrayList<VPOS2> listaVPOS2 = new ArrayList<VPOS2>();
VPOS2 objVPOS2 = new VPOS2();
objVPOS2.setAuthorizationResult(authorizationResult);
objVPOS2.setAuthorizationCode(authorizationCode);
objVPOS2.setErrorCode(errorCode);
objVPOS2.setErrorMessage(errorMessage);
objVPOS2.setBin(bin);
objVPOS2.setBrand(brand);
objVPOS2.setPaymentReferenceCode(paymentReferenceCode);
objVPOS2.setAcquirerId(acquirerId);
objVPOS2.setIdCommerce(idCommerce);
objVPOS2.setPurchaseOperationNumber(purchaseOperationNumber);
objVPOS2.setPurchaseCurrencyCode(purchaseCurrencyCode);
objVPOS2.setPurchaseAmount(purchaseAmount);		
objVPOS2.setShippingFirstName(shippingFirstName);
objVPOS2.setShippingLastName(shippingLastName);
objVPOS2.setShippingEmail(shippingEmail);
objVPOS2.setShippingAddress(shippingAddress);
objVPOS2.setShippingZIP(shippingZIP);
objVPOS2.setShippingCity(shippingCity);
objVPOS2.setShippingState(shippingState);
objVPOS2.setShippingCountry(shippingCountry);
objVPOS2.setDescriptionProducts(descriptionProducts);
objVPOS2.setPurchaseVerification(purchaseVerification);
objVPOS2.setPurchaseVerificationComercio(purchaseVerificationComercio);
listaVPOS2.add(objVPOS2);
request.setAttribute("listaVPOS2", listaVPOS2);
C
string purchaseVerificationPayMe = Request.Form["purchaseVerification"];
string claveSecreta = "LbABXJkbcaFRLJchXCb?679658268743";
string purchaseVerificationCom = Clase.Sha2.getStringSHA(Request.Form["acquirerId"] + Request.Form["idCommerce"] + Request.Form["purchaseOperationNumber"] + Request.Form["purchaseAmount"] + Request.Form["purchaseCurrencyCode"] + Request.Form["authorizationResult"] + claveSecreta);
purchaseVerification.Text = Request.Form["purchaseVerification"];
purchaseVerificationComercio.Text = purchaseVerificationCom;
if (purchaseVerificationPayMe == null || purchaseVerificationPayMe == purchaseVerificationCom) {                
authorizationResult.Text = Request.Form["authorizationResult"];
authorizationCode.Text = Request.Form["authorizationCode"];
errorCode.Text = Request.Form["errorCode"];
errorMessage.Text = Request.Form["errorMessage"];
bin.Text = Request.Form["bin"];
brand.Text = Request.Form["brand"];
paymentReferenceCode.Text = Request.Form["paymentReferenceCode"];
acquirerId.Text = Request.Form["acquirerId"];
idCommerce.Text = Request.Form["idCommerce"];
purchaseOperationNumber.Text = Request.Form["purchaseOperationNumber"];
purchaseCurrencyCode.Text = Request.Form["purchaseCurrencyCode"];
if (Request.Form["purchaseAmount"] == null) {
purchaseAmount.Text = "0";
} else {
double amount = double.Parse(Request.Form["purchaseAmount"]) / 100;
purchaseAmount.Text = amount.ToString();
}
shippingFirstName.Text = Request.Form["shippingFirstName"];
shippingLastName.Text = Request.Form["shippingLastName"];
shippingEmail.Text = Request.Form["shippingEmail"];
shippingAddress.Text = Request.Form["shippingAddress"];
shippingZIP.Text = Request.Form["shippingZIP"];
shippingCity.Text = Request.Form["shippingCity"];
shippingState.Text = Request.Form["shippingState"];
shippingCountry.Text = Request.Form["shippingCountry"];
descriptionProducts.Text = Request.Form["descriptionProducts"];
reserved1.Text = Request.Form["reserved1"];
} else {
resultadoErroneo.Text = "Transacción Invalida. Los datos fueron alterados en el proceso de respuesta.";
}
VB
Dim purchaseVerificationPayMe As String = Request.Form("purchaseVerification")
Dim claveSecreta As String = "LbABXJkbcaFRLJchXCb?679658268743"
Dim purchaseVerificationCom As String = Sha2.getStringSHA(Request.Form("acquirerId") & Request.Form("idCommerce") & Request.Form("purchaseOperationNumber") & Request.Form("purchaseAmount") & Request.Form("purchaseCurrencyCode") & Request.Form("authorizationResult") & claveSecreta)
purchaseVerification.Text = Request.Form("purchaseVerification")
purchaseVerificationComercio.Text = purchaseVerificationCom
If (purchaseVerificationPayMe Is Nothing Or purchaseVerificationPayMe = purchaseVerificationCom) Then
authorizationResult.Text = Request.Form("authorizationResult")
authorizationCode.Text = Request.Form("authorizationCode")
errorCode.Text = Request.Form("errorCode")
errorMessage.Text = Request.Form("errorMessage")
bin.Text = Request.Form("bin")
brand.Text = Request.Form("brand")
paymentReferenceCode.Text = Request.Form("paymentReferenceCode")
acquirerId.Text = Request.Form("acquirerId")
idCommerce.Text = Request.Form("idCommerce")
purchaseOperationNumber.Text = Request.Form("purchaseOperationNumber")
purchaseCurrencyCode.Text = Request.Form("purchaseCurrencyCode")
purchaseAmount.Text = Request.Form("purchaseAmount") / 100
shippingFirstName.Text = Request.Form("shippingFirstName")
shippingLastName.Text = Request.Form("shippingLastName")
shippingEmail.Text = Request.Form("shippingEmail")
shippingAddress.Text = Request.Form("shippingAddress")
shippingZIP.Text = Request.Form("shippingZIP")
shippingCity.Text = Request.Form("shippingCity")
shippingState.Text = Request.Form("shippingState")
shippingCountry.Text = Request.Form("shippingCountry")
descriptionProducts.Text = Request.Form("descriptionProducts")
reserved1.Text = Request.Form("reserved1")
Else
resultadoErroneo.Text = "Transacción Invalida. Los datos fueron alterados en el proceso de respuesta."
End If
PHP
<?php 
$claveSecreta = 'kBJSJbScFtxzhTYCRun?726583763869';
$purchaseVericationVPOS2 = $_POST['purchaseVerification'];
echo "Compara esto (purchaseVerificationVPOS2) : ";
echo "<br>";
echo "<b>" . $purchaseVerificationVPOS2 . "</b>";
echo "<br>";
$purchaseVerificationComercio = openssl_digest($_POST['acquirerId'] . $_POST['idCommerce'] . $_POST['purchaseOperationNumber'] . $_POST['purchaseAmount'] . $_POST['purchaseCurrencyCode'] . $_POST['authorizationResult'] . $claveSecreta, 'sha512');
echo "Con esto (purchaseVerificationComercio) : ";
echo "<br>";
echo "<b>" . $purchaseVerificationComercio . "</b>";
echo "<br>";
if ($purchaseVericationVPOS2 == $purchaseVericationComercio || $purchaseVericationVPOS2 == "") { ?>
<table>
<tr><td>authorizationResult</td><td><?php echo $_POST['authorizationResult'];?></td></tr>
<tr><td>authorizationCode</td><td><?php echo $_POST['authorizationCode'];?></td></tr>
<tr><td>errorCode</td><td><?php echo $_POST['errorCode'];?></td></tr>
<tr><td>errorMessage</td><td><?php echo $_POST['errorMessage'];?></td></tr>
<tr><td>bin</td><td><?php echo $_POST['bin'];?></td></tr>
<tr><td>brand</td><td><?php echo $_POST['brand'];?></td></tr>
<tr><td>paymentReferenceCode</td><td><?php echo $_POST['paymentReferenceCode'];?></td></tr>
<tr><td>acquirerId</td><td><?php echo $_POST['acquirerId'];?></td></tr>
<tr><td>idCommerce</td><td><?php echo $_POST['idCommerce'];?></td></tr>
<tr><td>purchaseOperationNumber</td><td><?php echo $_POST['purchaseOperationNumber'];?></td></tr>
<tr><td>purchaseCurrencyCode</td><td><?php echo $_POST['purchaseCurrencyCode'];?></td></tr>
<tr><td>purchaseAmount</td><td><?php echo $_POST['purchaseAmount'];?></td></tr>
<tr><td>shippingFirstName</td><td><?php echo $_POST['shippingFirstName'];?></td></tr>
<tr><td>shippingLastName</td><td><?php echo $_POST['shippingLastName'];?></td></tr>
<tr><td>shippingEmail</td><td><?php echo $_POST['shippingEmail'];?></td></tr>
<tr><td>shippingAddress</td><td><?php echo $_POST['shippingAddress'];?></td></tr>
<tr><td>shippingZIP</td><td><?php echo $_POST['shippingZIP'];?></td></tr>
<tr><td>shippingCity</td><td><?php echo $_POST['shippingCity'];?></td></tr>
<tr><td>shippingState</td><td><?php echo $_POST['shippingState'];?></td></tr>
<tr><td>shippingCountry</td><td><?php echo $_POST['shippingCountry'];?></td></tr>
<tr><td>descriptionProducts</td><td><?php echo $_POST['descriptionProducts'];?></td></tr>
<tr><td>reserved1</td><td><?php echo $_POST['reserved1'];?></td></tr>
</table>
<?php
} else {
echo "<h1>Transacción Invalida. Los datos fueron alterados en el proceso de respuesta.</h1>";
} ?>

Continue to Pay-me Contact ➡️

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.