public static QueryTransactionResponse Unmarshall(UnmarshallerContext context) { QueryTransactionResponse queryTransactionResponse = new QueryTransactionResponse(); queryTransactionResponse.HttpResponse = context.HttpResponse; queryTransactionResponse.RequestId = context.StringValue("QueryTransaction.RequestId"); QueryTransactionResponse.QueryTransaction_Result result = new QueryTransactionResponse.QueryTransaction_Result(); result.Hash = context.StringValue("QueryTransaction.Result.Hash"); result.BlockHeight = context.LongValue("QueryTransaction.Result.BlockHeight"); result.BlockVersion = context.IntegerValue("QueryTransaction.Result.BlockVersion"); result.CreateTime = context.LongValue("QueryTransaction.Result.CreateTime"); result.Category = context.IntegerValue("QueryTransaction.Result.Category"); result.Type = context.IntegerValue("QueryTransaction.Result.Type"); result.ReferenceCount = context.IntegerValue("QueryTransaction.Result.ReferenceCount"); result.Content = context.StringValue("QueryTransaction.Result.Content"); result.ContentHash = context.StringValue("QueryTransaction.Result.ContentHash"); result.KeyWrap = context.StringValue("QueryTransaction.Result.KeyWrap"); result.Nonce = context.StringValue("QueryTransaction.Result.Nonce"); result.KeyName = context.StringValue("QueryTransaction.Result.KeyName"); QueryTransactionResponse.QueryTransaction_Result.QueryTransaction_ReferenceList referenceList = new QueryTransactionResponse.QueryTransaction_Result.QueryTransaction_ReferenceList(); referenceList.Type = context.IntegerValue("QueryTransaction.Result.ReferenceList.Type"); referenceList.Length = context.IntegerValue("QueryTransaction.Result.ReferenceList.Length"); referenceList.Data = context.StringValue("QueryTransaction.Result.ReferenceList.Data"); result.ReferenceList = referenceList; queryTransactionResponse.Result = result; return(queryTransactionResponse); }
public ActionResult Ewayresponse(String AccessCode) { IRapidClient ewayClient = RapidClientFactory.NewRapidClient(apiKey, password, rapidEndpoint); QueryTransactionResponse response = ewayClient.QueryTransaction(AccessCode); string tokenid = response.Transaction.Customer.TokenCustomerID; //save the tokenid and response for the view ViewBag.token = tokenid; ViewBag.response = response; if ((bool)response.TransactionStatus.Status) { Console.WriteLine("Payment successful! ID: " + response.TransactionStatus.TransactionID); //Get organisation name to save in CssPaymentSetup QueryCustomerResponse customerresponse = ewayClient.QueryCustomer(long.Parse(tokenid)); string[] orgN = customerresponse.Customers.Select(c => c.CompanyName).ToArray(); string orgname = orgN[0]; int orgid; using (AimyEntities db = new AimyEntities()) { int[] orgids = db.Orgs.Where(o => o.Name == orgname).Select(o => o.Id).ToArray(); orgid = orgids[0]; } //Get the credit card details to save in CssPaymentSetup string[] cd = customerresponse.Customers.Select(cc => cc.CardDetails).Select(d => d.Number).ToArray(); string creditcard = cd[0]; using (AimyEntities db = new AimyEntities()) { CssPaymentSetup savetoken = new CssPaymentSetup(); savetoken.CustomerId = tokenid; savetoken.IsActive = true; savetoken.MaskedCardNumber = creditcard; savetoken.OrgId = orgid; savetoken.CreatedOn = DateTime.Today; //CreatedBy is the userid that can be retrieve from session current user -- for now we assign 3694 savetoken.CreatedBy = 3694; db.CssPaymentSetups.Add(savetoken); db.SaveChanges(); }; } else if (tokenid == null) { string[] errorCodes = response.TransactionStatus.ProcessingDetails.ResponseMessage.Split(new[] { ", " }, StringSplitOptions.None); foreach (string errorCode in errorCodes) { Console.WriteLine("Response Message: " + RapidClientFactory.UserDisplayMessage(errorCode, "EN")); } } return(View()); }