internal virtual void MapResponseValues(JsonDoc doc) { Token = doc.GetValue <string>("token"); Type = doc.GetValue <string>("type"); AppId = doc.GetValue <string>("app_id"); AppName = doc.GetValue <string>("app_name"); TimeCreated = doc.GetValue <DateTime>("time_created"); SecondsToExpire = doc.GetValue <int>("seconds_to_expire"); Email = doc.GetValue <string>("email"); if (doc.Has("scope")) { JsonDoc scope = doc.Get("scope"); MerchantId = scope.GetValue <string>("merchant_id"); MerchantName = scope.GetValue <string>("merchant_name"); if (scope.Has("accounts")) { var accounts = new List <GpApiAccount>(); foreach (JsonDoc account in scope.GetArray <JsonDoc>("accounts")) { accounts.Add(new GpApiAccount { Id = account.GetValue <string>("id"), Name = account.GetValue <string>("name"), }); } Accounts = accounts.ToArray(); } } }
public static DisputeDocument MapDisputeDocument(JsonDoc doc) { return(new DisputeDocument { Id = doc.GetValue <string>("id"), Base64Content = doc.GetValue <string>("b64_content"), }); }
private BankPaymentBuilder AddRemittanceRef(BankPaymentBuilder gatewayRequest, JsonDoc json) { var REF_TYPE = json.GetValue <string>("HPP_OB_REMITTANCE_REF_TYPE"); var REF_VALUE = json.GetValue <string>("HPP_OB_REMITTANCE_REF_VALUE"); return(gatewayRequest.WithRemittanceReference( (RemittanceReferenceType)Enum.Parse(typeof(RemittanceReferenceType), REF_TYPE), REF_VALUE )); }
protected void AddAssignment(JsonDoc assignment) { var server = assignment.GetValue <string>("server"); var tables = assignment.GetValue <string>("tables"); // do something with this data if (!string.IsNullOrEmpty(tables)) { var ids = tables.Split(',').Select(p => int.Parse(p)); Assignments.Add(server, ids); } }
internal virtual void MapResponseValues(JsonDoc doc) { TotalCount = doc.GetValue <int>("total_count"); MerchantId = doc.GetValue <string>("merchant_id"); MerchantName = doc.GetValue <string>("merchant_name"); AccountId = doc.GetValue <string>("account_id"); AccountName = doc.GetValue <string>("account_name"); if (!string.IsNullOrEmpty(ResultsField)) { RawResults = doc.GetEnumerator(ResultsField) as List <JsonDoc>; } }
public static StoredPaymentMethodSummary MapStoredPaymentMethodSummary(JsonDoc doc) { return(new StoredPaymentMethodSummary { Id = doc.GetValue <string>("id"), TimeCreated = doc.GetValue <DateTime>("time_created"), Status = doc.GetValue <string>("status"), Reference = doc.GetValue <string>("reference"), Name = doc.GetValue <string>("name"), CardLast4 = doc.Get("card")?.GetValue <string>("number_last4"), CardType = doc.Get("card")?.GetValue <string>("brand"), CardExpMonth = doc.Get("card")?.GetValue <string>("expiry_month"), CardExpYear = doc.Get("card")?.GetValue <string>("expiry_year"), }); }
internal virtual void MapResponseValues(JsonDoc doc) { TotalRecords = doc.GetValue <int>("TotalRecords"); RawResults = doc.GetEnumerator("Results") as List <JsonDoc>; Timestamp = doc.GetValue <DateTime?>("Timestamp", (input) => { if (input != null) { return(DateTime.Parse(input.ToString())); } return(null); }); StatusCode = doc.GetValue <int>("StatusCode"); ResponseMessage = doc.GetValue <string>("ResponseMessage"); }
protected override void MapResponse(JsonDoc response) { base.MapResponse(response); CheckId = response.GetValue <int>("checkID"); CheckInTime = response.GetValue <DateTime>("checkInTime", (value) => { if (value != null && !string.IsNullOrEmpty(value.ToString())) { return(DateTime.ParseExact(value.ToString(), "dd-MM-yyyy HH:mm", null)); } return(DateTime.Now); }); TableNumber = response.GetValue <int>("tableNumber"); WaitTime = response.GetValue <int>("waitTime"); }
private static BankPaymentType?GetBankPaymentType(JsonDoc response) { if (response.Has("payment_type")) { if (BankPaymentType.FASTERPAYMENTS.ToString().ToUpper().Equals(response.GetValue <string>("payment_type").ToUpper())) { return(BankPaymentType.FASTERPAYMENTS); } else if (BankPaymentType.SEPA.ToString().ToUpper().Equals(response.GetValue <string>("payment_type").ToUpper())) { return(BankPaymentType.SEPA); } } return(null); }
private static PaymentMethodUsageMode?GetPaymentMethodUsageMode(JsonDoc json) { if (json.Has("usage_mode")) { if (json.GetValue <string>("usage_mode").Equals(EnumConverter.GetMapping(Target.GP_API, PaymentMethodUsageMode.Single))) { return(PaymentMethodUsageMode.Single); } else if (json.GetValue <string>("usage_mode").Equals(EnumConverter.GetMapping(Target.GP_API, PaymentMethodUsageMode.Multiple))) { return(PaymentMethodUsageMode.Multiple); } } return(null); }
private static bool GetIsMultiCapture(JsonDoc json) { if (!string.IsNullOrEmpty(json.GetValue <string>("capture_mode"))) { switch (json.GetValue <string>("capture_mode")) { case "MULTIPLE": return(true); default: return(false); } } return(false); }
private static void SetPagingInfo <T>(PagedResult <T> result, JsonDoc json) where T : class { result.TotalRecordCount = json.GetValue <int>("total_record_count", "total_count"); result.PageSize = json.Get("paging")?.GetValue <int>("page_size") ?? default(int); result.Page = json.Get("paging")?.GetValue <int>("page") ?? default(int); result.Order = json.Get("paging")?.GetValue <string>("order"); result.OrderBy = json.Get("paging")?.GetValue <string>("order_by"); }
private static PayLinkStatus?GetPayLinkStatus(JsonDoc doc) { if (doc.Has("status")) { return((PayLinkStatus)Enum.Parse(typeof(PayLinkStatus), doc.GetValue <string>("status"))); } return(null); }
private static PayLinkType?GetPayLinkType(JsonDoc doc) { if (doc.Has("type")) { return((PayLinkType)Enum.Parse(typeof(PayLinkType), doc.GetValue <string>("type").ToUpper())); } return(null); }
private static bool?GetIsShippable(JsonDoc doc) { if (doc.Has("shippable")) { return(doc.GetValue <string>("shippable").ToUpper() == "TRUE" ? true : false); } return(null); }
public void MapResponseTest_BatchClose() { // Arrange string rawJson = "{\"id\":\"BAT_631762-460\",\"time_last_updated\":\"2021-04-23T18:54:52.467Z\",\"status\":\"CLOSED\",\"amount\":\"869\",\"currency\":\"USD\",\"country\":\"US\",\"transaction_count\":2,\"action\":{\"id\":\"ACT_QUuw7OPd9Rw8n72oaVOmVlQXpuhLUZ\",\"type\":\"CLOSE\",\"time_created\":\"2021-04-23T18:54:52.467Z\",\"result_code\":\"SUCCESS\",\"app_id\":\"P3LRVjtGRGxWQQJDE345mSkEh2KfdAyg\",\"app_name\":\"colleens_app\"}}"; // Act Transaction transaction = GpApiMapping.MapResponse(rawJson); // Assert Assert.IsNotNull(transaction?.BatchSummary); JsonDoc doc = JsonDoc.Parse(rawJson); Assert.AreEqual(doc.GetValue <string>("id"), transaction?.BatchSummary?.BatchReference); Assert.AreEqual(doc.GetValue <string>("status"), transaction?.BatchSummary?.Status); Assert.AreEqual(doc.GetValue <string>("amount").ToAmount(), transaction?.BatchSummary?.TotalAmount); Assert.AreEqual(doc.GetValue <int>("transaction_count"), transaction?.BatchSummary?.TransactionCount); }
public void MapResponseTest() { // Arrange string rawJson = "{\"id\":\"TRN_BHZ1whvNJnMvB6dPwf3znwWTsPjCn0\",\"time_created\":\"2020-12-04T12:46:05.235Z\",\"type\":\"SALE\",\"status\":\"PREAUTHORIZED\",\"channel\":\"CNP\",\"capture_mode\":\"LATER\",\"amount\":\"1400\",\"currency\":\"USD\",\"country\":\"US\",\"merchant_id\":\"MER_c4c0df11039c48a9b63701adeaa296c3\",\"merchant_name\":\"Sandbox_merchant_2\",\"account_id\":\"TRA_6716058969854a48b33347043ff8225f\",\"account_name\":\"Transaction_Processing\",\"reference\":\"15fbcdd9-8626-4e29-aae8-050f823f995f\",\"payment_method\":{\"result\":\"00\",\"message\":\"[ test system ] AUTHORISED\",\"entry_mode\":\"ECOM\",\"card\":{\"brand\":\"VISA\",\"masked_number_last4\":\"XXXXXXXXXXXX5262\",\"authcode\":\"12345\",\"brand_reference\":\"PSkAnccWLNMTcRmm\",\"brand_time_created\":\"\",\"cvv_result\":\"MATCHED\"}},\"batch_id\":\"\",\"action\":{\"id\":\"ACT_BHZ1whvNJnMvB6dPwf3znwWTsPjCn0\",\"type\":\"PREAUTHORIZE\",\"time_created\":\"2020-12-04T12:46:05.235Z\",\"result_code\":\"SUCCESS\",\"app_id\":\"Uyq6PzRbkorv2D4RQGlldEtunEeGNZll\",\"app_name\":\"sample_app_CERT\"}}"; // Act Transaction transaction = GpApiMapping.MapResponse(rawJson); JsonDoc doc = JsonDoc.Parse(rawJson); // Assert Assert.AreEqual(doc.GetValue <string>("id"), transaction.TransactionId); Assert.AreEqual(doc.GetValue <string>("amount").ToAmount(), transaction.BalanceAmount); Assert.AreEqual(doc.GetValue <string>("time_created"), transaction.Timestamp); Assert.AreEqual(doc.GetValue <string>("status"), transaction.ResponseMessage); Assert.AreEqual(doc.GetValue <string>("reference"), transaction.ReferenceNumber); Assert.AreEqual(doc.GetValue <string>("batch_id"), transaction.BatchSummary?.SequenceNumber); Assert.AreEqual(doc.Get("action").GetValue <string>("result_code"), transaction.ResponseCode); Assert.AreEqual(doc.GetValue <string>("id"), transaction.Token); if (doc.Has("payment_method")) { Assert.AreEqual(doc.Get("payment_method")?.GetValue <string>("result"), transaction.AuthorizationCode); Assert.AreEqual(doc.Get("payment_method")?.Get("card")?.GetValue <string>("brand"), transaction.CardType); Assert.AreEqual(doc.Get("payment_method")?.Get("card")?.GetValue <string>("masked_number_last4"), transaction.CardLast4); } if (doc.Has("card")) { Assert.AreEqual(doc.Get("card")?.GetValue <string>("number"), transaction.CardNumber); Assert.AreEqual(doc.Get("card")?.GetValue <string>("brand"), transaction.CardType); Assert.AreEqual(doc.Get("card")?.GetValue <int>("expiry_month"), transaction.CardExpMonth); Assert.AreEqual(doc.Get("card")?.GetValue <int>("expiry_year"), transaction.CardExpYear); } }
public static Transaction MapResponse(string rawResponse) { Transaction transaction = new Transaction(); if (!string.IsNullOrEmpty(rawResponse)) { JsonDoc json = JsonDoc.Parse(rawResponse); // ToDo: Map transaction values transaction.TransactionId = json.GetValue <string>("id"); transaction.BalanceAmount = json.GetValue <string>("amount").ToAmount(); transaction.Timestamp = json.GetValue <string>("time_created"); transaction.ResponseMessage = json.GetValue <string>("status"); transaction.ReferenceNumber = json.GetValue <string>("reference"); transaction.BatchSummary = new BatchSummary { SequenceNumber = json.GetValue <string>("batch_id") }; transaction.ResponseCode = json.Get("action").GetValue <string>("result_code"); transaction.Token = json.GetValue <string>("id"); if (json.Has("payment_method")) { JsonDoc paymentMethod = json.Get("payment_method"); transaction.AuthorizationCode = paymentMethod.GetValue <string>("result"); if (paymentMethod.Has("card")) { JsonDoc card = paymentMethod.Get("card"); transaction.CardType = card.GetValue <string>("brand"); transaction.CardLast4 = card.GetValue <string>("masked_number_last4"); transaction.CvnResponseMessage = card.GetValue <string>("cvv_result"); } } if (json.Has("card")) { JsonDoc card = json.Get("card"); transaction.CardNumber = card.GetValue <string>("number"); transaction.CardType = card.GetValue <string>("brand"); transaction.CardExpMonth = card.GetValue <int>("expiry_month"); transaction.CardExpYear = card.GetValue <int>("expiry_year"); } } return(transaction); }
public static DisputeSummary MapSettlementDisputeSummary(JsonDoc doc) { var summary = MapDisputeSummary(doc); summary.CaseIdTime = doc.GetValue <DateTime?>("stage_time_created", DateConverter); summary.DepositDate = doc.GetValue <DateTime?>("deposit_time_created", DateConverter); summary.DepositReference = doc.GetValue <string>("deposit_id"); summary.TransactionTime = doc.Get("transaction")?.GetValue <DateTime?>("time_created", DateConverter); summary.TransactionType = doc.Get("transaction")?.GetValue <string>("type"); summary.TransactionAmount = doc.Get("transaction")?.GetValue <string>("amount").ToAmount(); summary.TransactionCurrency = doc.Get("transaction")?.GetValue <string>("currency"); summary.TransactionReferenceNumber = doc.Get("transaction")?.GetValue <string>("reference"); summary.TransactionMaskedCardNumber = doc.Get("transaction")?.Get("payment_method")?.Get("card")?.GetValue <string>("masked_number_first6last4"); summary.TransactionARN = doc.Get("transaction")?.Get("payment_method")?.Get("card")?.GetValue <string>("arn"); summary.TransactionCardType = doc.Get("transaction")?.Get("payment_method")?.Get("card")?.GetValue <string>("brand"); summary.TransactionAuthCode = doc.Get("transaction")?.Get("payment_method")?.Get("card")?.GetValue <string>("authcode"); return(summary); }
private static TransactionSummary CreateTransactionSummary(JsonDoc doc) { var transaction = new TransactionSummary(); transaction.TransactionId = doc.GetValue <string>("id"); transaction.TransactionDate = doc.GetValue <DateTime?>("time_created", DateConverter); transaction.TransactionStatus = doc.GetValue <string>("status"); transaction.TransactionType = doc.GetValue <string>("type"); transaction.Channel = doc.GetValue <string>("channel"); transaction.Amount = doc.GetValue <string>("amount").ToAmount(); transaction.Currency = doc.GetValue <string>("currency"); transaction.ReferenceNumber = doc.GetValue <string>("reference"); transaction.ClientTransactionId = doc.GetValue <string>("reference"); return(transaction); }
public void MapResponseTest_CreateStoredPaymentMethod() { // Arrange string rawJson = "{\"id\":\"PMT_e150ba7c-bbbd-41fe-bc04-f21d18def2a1\",\"time_created\":\"2021-04-26T14:59:00.813Z\",\"status\":\"ACTIVE\",\"usage_mode\":\"MULTIPLE\",\"merchant_id\":\"MER_c4c0df11039c48a9b63701adeaa296c3\",\"merchant_name\":\"Sandbox_merchant_2\",\"account_id\":\"TKA_eba30a1b5c4a468d90ceeef2ffff7f5e\",\"account_name\":\"Tokenization\",\"reference\":\"9486a9e8-d8bd-4fd2-877c-796d07f3a2ce\",\"card\":{\"masked_number_last4\":\"XXXXXXXXXXXX1111\",\"brand\":\"VISA\",\"expiry_month\":\"12\",\"expiry_year\":\"25\"},\"action\":{\"id\":\"ACT_jFOurWcX9CvA8UKtEywVpxArNEryvZ\",\"type\":\"PAYMENT_METHOD_CREATE\",\"time_created\":\"2021-04-26T14:59:00.813Z\",\"result_code\":\"SUCCESS\",\"app_id\":\"P3LRVjtGRGxWQQJDE345mSkEh2KfdAyg\",\"app_name\":\"colleens_app\"}}"; // Act Transaction transaction = GpApiMapping.MapResponse(rawJson); // Assert JsonDoc doc = JsonDoc.Parse(rawJson); Assert.AreEqual(doc.GetValue <string>("id"), transaction.Token); Assert.AreEqual(doc.GetValue <string>("time_created"), transaction.Timestamp); Assert.AreEqual(doc.GetValue <string>("reference"), transaction.ReferenceNumber); Assert.AreEqual(doc.Get("card")?.GetValue <string>("brand"), transaction.CardType); Assert.AreEqual(doc.Get("card")?.GetValue <string>("number"), transaction.CardNumber); Assert.AreEqual(doc.Get("card")?.GetValue <string>("masked_number_last4"), transaction.CardLast4); Assert.AreEqual(doc.Get("card")?.GetValue <int>("expiry_month"), transaction.CardExpMonth); Assert.AreEqual(doc.Get("card")?.GetValue <int>("expiry_year"), transaction.CardExpYear); }
public static Transaction Map3DSecureData(string rawResponse) { if (!string.IsNullOrEmpty(rawResponse)) { JsonDoc json = JsonDoc.Parse(rawResponse); return(new Transaction { ThreeDSecure = new ThreeDSecure { ServerTransactionId = json.GetValue <string>("id"), Status = json.GetValue <string>("status"), Currency = json.GetValue <string>("currency"), Amount = json.GetValue <string>("amount").ToAmount(), Version = Parse3DSVersion(json.Get("three_ds")?.GetValue <string>("message_version")), MessageVersion = json.Get("three_ds")?.GetValue <string>("message_version"), DirectoryServerStartVersion = json.Get("three_ds")?.GetValue <string>("ds_protocol_version_start"), DirectoryServerEndVersion = json.Get("three_ds")?.GetValue <string>("ds_protocol_version_end"), DirectoryServerTransactionId = json.Get("three_ds")?.GetValue <string>("ds_trans_ref"), AcsStartVersion = json.Get("three_ds")?.GetValue <string>("acs_protocol_version_start"), AcsEndVersion = json.Get("three_ds")?.GetValue <string>("acs_protocol_version_end"), AcsTransactionId = json.Get("three_ds")?.GetValue <string>("acs_trans_ref"), Enrolled = json.Get("three_ds")?.GetValue <string>("enrolled_status"), Eci = json.Get("three_ds")?.GetValue <string>("eci")?.ToInt32(), AuthenticationValue = json.Get("three_ds")?.GetValue <string>("authentication_value"), ChallengeMandated = json.Get("three_ds")?.GetValue <string>("challenge_status") == "MANDATED", IssuerAcsUrl = !string.IsNullOrEmpty(json.Get("three_ds")?.GetValue <string>("method_url")) ? json.Get("three_ds")?.GetValue <string>("method_url") : json.Get("three_ds")?.GetValue <string>("acs_challenge_request_url"), ChallengeReturnUrl = json.Get("notifications")?.GetValue <string>("challenge_return_url"), SessionDataFieldName = json.Get("three_ds")?.GetValue <string>("session_data_field_name"), MessageType = json.Get("three_ds")?.GetValue <string>("message_type"), PayerAuthenticationRequest = (!string.IsNullOrEmpty(json.Get("three_ds")?.Get("method_data")?.GetValue <string>("encoded_method_data"))) ? json.Get("three_ds")?.Get("method_data")?.GetValue <string>("encoded_method_data") : json.Get("three_ds")?.GetValue <string>("challenge_value"), StatusReason = json.Get("three_ds")?.GetValue <string>("status_reason"), MessageCategory = json.Get("three_ds")?.GetValue <string>("message_category"), } }); } return(new Transaction()); }
public static TransactionSummary MapTransactionSummary(JsonDoc doc) { JsonDoc paymentMethod = doc.Get("payment_method"); JsonDoc card = paymentMethod?.Get("card"); var summary = new TransactionSummary { TransactionId = doc.GetValue <string>("id"), TransactionDate = doc.GetValue <DateTime?>("time_created", DateConverter), TransactionStatus = doc.GetValue <string>("status"), TransactionType = doc.GetValue <string>("type"), Channel = doc.GetValue <string>("channel"), Amount = doc.GetValue <string>("amount").ToAmount(), Currency = doc.GetValue <string>("currency"), ReferenceNumber = doc.GetValue <string>("reference"), ClientTransactionId = doc.GetValue <string>("reference"), TransactionLocalDate = doc.GetValue <DateTime?>("time_created_reference", DateConverter), BatchSequenceNumber = doc.GetValue <string>("batch_id"), Country = doc.GetValue <string>("country"), OriginalTransactionId = doc.GetValue <string>("parent_resource_id"), DepositReference = doc.GetValue <string>("deposit_id"), DepositDate = doc.GetValue <DateTime?>("deposit_time_created", DateConverter), GatewayResponseMessage = paymentMethod?.GetValue <string>("message"), EntryMode = paymentMethod?.GetValue <string>("entry_mode"), CardHolderName = paymentMethod?.GetValue <string>("name"), CardType = card?.GetValue <string>("brand"), AuthCode = card?.GetValue <string>("authcode"), BrandReference = card?.GetValue <string>("brand_reference"), AquirerReferenceNumber = card?.GetValue <string>("arn"), MaskedCardNumber = card?.GetValue <string>("masked_number_first6last4"), MerchantId = doc.Get("system")?.GetValue <string>("mid"), MerchantHierarchy = doc.Get("system")?.GetValue <string>("hierarchy"), MerchantName = doc.Get("system")?.GetValue <string>("name"), MerchantDbaName = doc.Get("system")?.GetValue <string>("dba"), }; return(summary); }
public void MapMapStoredPaymentMethodSummaryTest() { // Arrange string rawJson = "{\"id\":\"PMT_3502a05c-0a79-469b-bff9-994b665ce9d9\",\"time_created\":\"2021-04-23T18:46:57.000Z\",\"status\":\"ACTIVE\",\"merchant_id\":\"MER_c4c0df11039c48a9b63701adeaa296c3\",\"merchant_name\":\"Sandbox_merchant_2\",\"account_id\":\"TKA_eba30a1b5c4a468d90ceeef2ffff7f5e\",\"account_name\":\"Tokenization\",\"reference\":\"faed4ae3-1dd6-414a-bd7e-3a585715d9cc\",\"card\":{\"number_last4\":\"xxxxxxxxxxxx1111\",\"brand\":\"VISA\",\"expiry_month\":\"12\",\"expiry_year\":\"25\"},\"action\":{\"id\":\"ACT_wFGcHivudqleji9jA7S4MTapAHCTkp\",\"type\":\"PAYMENT_METHOD_SINGLE\",\"time_created\":\"2021-04-23T18:47:01.057Z\",\"result_code\":\"SUCCESS\",\"app_id\":\"P3LRVjtGRGxWQQJDE345mSkEh2KfdAyg\",\"app_name\":\"colleens_app\"}}"; JsonDoc doc = JsonDoc.Parse(rawJson); // Act StoredPaymentMethodSummary paymentMethod = GpApiMapping.MapStoredPaymentMethodSummary(doc); // Assert Assert.AreEqual(doc.GetValue <string>("id"), paymentMethod.Id); Assert.AreEqual(doc.GetValue <DateTime>("time_created"), paymentMethod.TimeCreated); Assert.AreEqual(doc.GetValue <string>("status"), paymentMethod.Status); Assert.AreEqual(doc.GetValue <string>("reference"), paymentMethod.Reference); Assert.AreEqual(doc.GetValue <string>("name"), paymentMethod.Name); Assert.AreEqual(doc.Get("card")?.GetValue <string>("number_last4"), paymentMethod.CardLast4); Assert.AreEqual(doc.Get("card")?.GetValue <string>("brand"), paymentMethod.CardType); Assert.AreEqual(doc.Get("card")?.GetValue <string>("expiry_month"), paymentMethod.CardExpMonth); Assert.AreEqual(doc.Get("card")?.GetValue <string>("expiry_year"), paymentMethod.CardExpYear); }
public static DepositSummary MapDepositSummary(JsonDoc doc) { var summary = new DepositSummary { DepositId = doc.GetValue <string>("id"), DepositDate = doc.GetValue <DateTime>("time_created"), Status = doc.GetValue <string>("status"), Type = doc.GetValue <string>("funding_type"), Amount = doc.GetValue <string>("amount").ToAmount(), Currency = doc.GetValue <string>("currency"), MerchantNumber = doc.Get("system")?.GetValue <string>("mid"), MerchantHierarchy = doc.Get("system")?.GetValue <string>("hierarchy"), MerchantName = doc.Get("system")?.GetValue <string>("name"), MerchantDbaName = doc.Get("system")?.GetValue <string>("dba"), SalesTotalCount = doc.Get("sales")?.GetValue <int>("count") ?? default(int), SalesTotalAmount = doc.Get("sales")?.GetValue <string>("amount").ToAmount(), RefundsTotalCount = doc.Get("refunds")?.GetValue <int>("count") ?? default(int), RefundsTotalAmount = doc.Get("refunds")?.GetValue <string>("amount").ToAmount(), ChargebackTotalCount = doc.Get("disputes")?.Get("chargebacks")?.GetValue <int>("count") ?? default(int), ChargebackTotalAmount = doc.Get("disputes")?.Get("chargebacks")?.GetValue <string>("amount").ToAmount(), AdjustmentTotalCount = doc.Get("disputes")?.Get("reversals")?.GetValue <int>("count") ?? default(int), AdjustmentTotalAmount = doc.Get("disputes")?.Get("reversals")?.GetValue <string>("amount").ToAmount(), FeesTotalAmount = doc.Get("fees")?.GetValue <string>("amount").ToAmount(), }; return(summary); }
public static Transaction MapResponse(string rawResponse) { Transaction transaction = new Transaction(); if (!string.IsNullOrEmpty(rawResponse)) { JsonDoc json = JsonDoc.Parse(rawResponse); transaction.TransactionId = json.GetValue <string>("ob_trans_id"); transaction.PaymentMethodType = PaymentMethodType.BankPayment; transaction.OrderId = json.Get("order")?.GetValue <string>("id"); transaction.ResponseMessage = json.GetValue <string>("status"); BankPaymentResponse obResponse = new BankPaymentResponse(); obResponse.RedirectUrl = json.GetValue <string>("redirect_url"); obResponse.PaymentStatus = json.GetValue <string>("status"); obResponse.Id = json.GetValue <string>("ob_trans_id"); transaction.BankPaymentResponse = obResponse; } return(transaction); }
public void MapDepositSummaryTest_NullDates() { // Arrange string rawJson = "{\"id\":\"DEP_2342423423\",\"time_created\":\"\",\"status\":\"FUNDED\",\"funding_type\":\"CREDIT\",\"amount\":\"11400\",\"currency\":\"USD\",\"aggregation_model\":\"H-By Date\",\"bank_transfer\":{\"masked_account_number_last4\":\"XXXXXX9999\",\"bank\":{\"code\":\"XXXXX0001\"}},\"system\":{\"mid\":\"101023947262\",\"hierarchy\":\"055-70-024-011-019\",\"name\":\"XYZ LTD.\",\"dba\":\"XYZ Group\"},\"sales\":{\"count\":4,\"amount\":\"12400\"},\"refunds\":{\"count\":1,\"amount\":\"-1000\"},\"discounts\":{\"count\":0,\"amount\":\"\"},\"tax\":{\"count\":0,\"amount\":\"\"},\"disputes\":{\"chargebacks\":{\"count\":0,\"amount\":\"\"},\"reversals\":{\"count\":0,\"amount\":\"\"}},\"fees\":{\"amount\":\"\"},\"action\":{\"id\":\"ACT_TWdmMMOBZ91iQX1DcvxYermuVJ6E6h\",\"type\":\"DEPOSIT_SINGLE\",\"time_created\":\"\",\"result_code\":\"SUCCESS\",\"app_id\":\"JF2GQpeCrOivkBGsTRiqkpkdKp67Gxi0\",\"app_name\":\"test_app\"}}"; JsonDoc doc = JsonDoc.Parse(rawJson); // Act DepositSummary deposit = GpApiMapping.MapDepositSummary(doc); // Assert Assert.AreEqual(doc.GetValue <string>("id"), deposit.DepositId); Assert.IsNull(deposit.DepositDate); Assert.AreEqual(doc.GetValue <string>("status"), deposit.Status); Assert.AreEqual(doc.GetValue <string>("funding_type"), deposit.Type); Assert.AreEqual(doc.GetValue <string>("amount").ToAmount(), deposit.Amount); Assert.AreEqual(doc.GetValue <string>("currency"), deposit.Currency); Assert.AreEqual(doc.Get("system")?.GetValue <string>("mid"), deposit.MerchantNumber); Assert.AreEqual(doc.Get("system")?.GetValue <string>("hierarchy"), deposit.MerchantHierarchy); Assert.AreEqual(doc.Get("system")?.GetValue <string>("name"), deposit.MerchantName); Assert.AreEqual(doc.Get("system")?.GetValue <string>("dba"), deposit.MerchantDbaName); Assert.AreEqual(doc.Get("sales")?.GetValue <int>("count") ?? default(int), deposit.SalesTotalCount); Assert.AreEqual(doc.Get("sales")?.GetValue <string>("amount").ToAmount(), deposit.SalesTotalAmount); Assert.AreEqual(doc.Get("refunds")?.GetValue <int>("count") ?? default(int), deposit.RefundsTotalCount); Assert.AreEqual(doc.Get("refunds")?.GetValue <string>("amount").ToAmount(), deposit.RefundsTotalAmount); Assert.AreEqual(doc.Get("disputes")?.Get("chargebacks")?.GetValue <int>("count") ?? default(int), deposit.ChargebackTotalCount); Assert.AreEqual(doc.Get("disputes")?.Get("chargebacks")?.GetValue <string>("amount").ToAmount(), deposit.ChargebackTotalAmount); Assert.AreEqual(doc.Get("disputes")?.Get("reversals")?.GetValue <int>("count") ?? default(int), deposit.AdjustmentTotalCount); Assert.AreEqual(doc.Get("disputes")?.Get("reversals")?.GetValue <string>("amount").ToAmount(), deposit.AdjustmentTotalAmount); Assert.AreEqual(doc.Get("fees")?.GetValue <string>("amount").ToAmount(), deposit.FeesTotalAmount); }
public static PayLinkResponse MapPayLinkResponse(JsonDoc doc) { var payLinkResponse = new PayLinkResponse(); payLinkResponse.Id = doc.GetValue <string>("id"); payLinkResponse.AccountName = doc.GetValue <string>("account_name"); payLinkResponse.Url = doc.GetValue <string>("url"); payLinkResponse.Status = GetPayLinkStatus(doc); payLinkResponse.Type = GetPayLinkType(doc); payLinkResponse.UsageMode = GetPaymentMethodUsageMode(doc); payLinkResponse.UsageLimit = doc.GetValue <int>("usage_limit"); payLinkResponse.Reference = doc.GetValue <string>("reference"); payLinkResponse.Name = doc.GetValue <string>("name"); payLinkResponse.Description = doc.GetValue <string>("description"); payLinkResponse.IsShippable = GetIsShippable(doc); payLinkResponse.ViewedCount = doc.GetValue <string>("viewed_count"); payLinkResponse.ExpirationDate = doc.GetValue <DateTime?>("expiration_date", DateConverter); return(payLinkResponse); }
public static TransactionSummary MapTransactionSummary(JsonDoc doc) { JsonDoc paymentMethod = doc.Get("payment_method"); JsonDoc card = paymentMethod?.Get("card"); var summary = new TransactionSummary { //ToDo: Map all transaction properties TransactionId = doc.GetValue <string>("id"), TransactionDate = doc.GetValue <DateTime>("time_created"), TransactionStatus = doc.GetValue <string>("status"), TransactionType = doc.GetValue <string>("type"), Channel = doc.GetValue <string>("channel"), Amount = doc.GetValue <string>("amount").ToAmount(), Currency = doc.GetValue <string>("currency"), ReferenceNumber = doc.GetValue <string>("reference"), ClientTransactionId = doc.GetValue <string>("reference"), // ?? = doc.GetValue<DateTime>("time_created_reference"), BatchSequenceNumber = doc.GetValue <string>("batch_id"), Country = doc.GetValue <string>("country"), // ?? = doc.GetValue<string>("action_create_id"), OriginalTransactionId = doc.GetValue <string>("parent_resource_id"), GatewayResponseMessage = paymentMethod?.GetValue <string>("message"), EntryMode = paymentMethod?.GetValue <string>("entry_mode"), CardHolderName = paymentMethod?.GetValue <string>("name"), CardType = card?.GetValue <string>("brand"), AuthCode = card?.GetValue <string>("authcode"), BrandReference = card?.GetValue <string>("brand_reference"), AquirerReferenceNumber = card?.GetValue <string>("arn"), MaskedCardNumber = card?.GetValue <string>("masked_number_first6last4"), }; return(summary); }
protected override void MapResponse(JsonDoc response) { base.MapResponse(response); // populate servers var serverList = response.GetValue <string>("serverList"); if (serverList != null) { Servers = new List <string>(); foreach (var server in serverList.Split(',')) { Servers.Add(server); } } }