public HttpResponseMessage VaultTransaction(string guid) { HttpContent hc = Request.Content; Task<NameValueCollection> ReadTask = hc.ReadAsFormDataAsync(); NameValueCollection formData = ReadTask.Result; string amount = formData.Get("amount"); SEVD.Configuration config = new SEVD.Configuration(Credentials.MID, Credentials.MKEY, Credentials.APPID); Client sevdClient = new Client(config); Models.TransactionBase tb = new Models.TransactionBase(Models.TransactionBase.RequestType.Sale, false, amount); Models.Customer cust = new Models.Customer(); string response = sevdClient.Transaction.DoVaultTransaction(tb, guid, cust); Models.TransactionResult tr = new Models.TransactionResult(response); SEVD.API.Configuration.DataAccess.WriteToDataBase(tr); HttpResponseMessage resp = Request.CreateResponse(HttpStatusCode.Redirect); resp.Headers.Location = new Uri(Settings.ReturnPage); return resp; }
public void MapTQR_NormalTransaction_MapsAndMaskData() { const string lastFourDigit = "3333"; var mapper = new TransactionResultMapper(); var input = new Models.TransactionResult { Code = (PaymentStatusCode)1, BankId = string.Empty, PaymentId = string.Empty, TransactionDetails = new Models.Transaction { Amount = 1.0m, CardHolderName = string.Empty, CardNumber = $"0000-1111-2222-{lastFourDigit}", CurrencyISO4217Code = "EUR", CVVNumber = 123, ExperyDate = new DateTime(1, 1, 1) } }; var result = mapper.Map(input); Models.Transaction resultTransaction = result.TransactionDetails; Models.Transaction inputTransaction = input.TransactionDetails; Assert.AreEqual(result.Code, input.Code); Assert.AreEqual(result.PaymentId, input.PaymentId); Assert.AreEqual(resultTransaction.Amount, inputTransaction.Amount); Assert.AreEqual(resultTransaction.CardHolderName, inputTransaction.CardHolderName); Assert.AreEqual(resultTransaction.CurrencyISO4217Code, inputTransaction.CurrencyISO4217Code); Assert.IsTrue(resultTransaction.ExperyDate.CompareTo(inputTransaction.ExperyDate) == 0); Assert.IsNull(resultTransaction.CVVNumber); Assert.IsTrue(resultTransaction.CardNumber.StartsWith(TransactionResultMapper.CARD_MASK)); Assert.IsTrue(resultTransaction.CardNumber.EndsWith(lastFourDigit)); }