public static string CreateJasonRequest(IPGData iPGData) { RequestClass requestClass = new RequestClass(); requestClass.Request.CmsPreservationId = iPGData.CmsPreservationId; requestClass.Request.AcceptorId = iPGData.AcceptorId; requestClass.Request.amount = iPGData.Amount; requestClass.Request.BillInfo = iPGData.BillInfo; requestClass.Request.multiplexParameters = iPGData.MultiplexParameters; requestClass.Request.PaymentId = iPGData.PaymentId; requestClass.Request.RequestId = iPGData.RequestId; requestClass.Request.RevertUri = iPGData.RevertURL; requestClass.Request.terminalId = iPGData.TreminalId; requestClass.Request.RequestTimestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; requestClass.Request.transactionType = iPGData.TransactionType; CreateAESCoding(requestClass, iPGData.RsaPublicKey, iPGData.PassPhrase, requestClass.Request.multiplexParameters == null ? false : true); try { } catch (Exception ex) { } return(JsonConvert.SerializeObject(requestClass));; }
private static void CreateAESCoding(this RequestClass requestClass, string rsaPublicKey, string passPhrase, bool isMultiplex) { try { string baseString = requestClass.Request.terminalId + passPhrase + requestClass.Request.amount.ToString().PadLeft(12, '0') + (isMultiplex ? "01" : "00") + (isMultiplex ? requestClass.Request.multiplexParameters.Select(t => $"{t.Iban.Replace("IR", "2718")}{t.Amount.ToString().PadLeft(12, '0')}") .Aggregate((a, b) => $"{a}{b}") : string.Empty); using (Aes myAes = Aes.Create()) { myAes.KeySize = 128; myAes.GenerateKey(); myAes.GenerateIV(); byte[] keyAes = myAes.Key; byte[] ivAes = myAes.IV; byte[] resultCoding = new byte[48]; byte[] baseStringbyte = baseString.HexStringToByteArray(); byte[] encrypted = EncryptStringToBytes_Aes(baseStringbyte, myAes.Key, myAes.IV); byte[] hsahash = new SHA256CryptoServiceProvider().ComputeHash(encrypted); resultCoding = CombinArray(keyAes, hsahash); requestClass.AuthenticationEnvelope.Data = RSAData(resultCoding, rsaPublicKey).ByteArrayToHexString(); // string decripte = DecryptStringFromBytes_Aes(encrypted, myAes.Key, myAes.IV); requestClass.AuthenticationEnvelope.Iv = ivAes.ByteArrayToHexString(); } } catch (Exception ex) { } }
public static string CreateJasonRequest(string terminalId, string acceptorId, long amount, string revertUri, string passPhrase, string requestId, string paymentId, string cmsPreservationId, string transactionType, BillInfo billInfo, List <MultiplexParameter> multiplexParameters) { RequestClass requestClass = new RequestClass(); requestClass.Request.CmsPreservationId = cmsPreservationId; requestClass.Request.AcceptorId = acceptorId; requestClass.Request.amount = amount; requestClass.Request.BillInfo = billInfo; requestClass.Request.multiplexParameters = multiplexParameters; requestClass.Request.PaymentId = paymentId; requestClass.Request.RequestId = requestId; requestClass.Request.RevertUri = revertUri; requestClass.Request.terminalId = terminalId; requestClass.Request.RequestTimestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; requestClass.Request.transactionType = transactionType; try { } catch (Exception ex) { } return(JsonConvert.SerializeObject(requestClass));; }