API Visa Checkout JSon exemplo C#

Notari
Regular Visitor

API Visa Checkout JSon exemplo C#

I seek information about Visa Checkout API for JSon integration, examples in C #

2 REPLIES 2
API_Products
Visa Developer Support Specialist

Re: API Visa Checkout JSon exemplo C#

Hey @Notari,

 

If you'd like to integrate with Visa Checkout, you can follow the integration guides here -  

https://developer.visa.com/capabilities/visa_checkout/docs  

 

Please remember you need to have an active merchant acquiring account to process Visa Checkout transactions.

 




Thanks,

Diana H.



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.

Re: API Visa Checkout JSon exemplo C#

If you are referring to the decrypting Visa Checkout Consumer information with C#, below is a C# Decryption Example:

 

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
class Decrypt {
const int HMAC_LENGTH = 32, IV_LENGTH = 16;
public static String decryptPayload(String key, String wrappedKey, String payload) {
return Encoding.UTF8.GetString(decrypt(decrypt(Encoding.UTF8.GetBytes(key),
Convert.FromBase64String(wrappedKey)), Convert.FromBase64String(payload)));
}
public static byte[] decrypt(byte[] key, byte[] data) {
if (data == null || data.Length <= IV_LENGTH + HMAC_LENGTH) {
throw new ArgumentException("Bad input data", "data");
}
byte[] hmac = new byte[HMAC_LENGTH];
Array.Copy(data, 0, hmac, 0, HMAC_LENGTH);
byte[] iv = new byte[IV_LENGTH];
Array.Copy(data, HMAC_LENGTH, iv, 0, IV_LENGTH);
byte[] payload = new byte[data.Length - HMAC_LENGTH - IV_LENGTH];
Array.Copy(data, HMAC_LENGTH + IV_LENGTH, payload, 0, payload.Length);
//if (byteArrayEquals(hmac, dohmac(key, byteArrayConcat(iv, payload)))) {
// TODO: Handle HMAC validation failure
//}
Aes aes = new AesManaged();
aes.BlockSize = 128;
aes.KeySize = 256;
aes.Key = hash(key);
aes.IV = iv;
aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.PKCS7;
MemoryStream ms = new MemoryStream();
CryptoStream cs=new CryptoStream(ms,aes.CreateDecryptor(),CryptoStreamMode.Write);
cs.Write(payload, 0, payload.Length);
cs.FlushFinalBlock();
return ms.ToArray();
}
public static byte[] hash(byte[] key) {
return (new SHA256Managed()).ComputeHash(key);
}
public static byte[] dohmac(byte[] key, byte[] data) {
return (new HMACSHA256(key)).ComputeHash(data);
}
public static void Main(string[] args) {
Console.WriteLine(decryptPayload("SECRET_KEY", "..."));
}
}

 

 



Powered by NexWebSites.com