diff --git a/Transbank/PatpassRest/Common/Detail.cs b/Transbank/PatpassRest/Common/Detail.cs new file mode 100644 index 0000000..03458b6 --- /dev/null +++ b/Transbank/PatpassRest/Common/Detail.cs @@ -0,0 +1,53 @@ +using Newtonsoft.Json; + +namespace Transbank.Patpass.Common +{ + internal class Detail + { + [JsonProperty("service_id")] + internal string ServiceId { get; } + + [JsonProperty("card_holder_id")] + internal string CardHolderId { get; } + + [JsonProperty("card_holder_name")] + internal string CardHolderName { get; } + + [JsonProperty("card_holder_last_name1")] + internal string CardHolderLastName1 { get; } + + [JsonProperty("card_holder_last_name2")] + internal string CardHolderLastName2 { get; } + + [JsonProperty("card_holder_mail")] + internal string CardHolderMail { get; } + + [JsonProperty("cellphone_number")] + internal string CellphoneNumber { get; } + + [JsonProperty("expiration_date")] + internal string ExpirationDate { get; } + + [JsonProperty("commerce_mail")] + internal string CommerceMail { get; } + + [JsonProperty("uf_flag")] + internal bool UfFlag { get; } + + public Detail(string serviceId, string cardHolderId, string cardHolderName, + string cardHolderLastName1, string cardHolderLastName2, string cardHolderMail, + string cellphoneNumber, string expirationDate, string commerceMail, bool ufFlag) + { + ServiceId = serviceId; + CardHolderId = cardHolderId; + CardHolderName = cardHolderName; + CardHolderLastName1 = cardHolderLastName1; + CardHolderLastName2 = cardHolderLastName2; + CardHolderMail = cardHolderMail; + CellphoneNumber = cellphoneNumber; + ExpirationDate = expirationDate; + CommerceMail = commerceMail; + UfFlag = ufFlag; + } + } +} diff --git a/Transbank/PatpassRest/Common/PatpassByWebpayIntegrationType.cs b/Transbank/PatpassRest/Common/PatpassByWebpayIntegrationType.cs new file mode 100644 index 0000000..3dfa6db --- /dev/null +++ b/Transbank/PatpassRest/Common/PatpassByWebpayIntegrationType.cs @@ -0,0 +1,22 @@ +using System; +using Transbank.Common; + +namespace Transbank.Patpass.Common +{ + public class PatpassByWebpayIntegrationType : IIntegrationType + { + public string Key { get; private set; } + public string ApiBase { get; private set; } + + private PatpassByWebpayIntegrationType(string key, string apiBase) + { + Key = key; + ApiBase = apiBase; + } + + public static readonly PatpassByWebpayIntegrationType Live = + new PatpassByWebpayIntegrationType("LIVE", "https://webpay3g.transbank.cl"); + public static readonly PatpassByWebpayIntegrationType Test = + new PatpassByWebpayIntegrationType("TEST", "https://webpay3gint.transbank.cl"); + } +} diff --git a/Transbank/PatpassRest/Common/PatpassComercioIntegrationType.cs b/Transbank/PatpassRest/Common/PatpassComercioIntegrationType.cs new file mode 100644 index 0000000..34b8ba0 --- /dev/null +++ b/Transbank/PatpassRest/Common/PatpassComercioIntegrationType.cs @@ -0,0 +1,22 @@ +using System; +using Transbank.Common; + +namespace Transbank.Patpass.Common +{ + public class PatpassComercioIntegrationType : IIntegrationType + { + public string Key { get; private set; } + public string ApiBase { get; private set; } + + private PatpassComercioIntegrationType(string key, string apiBase) + { + Key = key; + ApiBase = apiBase; + } + + public static readonly PatpassComercioIntegrationType Live = + new PatpassComercioIntegrationType("LIVE", "https://www.pagoautomaticocontarjetas.cl/"); + public static readonly PatpassComercioIntegrationType Test = + new PatpassComercioIntegrationType("TEST", "https://pagoautomaticocontarjetasint.transbank.cl/"); + } +} diff --git a/Transbank/PatpassRest/PatpassByWebpay/Requests/CommitRequest.cs b/Transbank/PatpassRest/PatpassByWebpay/Requests/CommitRequest.cs new file mode 100644 index 0000000..18b1fad --- /dev/null +++ b/Transbank/PatpassRest/PatpassByWebpay/Requests/CommitRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Net.Http; +using Transbank.Common; + +namespace Transbank.Patpass.PatpassByWebpay.Requests +{ + internal class CommitRequest : BaseRequest + { + internal CommitRequest(string token) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}", HttpMethod.Put) {} + } +} diff --git a/Transbank/PatpassRest/PatpassByWebpay/Requests/CreateRequest.cs b/Transbank/PatpassRest/PatpassByWebpay/Requests/CreateRequest.cs new file mode 100644 index 0000000..a98c52f --- /dev/null +++ b/Transbank/PatpassRest/PatpassByWebpay/Requests/CreateRequest.cs @@ -0,0 +1,40 @@ +using Newtonsoft.Json; +using Transbank.Common; +using System.Net.Http; +using Transbank.Patpass.Common; + +namespace Transbank.Patpass.PatpassByWebpay.Requests +{ + internal class CreateRequest : BaseRequest + { + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("session_id")] + public string SessionId { get; set; } + + [JsonProperty("amount")] + public decimal Amount { get; set; } + + [JsonProperty("return_url")] + public string ReturnUrl { get; set; } + + [JsonProperty("wpm_detail")] + public Detail Details { get; set; } + + internal CreateRequest(string buyOrder, string sessionId, decimal amount, string returnUrl, string serviceId, string cardHolderId, + string cardHolderName, string cardHolderLastName1, string cardHolderLastName2, string cardHolderMail, string cellphoneNumber, + string expirationDate, string commerceMail, bool ufFlag) + : base("/rswebpaytransaction/api/webpay/v1.0/transactions", HttpMethod.Post) + { + BuyOrder = buyOrder; + SessionId = sessionId; + Amount = amount; + ReturnUrl = returnUrl; + Details = new Detail(serviceId, cardHolderId, cardHolderName, + cardHolderLastName1, cardHolderLastName2, cardHolderMail, + cellphoneNumber, expirationDate, commerceMail, ufFlag + ); + } + } +} diff --git a/Transbank/PatpassRest/PatpassByWebpay/Requests/StatusRequest.cs b/Transbank/PatpassRest/PatpassByWebpay/Requests/StatusRequest.cs new file mode 100644 index 0000000..bbe5c24 --- /dev/null +++ b/Transbank/PatpassRest/PatpassByWebpay/Requests/StatusRequest.cs @@ -0,0 +1,12 @@ +using System; +using Transbank.Common; +using System.Net.Http; + +namespace Transbank.Patpass.PatpassByWebpay.Requests +{ + public class StatusRequest : BaseRequest + { + internal StatusRequest(string token) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}", HttpMethod.Get) { } + } +} diff --git a/Transbank/PatpassRest/PatpassByWebpay/Responses/CommitResponse.cs b/Transbank/PatpassRest/PatpassByWebpay/Responses/CommitResponse.cs new file mode 100644 index 0000000..fdf8420 --- /dev/null +++ b/Transbank/PatpassRest/PatpassByWebpay/Responses/CommitResponse.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; +using Transbank.Webpay.Common; + +namespace Transbank.Patpass.PatpassByWebpay.Responses +{ + public class CommitResponse + { + [JsonProperty("vci")] + public string Vci { get; set; } + [JsonProperty("amount")] + public decimal Amount { get; set; } + [JsonProperty("status")] + public string Status { get; set; } + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + [JsonProperty("session_id")] + public string SessionId { get; set; } + [JsonProperty("card_detail")] + public CardDetail CardDetail { get; set; } + [JsonProperty("accounting_date")] + public string AccountingDate { get; set; } + [JsonProperty("transaction_date")] + public DateTime TransactionDate { get; set; } + [JsonProperty("authorization_code")] + public string AuthorizationCode { get; set; } + [JsonProperty("payment_type_code")] + public string PaymentTypeCode { get; set; } + [JsonProperty("response_code")] + public int ResponseCode { get; set; } + [JsonProperty("installments_amount")] + public int InstallmentsAmount { get; set; } + [JsonProperty("installments_number")] + public int InstallmentsNumber { get; set; } + [JsonProperty("balance")] + public decimal Balance { get; set; } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(", ", properties); + } + } +} diff --git a/Transbank/PatpassRest/PatpassByWebpay/Responses/CreateResponse.cs b/Transbank/PatpassRest/PatpassByWebpay/Responses/CreateResponse.cs new file mode 100644 index 0000000..a89a1eb --- /dev/null +++ b/Transbank/PatpassRest/PatpassByWebpay/Responses/CreateResponse.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Transbank.Patpass.PatpassByWebpay.Responses +{ + public class CreateResponse + { + [JsonProperty("token")] + public string Token { get; private set; } + + [JsonProperty("url")] + public string Url { get; private set; } + + public override string ToString() + { + return $"Token={Token}, Url={Url}"; + } + } +} diff --git a/Transbank/PatpassRest/PatpassByWebpay/Responses/StatusResponse.cs b/Transbank/PatpassRest/PatpassByWebpay/Responses/StatusResponse.cs new file mode 100644 index 0000000..9795b53 --- /dev/null +++ b/Transbank/PatpassRest/PatpassByWebpay/Responses/StatusResponse.cs @@ -0,0 +1,5 @@ +using System; +namespace Transbank.Patpass.PatpassByWebpay.Responses +{ + public class StatusResponse : CommitResponse { } +} diff --git a/Transbank/PatpassRest/PatpassByWebpay/Transaction.cs b/Transbank/PatpassRest/PatpassByWebpay/Transaction.cs new file mode 100644 index 0000000..f18fc7e --- /dev/null +++ b/Transbank/PatpassRest/PatpassByWebpay/Transaction.cs @@ -0,0 +1,116 @@ +using System; +using Newtonsoft.Json; +using Transbank.Common; +using Transbank.Exceptions; +using Transbank.Patpass.Common; +using Transbank.Patpass.PatpassByWebpay.Requests; +using Transbank.Patpass.PatpassByWebpay.Responses; +using RequestService = Transbank.Common.RequestService; + +namespace Transbank.Patpass.PatpassByWebpay +{ + public static class Transaction + { + private static string _commerceCode = "597055555550"; + private static string _apiKey = "579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C"; + private static PatpassByWebpayIntegrationType _integrationType = PatpassByWebpayIntegrationType.Test; + + private static string _commerceCodeHeaderName = "Tbk-Api-Key-Id"; + private static string _apiKeyHeaderName = "Tbk-Api-Key-Secret"; + + private static RequestServiceHeaders _headers = new RequestServiceHeaders(_apiKeyHeaderName, _commerceCodeHeaderName); + + public static RequestServiceHeaders Headers + { + get => _headers; + set => _headers = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + public static string CommerceCode + { + get => _commerceCode; + set => _commerceCode = value ?? throw new ArgumentNullException( + nameof(value), "Commerce code can't be null." + ); + } + + public static string ApiKey + { + get => _apiKey; + set => _apiKey = value ?? throw new ArgumentNullException( + nameof(value), "Api Key can't be null." + ); + } + + public static PatpassByWebpayIntegrationType IntegrationType + { + get => _integrationType; + set => _integrationType = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + + + + public static Options DefaultOptions() + { + return new Options(CommerceCode, ApiKey, IntegrationType, Headers); + } + + public static CreateResponse Create(string buyOrder, string sessionId, decimal amount, string returnUrl, string serviceId, string cardHolderId, + string cardHolderName, string cardHolderLastName1, string cardHolderLastName2, string cardHolderMail, string cellphoneNumber, + string expirationDate, string commerceMail, bool ufFlag) + { + return Create(buyOrder, sessionId, amount, returnUrl, serviceId, cardHolderId, + cardHolderName, cardHolderLastName1, cardHolderLastName2, cardHolderMail, cellphoneNumber, + expirationDate, commerceMail, ufFlag, DefaultOptions()); + } + + public static CreateResponse Create(string buyOrder, string sessionId, decimal amount, string returnUrl, string serviceId, string cardHolderId, + string cardHolderName, string cardHolderLastName1, string cardHolderLastName2, string cardHolderMail, string cellphoneNumber, + string expirationDate, string commerceMail, bool ufFlag, Options options) + { + var createRequest = new CreateRequest(buyOrder, sessionId, amount, returnUrl, serviceId, cardHolderId, + cardHolderName, cardHolderLastName1, cardHolderLastName2, cardHolderMail, cellphoneNumber, + expirationDate, commerceMail, ufFlag); + var response = RequestService.Perform(createRequest, options); + + return JsonConvert.DeserializeObject(response); + } + + public static CommitResponse Commit(string token) + { + return Commit(token, DefaultOptions()); + } + + public static CommitResponse Commit(string token, Options options) + { + return ExceptionHandler.Perform(() => + { + var commitRequest = new CommitRequest(token); + var response = RequestService.Perform( + commitRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static StatusResponse Status(string token) + { + return Status(token, DefaultOptions()); + } + + public static StatusResponse Status(string token, Options options) + { + return ExceptionHandler.Perform(() => + { + var statusRequest = new StatusRequest(token); + var response = RequestService.Perform( + statusRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + } +} diff --git a/Transbank/PatpassRest/PatpassComercio/Inscription.cs b/Transbank/PatpassRest/PatpassComercio/Inscription.cs new file mode 100644 index 0000000..163a47e --- /dev/null +++ b/Transbank/PatpassRest/PatpassComercio/Inscription.cs @@ -0,0 +1,163 @@ +using System; +using System.Dynamic; +using System.Globalization; +using System.Runtime.Remoting.Messaging; +using Newtonsoft.Json; +using Transbank.Common; +using Transbank.Exceptions; +using Transbank.Patpass.Common; +using Transbank.Patpass.PatpassComercio.Requests; +using Transbank.Patpass.PatpassComercio.Responses; + +namespace Transbank.Patpass.PatpassComercio +{ + public static class Inscription + { + private static string _commerceCode = "28299257"; + private static string _apiKey = "cxxXQgGD9vrVe4M41FIt"; + private static PatpassComercioIntegrationType _integrationType = PatpassComercioIntegrationType.Test; + private static string _apiKeyHeaderName = "Authorization"; + private static string _commerceCodeHeaderName = "commerceCode"; + + private static RequestServiceHeaders _headers = new RequestServiceHeaders(_apiKeyHeaderName, _commerceCodeHeaderName); + + public static string CommerceCode + { + get => _commerceCode; + set => _commerceCode = value ?? throw new ArgumentNullException( + nameof(value), "Commerce Code can't be null." + ); + } + + public static string ApiKey + { + get => _apiKey; + set => _apiKey = value ?? throw new ArgumentNullException( + nameof(value), "Api Key can't be null."); + } + + public static PatpassComercioIntegrationType IntegrationType + { + get => _integrationType; + set => _integrationType = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null"); + } + + public static RequestServiceHeaders Headers + { + get => _headers; + set => _headers = value ?? throw new ArgumentNullException( + nameof(value), " Headers can't be null"); + } + + public static Options DefaultOptions() + { + return new Options(CommerceCode, ApiKey, IntegrationType, Headers); + } + + public static StartResponse Start( + string url, + string name, + string fLastname, + string sLastname, + string rut, + string serviceId, + string finalUrl, + decimal maxAmount, + string phoneNumber, + string mobileNumber, + string patpassName, + string personEmail, + string commerceEmail, + string address, + string city + ) + { + return Start( + url, + name, + fLastname, + sLastname, + rut, + serviceId, + finalUrl, + maxAmount, + phoneNumber, + mobileNumber, + patpassName, + personEmail, + commerceEmail, + address, + city, + DefaultOptions() + ); + } + + public static StartResponse Start( + string url, + string name, + string fLastname, + string sLastname, + string rut, + string serviceId, + string finalUrl, + decimal maxAmount, + string phoneNumber, + string mobileNumber, + string patpassName, + string personEmail, + string commerceEmail, + string address, + string city, + Options options + ) + { + // set culture to es-CL, since webpay only works with clp we are forcing to anyone to use clp currency standard. + CultureInfo myCiIntl = new CultureInfo("es-CL", false); + string mAmount = maxAmount <= 0 ? "" : maxAmount.ToString(myCiIntl); + return ExceptionHandler.Perform(() => + { + var request = new StartRequest( + url, + name, + fLastname, + sLastname, + rut, + serviceId, + finalUrl, + options.CommerceCode, + mAmount, + phoneNumber, + mobileNumber, + patpassName, + personEmail, + commerceEmail, + address, + city + ); + var response = RequestService.Perform(request, options); + + return JsonConvert.DeserializeObject(response); + }); + + } + + public static StatusResponse Status(string token) + { + return Status(token, DefaultOptions()); + } + + public static StatusResponse Status(string token, Options options) + { + return ExceptionHandler.Perform(() => + { + var statusRequest = new StatusRequest(token); + var response = RequestService.Perform( + statusRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + } + +} diff --git a/Transbank/PatpassRest/PatpassComercio/Requests/StartRequest.cs b/Transbank/PatpassRest/PatpassComercio/Requests/StartRequest.cs new file mode 100644 index 0000000..a84e363 --- /dev/null +++ b/Transbank/PatpassRest/PatpassComercio/Requests/StartRequest.cs @@ -0,0 +1,95 @@ +using System; +using Newtonsoft.Json; +using Transbank.Common; +using System.Net.Http; + +namespace Transbank.Patpass.PatpassComercio.Requests +{ + internal class StartRequest : BaseRequest + { + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("nombre")] + public string Name { get; set; } + + [JsonProperty("pApellido")] + public string FLastname { get; set; } + + [JsonProperty("sApellido")] + public string SLastname { get; set; } + + [JsonProperty("rut")] + public string Rut { get; set; } + + [JsonProperty("serviceId")] + public string ServiceId { get; set; } + + [JsonProperty("finalUrl")] + public string FinalUrl { get; set; } + + [JsonProperty("commerceCode")] + public string CommerceCode { get; set; } + + [JsonProperty("montoMaximo")] + public string MaxAmount { get; set; } + + [JsonProperty("telefonoFijo")] + public string PhoneNumber { get; set; } + + [JsonProperty("telefonoCelular")] + public string MobileNumber { get; set; } + + [JsonProperty("nombrePatPass")] + public string PatpassName { get; set; } + + [JsonProperty("correoPersona")] + public string PersonEmail { get; set; } + + [JsonProperty("correoComercio")] + public string CommerceEmail { get; set; } + + [JsonProperty("direccion")] + public string Address { get; set; } + + [JsonProperty("ciudad")] + public string City { get; set; } + + internal StartRequest( + string url, + string name, + string fLastname, + string sLastname, + string rut, + string serviceId, + string finalUrl, + string commerceCode, + string maxAmount, + string phoneNumber, + string mobileNumber, + string patpassName, + string personEmail, + string commerceEmail, + string address, + string city + ) : base("restpatpass/v1/services/patInscription", HttpMethod.Post) + { + Url = url; + Name = name; + FLastname = fLastname; + SLastname = sLastname; + Rut = rut; + ServiceId = serviceId; + FinalUrl = finalUrl; + CommerceCode = commerceCode; + MaxAmount = maxAmount; + PhoneNumber = phoneNumber; + MobileNumber = mobileNumber; + PatpassName = patpassName; + PersonEmail = personEmail; + CommerceEmail = commerceEmail; + Address = address; + City = city; + } + } +} diff --git a/Transbank/PatpassRest/PatpassComercio/Requests/StatusRequest.cs b/Transbank/PatpassRest/PatpassComercio/Requests/StatusRequest.cs new file mode 100644 index 0000000..c7cbb2b --- /dev/null +++ b/Transbank/PatpassRest/PatpassComercio/Requests/StatusRequest.cs @@ -0,0 +1,22 @@ +using System.Net.Http; +using Transbank.Common; +using Newtonsoft.Json; + +namespace Transbank.Patpass.PatpassComercio.Requests +{ + internal class StatusRequest : BaseRequest + { + [JsonProperty("token")] + public string Token { get; set; } + + + internal StatusRequest( + string token + ) : base($"restpatpass/v1/services/status", + HttpMethod.Post) + { + Token = token; + } + + } +} diff --git a/Transbank/PatpassRest/PatpassComercio/Responses/StartResponse.cs b/Transbank/PatpassRest/PatpassComercio/Responses/StartResponse.cs new file mode 100644 index 0000000..e0c5aa8 --- /dev/null +++ b/Transbank/PatpassRest/PatpassComercio/Responses/StartResponse.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; + +namespace Transbank.Patpass.PatpassComercio.Responses +{ + public class StartResponse + { + [JsonProperty("token")] + public string Token { get; private set; } + + [JsonProperty("url")] + public string Url { get; private set; } + + public StartResponse(string token, string url) + { + Token = token; + Url = url; + } + + public override string ToString() + { + return $"Token={Token}, Url={Url}"; + } + + } +} diff --git a/Transbank/PatpassRest/PatpassComercio/Responses/StatusResponse.cs b/Transbank/PatpassRest/PatpassComercio/Responses/StatusResponse.cs new file mode 100644 index 0000000..97be3d3 --- /dev/null +++ b/Transbank/PatpassRest/PatpassComercio/Responses/StatusResponse.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; + +namespace Transbank.Patpass.PatpassComercio.Responses +{ + public class StatusResponse + { + [JsonProperty("status")] + public string Status { get; set; } + + [JsonProperty("urlVoucher")] + public string UrlVoucher { get; set; } + + public StatusResponse(string status, string urlVoucher) + { + Status = status; + UrlVoucher = urlVoucher; + } + + public override string ToString() + { + return $"status: {Status}\n" + + $"url voucher: {UrlVoucher}"; + } + } +} diff --git a/Transbank/Transbank.csproj b/Transbank/Transbank.csproj index a2b226c..92c1689 100644 --- a/Transbank/Transbank.csproj +++ b/Transbank/Transbank.csproj @@ -117,8 +117,12 @@ + + + + diff --git a/Transbank/WebpayRest/Common/CardDetail.cs b/Transbank/WebpayRest/Common/CardDetail.cs index 4c9537d..39ec8cd 100644 --- a/Transbank/WebpayRest/Common/CardDetail.cs +++ b/Transbank/WebpayRest/Common/CardDetail.cs @@ -10,7 +10,7 @@ public class CardDetail public override string ToString() { - return $"CardNumber={CardNumber}"; + return $"CardNumber={CardNumber}\n"; } } } diff --git a/Transbank/WebpayRest/Common/PaymentRequest.cs b/Transbank/WebpayRest/Common/PaymentRequest.cs index 7248a9e..14def41 100644 --- a/Transbank/WebpayRest/Common/PaymentRequest.cs +++ b/Transbank/WebpayRest/Common/PaymentRequest.cs @@ -29,7 +29,7 @@ public override string ToString() return $"Commerce Code= {CommerceCode}\n" + $"Buy Order= {BuyOrder}\n" + $"Amount= {Amount}\n" + - $"InstallmentsNumber= {InstallmentsNumber}"; + $"InstallmentsNumber= {InstallmentsNumber}\n"; } } } diff --git a/Transbank/WebpayRest/Common/PaymentResponse.cs b/Transbank/WebpayRest/Common/PaymentResponse.cs index 2bab04e..8e32d75 100644 --- a/Transbank/WebpayRest/Common/PaymentResponse.cs +++ b/Transbank/WebpayRest/Common/PaymentResponse.cs @@ -29,12 +29,12 @@ public class PaymentResponse public decimal Amount { get; private set; } public PaymentResponse (string commerceCode, string buyOrder, int amount, int authorizationCode, - string paymentTypeCode, int responseCode, int installmentsAmount, string status) + string paymentTypeCode, int responseCode, int installmentsNumber, string status) { AuthorizationCode = authorizationCode; PaymentTypeCode = paymentTypeCode; ResponseCode = responseCode; - InstallmentsNumber = installmentsAmount; + InstallmentsNumber = installmentsNumber; Status = status; CommerceCode = commerceCode; BuyOrder = buyOrder; @@ -43,8 +43,7 @@ public PaymentResponse (string commerceCode, string buyOrder, int amount, int au public override string ToString() { - return base.ToString() + "\n" + - $"InstallmentsAmount= {InstallmentsNumber}\n" + + return $"InstallmentsNumber= {InstallmentsNumber}\n" + $"AuthorizationCode= {AuthorizationCode}\n" + $"PaymentTypeCode= {PaymentTypeCode}\n" + $"ResponseCode= {ResponseCode}\n" + diff --git a/Transbank/WebpayRest/Common/TransactionDetail.cs b/Transbank/WebpayRest/Common/TransactionDetail.cs index 3f1f1d0..e90d541 100644 --- a/Transbank/WebpayRest/Common/TransactionDetail.cs +++ b/Transbank/WebpayRest/Common/TransactionDetail.cs @@ -20,5 +20,12 @@ public TransactionDetail(decimal amount, string commerceCode, string buyOrder) CommerceCode = commerceCode; BuyOrder = buyOrder; } + + public override string ToString() + { + return $"Amount= {Amount}\n" + + $"CommerceCode= {CommerceCode}\n" + + $"BuyOrder= {BuyOrder}\n"; + } } } diff --git a/Transbank/WebpayRest/Oneclick/Responses/FinishResponse.cs b/Transbank/WebpayRest/Oneclick/Responses/FinishResponse.cs index 2013cb6..55783ed 100644 --- a/Transbank/WebpayRest/Oneclick/Responses/FinishResponse.cs +++ b/Transbank/WebpayRest/Oneclick/Responses/FinishResponse.cs @@ -1,4 +1,5 @@ -using Transbank.Webpay.Common; +using System; +using Transbank.Webpay.Common; using Newtonsoft.Json; namespace Transbank.Webpay.Oneclick.Responses diff --git a/Transbank/WebpayRest/Oneclick/Responses/MallAuthorizeResponse.cs b/Transbank/WebpayRest/Oneclick/Responses/MallAuthorizeResponse.cs index 1b9ec34..eaea759 100644 --- a/Transbank/WebpayRest/Oneclick/Responses/MallAuthorizeResponse.cs +++ b/Transbank/WebpayRest/Oneclick/Responses/MallAuthorizeResponse.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; using Transbank.Webpay.Common; @@ -43,13 +43,15 @@ public MallAuthorizeResponse(string buyOrder, string sessionId, string cardNumbe public override string ToString() { + var details = ""; + Details.ForEach(i => details += "{\n"+ i.ToString() + "\n}\n"); return $"\"BuyOrder\": \"{BuyOrder}\"\n" + $"\"SessionId\": \"{SessionId}\"\n" + $"\"CardNumber\": \"{CardNumber}\"\n" + $"\"ExpirationDate\": \"{ExpirationDate}\"\n" + $"\"AccountingDate\": \"{AccountingDate}\"\n" + $"\"TransactionDate\": \"{TransactionDate}\"\n" + - $"\"Details\": \"{Details.ToString()}\""; + "\"Details\":\n{\n\t" + details + "\n}\n"; } } } diff --git a/Transbank/WebpayRest/Oneclick/Responses/MallStatusResponse.cs b/Transbank/WebpayRest/Oneclick/Responses/MallStatusResponse.cs index 5fb43b8..8b6b344 100644 --- a/Transbank/WebpayRest/Oneclick/Responses/MallStatusResponse.cs +++ b/Transbank/WebpayRest/Oneclick/Responses/MallStatusResponse.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.ComponentModel; using Newtonsoft.Json; using Transbank.Webpay.Common; @@ -31,12 +33,14 @@ public MallStatusResponse(string buyOrder, CardDetail cardDetail, string account public override string ToString() { + var details = ""; + Details.ForEach(i => details += "{\n"+ i.ToString() + "\n}\n"); return $"\"BuyOrder\": \"{BuyOrder}\"\n" + $"\"AccountingDate\": \"{AccountingDate}\"\n" + $"\"TransactionDate\": \"{TransactionDate}\"\n" + - $"\"Details\": \"{Details.ToString()}\""; + "\"Details\":\n{\n\t" + details + "\n}\n"; } - + public class Detail { [JsonProperty("amount")] @@ -75,6 +79,19 @@ public Detail(decimal amount, string status, string authorizationCode, string pa CommerceCode = commerceCode; BuyOrder = buyOrder; } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } } } \ No newline at end of file diff --git a/Transbank/WebpayRest/Oneclick/Responses/StartResponse.cs b/Transbank/WebpayRest/Oneclick/Responses/StartResponse.cs index 68c6710..bd30bfd 100644 --- a/Transbank/WebpayRest/Oneclick/Responses/StartResponse.cs +++ b/Transbank/WebpayRest/Oneclick/Responses/StartResponse.cs @@ -18,7 +18,8 @@ public StartResponse(string token, string url) public override string ToString() { - return $"\"Token\": \"{Token}\"\n\"Url\": \"{Url}\""; + return $"\"Token\": \"{Token}\"\n"+ + $"\"Url\": \"{Url}\"\n"; } } } diff --git a/Transbank/WebpayRest/TransaccionCompleta/Common/CardDetail.cs b/Transbank/WebpayRest/TransaccionCompleta/Common/CardDetail.cs index 65ea471..0d93d6a 100644 --- a/Transbank/WebpayRest/TransaccionCompleta/Common/CardDetail.cs +++ b/Transbank/WebpayRest/TransaccionCompleta/Common/CardDetail.cs @@ -14,7 +14,7 @@ public CardDetail(string cardNumber) public override string ToString() { - return $"CardNumber={CardNumber}"; + return $"CardNumber={CardNumber}\n"; } } } diff --git a/Transbank/WebpayRest/TransaccionCompleta/Common/DeferredPeriods.cs b/Transbank/WebpayRest/TransaccionCompleta/Common/DeferredPeriods.cs index e721d1f..47fd15f 100644 --- a/Transbank/WebpayRest/TransaccionCompleta/Common/DeferredPeriods.cs +++ b/Transbank/WebpayRest/TransaccionCompleta/Common/DeferredPeriods.cs @@ -19,7 +19,7 @@ public DeferredPeriods(int amount, int period) public override string ToString() { return $"Amount={Amount}\n" + - $"Period={Period}"; + $"Period={Period}\n"; } } } diff --git a/Transbank/WebpayRest/TransaccionCompleta/Common/Detail.cs b/Transbank/WebpayRest/TransaccionCompleta/Common/Detail.cs index 5a75b10..3c9b6bc 100644 --- a/Transbank/WebpayRest/TransaccionCompleta/Common/Detail.cs +++ b/Transbank/WebpayRest/TransaccionCompleta/Common/Detail.cs @@ -27,7 +27,7 @@ public override string ToString() { return $"Amount={Amount}\n" + $"CommerceCode={CommerceCode}\n" + - $"BuyOrder={BuyOrder}"; + $"BuyOrder={BuyOrder}\n"; } } } diff --git a/Transbank/WebpayRest/TransaccionCompleta/Responses/CommitResponse.cs b/Transbank/WebpayRest/TransaccionCompleta/Responses/CommitResponse.cs index 241ca7c..5ad4b58 100644 --- a/Transbank/WebpayRest/TransaccionCompleta/Responses/CommitResponse.cs +++ b/Transbank/WebpayRest/TransaccionCompleta/Responses/CommitResponse.cs @@ -62,7 +62,7 @@ public override string ToString() $"\"Status\":\"{Status}\"\n" + $"\"BuyOrder\":\"{BuyOrder}\"\n" + $"\"SessionId\":\"{SessionId}\"\n" + - $"\"CardDetail\":\"{CardDetail.ToString()}\"\n" + + "Card Detail=\n{\n" + CardDetail.ToString() + "}\n" + $"\"AccountingDate\":\"{AccountingDate}\"\n" + $"\"TransactionDate\":\"{TransactionDate}\"\n" + $"\"AuthorizationCode\":\"{AuthorizationCode}\"\n" + diff --git a/Transbank/WebpayRest/TransaccionCompleta/Responses/CreateResponse.cs b/Transbank/WebpayRest/TransaccionCompleta/Responses/CreateResponse.cs index c07dd8a..69464cb 100644 --- a/Transbank/WebpayRest/TransaccionCompleta/Responses/CreateResponse.cs +++ b/Transbank/WebpayRest/TransaccionCompleta/Responses/CreateResponse.cs @@ -14,7 +14,7 @@ public CreateResponse(string token) public override string ToString() { - return $"\"Token\":\"{Token}\""; + return $"Token:{Token}\n"; } } } diff --git a/Transbank/WebpayRest/TransaccionCompleta/Responses/InstallmentsResponse.cs b/Transbank/WebpayRest/TransaccionCompleta/Responses/InstallmentsResponse.cs index b804a1a..06d1a82 100644 --- a/Transbank/WebpayRest/TransaccionCompleta/Responses/InstallmentsResponse.cs +++ b/Transbank/WebpayRest/TransaccionCompleta/Responses/InstallmentsResponse.cs @@ -24,9 +24,12 @@ public InstallmentsResponse(int installmentsAmount, int idQueryInstallments, Lis public override string ToString() { + string deferred = ""; + DeferredPeriods.ForEach(i => deferred += "{\n" + i.ToString() + "}\n"); return $"\"InstallmentsAmount\":\"{InstallmentsAmount}\"\n" + $"\"IdQueryInstallments\":\"{IdQueryInstallments}\"\n" + - $"\"DeferredPeriods\":\"{DeferredPeriods.ToString()}\""; + "DeferredPeriods=\n{\n" + deferred + "}\n"; + } } } diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Common/CommitResponseDetails.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Common/CommitResponseDetails.cs new file mode 100644 index 0000000..5a401dd --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Common/CommitResponseDetails.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace Transbank.Webpay.TransaccionCompletaMall.Common +{ + public class CommitResponseDetails + { + [JsonProperty("amount")] + public int Amount { get; set; } + + [JsonProperty("status")] + public string Status { get; set; } + + [JsonProperty("authorization_code")] + public string AuthorizationCode { get; set; } + + [JsonProperty("payment_type_code")] + public string PaymentTypeCode { get; set; } + + [JsonProperty("response_code")] + public int ResponseCode { get; set; } + + [JsonProperty("installments_amount")] + public int InstallmentsAmount { get; set; } + + [JsonProperty("installments_number")] + public int InstallmentsNumber { get; set; } + + [JsonProperty("commerce_code")] + public string CommerceCode { get; set; } + + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + public CommitResponseDetails( + int amount, + string status, + string authorizationCode, + string paymentTypeCode, + int responseCode, + int installmentsAmount, + int installmentsNumber, + string commerceCode, + string buyOrder) + { + Amount = amount; + Status = status; + AuthorizationCode = authorizationCode; + PaymentTypeCode = paymentTypeCode; + ResponseCode = responseCode; + InstallmentsAmount = installmentsAmount; + InstallmentsNumber = installmentsNumber; + CommerceCode = commerceCode; + BuyOrder = buyOrder; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Common/CreateDetails.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Common/CreateDetails.cs new file mode 100644 index 0000000..cde3ea5 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Common/CreateDetails.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace Transbank.Webpay.TransaccionCompletaMall.Common +{ + public class CreateDetails + { + [JsonProperty("amount")] + public int Amount { get; } + + [JsonProperty("commerce_code")] + public string CommerceCode { get; } + + [JsonProperty("buy_order")] + public string BuyOrder { get; } + + public CreateDetails( + int amount, + string commerceCode, + string buyOrder) + { + Amount = amount; + CommerceCode = commerceCode; + BuyOrder = buyOrder; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Common/DeferredPeriods.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Common/DeferredPeriods.cs new file mode 100644 index 0000000..6677982 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Common/DeferredPeriods.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace Transbank.Webpay.TransaccionCompletaMall.Common +{ + public class DeferredPeriods + { + [JsonProperty("amount")] + internal int Amount { get; } + + [JsonProperty("period")] + internal int Period { get; } + + public DeferredPeriods(int amount, int period) + { + Amount= amount; + Period = period; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallCommitDetails.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallCommitDetails.cs new file mode 100644 index 0000000..46f3d7e --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallCommitDetails.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace Transbank.Webpay.TransaccionCompletaMall.Common +{ + public class MallCommitDetails + { + [JsonProperty("commerce_code")] + public string CommerceCode { get; set; } + + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("id_query_installments")] + public int IdQueryInstallments { get; set; } + + [JsonProperty("deferred_period_index")] + public int DeferredPeriodIndex { get; set; } + + [JsonProperty("grace_period")] + public bool GracePeriod { get; set; } + + public MallCommitDetails( + string commerceCode, + string buyOrder, + int idQueryInstallments, + int deferredPeriodIndex, + bool gracePeriod) + { + CommerceCode = commerceCode; + BuyOrder = buyOrder; + IdQueryInstallments = idQueryInstallments; + DeferredPeriodIndex = deferredPeriodIndex; + GracePeriod = gracePeriod; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallInstallmentsDetails.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallInstallmentsDetails.cs new file mode 100644 index 0000000..e71680f --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallInstallmentsDetails.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace Transbank.Webpay.TransaccionCompletaMall.Common +{ + public class MallInstallmentsDetails + { + [JsonProperty("commerce_code")] + public string CommerceCode { get; } + + [JsonProperty("buy_order")] + public string BuyOrder { get; } + + [JsonProperty("installments_number")] + public int InstallmentsNumber { get; } + + public MallInstallmentsDetails( + string commerceCode, + string buyOrder, + int installmentsNumber) + { + CommerceCode = commerceCode; + BuyOrder = buyOrder; + InstallmentsNumber = installmentsNumber; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallInstallmentsDetailsResponse.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallInstallmentsDetailsResponse.cs new file mode 100644 index 0000000..f662e9f --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Common/MallInstallmentsDetailsResponse.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using Transbank.Webpay.TransaccionCompletaMall.Responses; + +namespace Transbank.Webpay.TransaccionCompletaMall.Common +{ + public class MallInstallmentsDetailsResponse + { + [JsonProperty("details")] + public List Details { get; set; } + + public MallInstallmentsDetailsResponse( + List details + ) + { + Details = details; + } + + public override string ToString() + { + string details = ""; + Details.ForEach(i => details += "{\n" + i.ToString() + "\n}\n"); + return details; + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/MallFullTransaction.cs b/Transbank/WebpayRest/TransaccionCompletaMall/MallFullTransaction.cs new file mode 100644 index 0000000..e0f25c2 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/MallFullTransaction.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using Transbank.Common; +using Transbank.Exceptions; +using Transbank.Webpay.Common; +using Transbank.Webpay.TransaccionCompletaMall.Common; +using Transbank.Webpay.TransaccionCompletaMall.Requests; +using Transbank.Webpay.TransaccionCompletaMall.Responses; + +namespace Transbank.Webpay.TransaccionCompletaMall +{ + public class MallFullTransaction + { + private static string _commerceCode = ""; + private static string _apiKey = ""; + + private static WebpayIntegrationType _integrationType = WebpayIntegrationType.Test; + + private static string _commerceCodeHeaderName = "Tbk-Api-Key-Id"; + private static string _apiKeyHeaderName = "Tbk-Api-Key-Secret"; + + private static RequestServiceHeaders _headers = new RequestServiceHeaders(_apiKeyHeaderName, _commerceCodeHeaderName); + + public static RequestServiceHeaders Headers + { + get => _headers; + set => _headers = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + + public static string CommerceCode + { + get => _commerceCode; + set => _commerceCode = value ?? throw new ArgumentNullException( + nameof(value), "Commerce code can't be null." + ); + } + + public static string ApiKey + { + get => _apiKey; + set => _apiKey = value ?? throw new ArgumentNullException( + nameof(value), "Api Key can't be null." + ); + } + + public static WebpayIntegrationType IntegrationType + { + get => _integrationType; + set => _integrationType = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + + public static Options DefaultOptions() + { + return new Options(CommerceCode, ApiKey, IntegrationType, Headers); + } + + public static MallCreateResponse Create( + string buyOrder, + string sessionId, + string cardNumber, + string cardExpirationDate, + List details) + { + return Create(buyOrder, sessionId, cardNumber, cardExpirationDate, details); + } + + public static MallCreateResponse Create( + string buyOrder, + string sessionId, + string cardNumber, + string cardExpirationDate, + List details, + Options options) + { + return ExceptionHandler.Perform(() => + { + var mallCreateRequest = new MallCreateRequest( + buyOrder, + sessionId, + cardNumber, + cardExpirationDate, + details); + var response = RequestService.Perform(mallCreateRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static MallInstallmentsResponse Installments( + string token, + string commerceCode, + string buyOrder, + int installmentsAmount) + { + return Installments( + token, + commerceCode, + buyOrder, + installmentsAmount); + } + + public static MallInstallmentsResponse Installments( + string token, + string commerceCode, + string buyOrder, + int installmentsNumber, + Options options) + { + return ExceptionHandler.Perform(() => + { + var mallInstallmentsResponse = new MallInstallmentsRequest( + token, + commerceCode, + buyOrder, + installmentsNumber); + var response = RequestService.Perform(mallInstallmentsResponse, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static MallInstallmentsDetailsResponse Installments( + string token, + List details) + { + return Installments(token, details); + } + + public static MallInstallmentsDetailsResponse Installments( + string token, + List detailsGroup, + Options options) + { + return ExceptionHandler.Perform(() => + { + List details = new List(); + + foreach (MallInstallmentsDetails req in detailsGroup) + { + var request = new MallInstallmentsRequest( + token, + req.CommerceCode, + req.BuyOrder, + req.InstallmentsNumber); + + var response = RequestService.Perform(request, options); + var json = JsonConvert.DeserializeObject(response); + + details.Add(new MallInstallmentsResponse(json.InstallmentsAmount, json.IdQueryInstallments, json.DeferredPeriods)); + + } + + + + return JsonConvert.DeserializeObject(details.ToString()); + }); + } + + public static MallCommitResponse Commit( + string token, + List details) + { + return Commit( + token, + details); + } + + public static MallCommitResponse Commit( + string token, + List details, + Options options) + { + return ExceptionHandler.Perform(() => + { + var mallCommitRequest = new MallCommitRequest( + token, + details); + var response = RequestService.Perform(mallCommitRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static MallRefundResponse Refund( + string token, + string buyOrder, + string commerceCode, + int amount) + { + return Refund(token, buyOrder, commerceCode, amount); + } + + public static MallRefundResponse Refund( + string token, + string buyOrder, + string commerceCode, + int amount, + Options options) + { + return ExceptionHandler.Perform(() => + { + var mallRefundRequest = new MallRefundRequest( + token, + buyOrder, + commerceCode, + amount); + var response = RequestService.Perform(mallRefundRequest, options); + + return JsonConvert.DeserializeObject(response); + + }); + } + + public static MallStatusResponse Status( + string token) + { + return Status(token); + } + + public static MallStatusResponse Status( + string token, + Options options) + { + return ExceptionHandler.Perform(() => + { + var mallStatusRequest = new MallStatusRequest( + token); + var response = RequestService.Perform(mallStatusRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + } + } diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallCommitRequest.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallCommitRequest.cs new file mode 100644 index 0000000..0a800e2 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallCommitRequest.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using Transbank.Common; +using System.Net.Http; +using Transbank.Webpay.TransaccionCompletaMall.Common; + +namespace Transbank.Webpay.TransaccionCompletaMall.Requests +{ + internal class MallCommitRequest : BaseRequest + { + [JsonProperty("details")] + public List Details { get; set; } + + internal MallCommitRequest( + string token, + List details) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}", HttpMethod.Put) + { + Details = details; + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallCreateRequest.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallCreateRequest.cs new file mode 100644 index 0000000..1deca7d --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallCreateRequest.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Net.Http; +using Newtonsoft.Json; +using Transbank.Common; +using Transbank.Webpay.TransaccionCompletaMall.Common; + +namespace Transbank.Webpay.TransaccionCompletaMall.Requests +{ + internal class MallCreateRequest : BaseRequest + { + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("session_id")] + public string SessionId { get; set; } + + [JsonProperty("card_number")] + public string CardNumber { get; set; } + + [JsonProperty("card_expiration_date")] + public string CardExpirationDate { get; set; } + + [JsonProperty("details")] + public List Details { get; set; } + + internal MallCreateRequest(string buyOrder, + string sessionId, + string cardNumber, + string cardExpirationDate, + List details) + : base("/rswebpaytransaction/api/webpay/v1.0/transactions", HttpMethod.Post) + { + BuyOrder = buyOrder; + SessionId = sessionId; + CardNumber = cardNumber; + CardExpirationDate = cardExpirationDate; + Details = details; + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallInstallmentsRequest.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallInstallmentsRequest.cs new file mode 100644 index 0000000..d2dfad9 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallInstallmentsRequest.cs @@ -0,0 +1,31 @@ +using Newtonsoft.Json; +using Transbank.Common; +using System.Net.Http; +using Transbank.Webpay.TransaccionCompletaMall.Common; + +namespace Transbank.Webpay.TransaccionCompletaMall.Requests +{ + internal class MallInstallmentsRequest : BaseRequest + { + [JsonProperty("commerce_code")] + public string CommerceCode { get; set; } + + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("installments_number")] + public int InstallmentsNumber { get; set; } + + internal MallInstallmentsRequest( + string token, + string commerceCode, + string buyOrder, + int installmentsNumber) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}/installments", HttpMethod.Post) + { + CommerceCode = commerceCode; + BuyOrder = buyOrder; + InstallmentsNumber = installmentsNumber; + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallRefundRequest.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallRefundRequest.cs new file mode 100644 index 0000000..0ff7541 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallRefundRequest.cs @@ -0,0 +1,31 @@ +using Newtonsoft.Json; +using Transbank.Common; +using System.Net.Http; + +namespace Transbank.Webpay.TransaccionCompletaMall.Requests +{ + internal class MallRefundRequest : BaseRequest + { + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("commerce_code")] + public string CommerceCode { get; set; } + + [JsonProperty("amount")] + public int Amount { get; set; } + + internal MallRefundRequest( + string token, + string buyOrder, + string commerceCode, + int amount) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}/refunds", HttpMethod.Post) + { + BuyOrder = buyOrder; + CommerceCode = commerceCode; + Amount = amount; + } + + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallStatusRequest.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallStatusRequest.cs new file mode 100644 index 0000000..75fb69f --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Requests/MallStatusRequest.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; +using Transbank.Common; +using System.Net.Http; + +namespace Transbank.Webpay.TransaccionCompletaMall.Requests +{ + public class MallStatusRequest : BaseRequest + { + internal MallStatusRequest(string token) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}", HttpMethod.Get){} + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallCommitResponse.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallCommitResponse.cs new file mode 100644 index 0000000..ed25fa0 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallCommitResponse.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; +using Transbank.Patpass.Common; +using Transbank.Webpay.Common; +using Transbank.Webpay.TransaccionCompletaMall.Common; + +namespace Transbank.Webpay.TransaccionCompletaMall.Responses +{ + public class MallCommitResponse + { + [JsonProperty("details")] + public List Details { get; set; } + + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("session_id")] + public string SessionId { get; set; } + + [JsonProperty("card_detail")] + public CardDetail CardDetail { get; set; } + + [JsonProperty("accounting_date")] + public string AccountingDate { get; set; } + + [JsonProperty("transaction_date")] + public string TransactionDate { get; set; } + + public MallCommitResponse( + List details, + string buyOrder, + string sessionId, + CardDetail cardDetail, + string accountingDate, + string transactionDate + ) + { + Details = details; + BuyOrder = buyOrder; + SessionId = sessionId; + CardDetail = cardDetail; + AccountingDate = accountingDate; + TransactionDate = transactionDate; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallCreateResponse.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallCreateResponse.cs new file mode 100644 index 0000000..b54cba4 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallCreateResponse.cs @@ -0,0 +1,22 @@ +using Microsoft.Web.Services3.Addressing; +using Newtonsoft.Json; + +namespace Transbank.Webpay.TransaccionCompletaMall.Responses +{ + public class MallCreateResponse + { + [JsonProperty("token")] + public string Token { get; set; } + + public MallCreateResponse( + string token) + { + Token = token; + } + + public override string ToString() + { + return $"Token={Token}\n"; + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallInstallmentsResponse.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallInstallmentsResponse.cs new file mode 100644 index 0000000..d4178aa --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallInstallmentsResponse.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; +using Transbank.Webpay.TransaccionCompletaMall.Common; + +namespace Transbank.Webpay.TransaccionCompletaMall.Responses +{ + public class MallInstallmentsResponse + { + [JsonProperty("installments_amount")] + public int InstallmentsAmount { get; set; } + + [JsonProperty("id_query_installments")] + public int IdQueryInstallments { get; set; } + + [JsonProperty("deferred_periods")] + public List DeferredPeriods { get; set; } + + + public MallInstallmentsResponse(int installmentsAmount, int idQueryInstallments, List deferredPeriods) + { + InstallmentsAmount = installmentsAmount; + IdQueryInstallments = idQueryInstallments; + DeferredPeriods = deferredPeriods; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + + + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallRefundResponse.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallRefundResponse.cs new file mode 100644 index 0000000..b2cfe2b --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallRefundResponse.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace Transbank.Webpay.TransaccionCompletaMall.Responses +{ + public class MallRefundResponse + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("authorization_code")] + public string AuthorizationCode { get; set; } + + [JsonProperty("authorization_date")] + public string AuthorizationDate { get; set; } + + [JsonProperty("nullified_amount")] + public double NullifiedAmount { get; set; } + + [JsonProperty("balance")] + public double Balance { get; set; } + + [JsonProperty("response_code")] + public int ResponseCode { get; set; } + + public MallRefundResponse( + string type, + string authorizationCode, + string authorizationDate, + double nullifiedAmount, + double balance, + int responseCode) + { + Type = type; + AuthorizationCode = authorizationCode; + AuthorizationDate = authorizationDate; + NullifiedAmount = nullifiedAmount; + Balance = balance; + ResponseCode = responseCode; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } +} diff --git a/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallStatusResponse.cs b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallStatusResponse.cs new file mode 100644 index 0000000..76a35f5 --- /dev/null +++ b/Transbank/WebpayRest/TransaccionCompletaMall/Responses/MallStatusResponse.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; +using Transbank.Patpass.Common; +using Transbank.Webpay.Common; +using Transbank.Webpay.TransaccionCompletaMall.Common; + +namespace Transbank.Webpay.TransaccionCompletaMall.Responses +{ + public class MallStatusResponse + { + [JsonProperty("details")] + public List Details { get; set; } + + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("session_id")] + public string SessionId { get; set; } + + [JsonProperty("card_detail")] + public CardDetail CardDetail { get; set; } + + [JsonProperty("accounting_date")] + public string AccountingDate { get; set; } + + [JsonProperty("transaction_date")] + public string TransactionDate { get; set; } + + public MallStatusResponse( + List details, + string buyOrder, + string sessionId, + CardDetail cardDetail, + string accountingDate, + string transactionDate + ) + { + Details = details; + BuyOrder = buyOrder; + SessionId = sessionId; + CardDetail = cardDetail; + AccountingDate = accountingDate; + TransactionDate = transactionDate; + } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/DeferredTransaction.cs b/Transbank/WebpayRest/WebpayPlus/DeferredTransaction.cs new file mode 100644 index 0000000..253f5f5 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/DeferredTransaction.cs @@ -0,0 +1,114 @@ +using System; +using Newtonsoft.Json; +using Transbank.Common; +using Transbank.Webpay.Common; +using Transbank.Webpay.WebpayPlus.Exceptions; +using Transbank.Webpay.WebpayPlus.Requests; +using Transbank.Webpay.WebpayPlus.Responses; + +namespace Transbank.Webpay.WebpayPlus +{ + public static class DeferredTransaction + { + private static string _commerceCode = "597055555540"; + private static string _apiKey = "579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C"; + private static WebpayIntegrationType _integrationType = WebpayIntegrationType.Test; + + public static string CommerceCode + { + get => _commerceCode; + set => _commerceCode = value ?? throw new ArgumentNullException( + nameof(value), "Commerce code can't be null." + ); + } + + public static string ApiKey + { + get => _apiKey; + set => _apiKey = value ?? throw new ArgumentNullException( + nameof(value), "Api Key can't be null." + ); + } + + public static WebpayIntegrationType IntegrationType + { + get => _integrationType; + set => _integrationType = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + + public static Options DefaultOptions() + { + return new Options(CommerceCode, ApiKey, IntegrationType, null); + } + + public static CreateResponse Create(string buyOrder, string sessionId, + decimal amount, string returnUrl) + { + return Create(buyOrder, sessionId, amount, returnUrl, DefaultOptions()); + } + + public static CreateResponse Create(string buyOrder, string sessionId, + decimal amount, string returnUrl, Options options) + { + return Transaction.Create(buyOrder, sessionId, amount, returnUrl, options); + } + + public static CommitResponse Commit(string token) + { + return Commit(token, DefaultOptions()); + } + + public static CommitResponse Commit(string token, Options options) + { + return Transaction.Commit(token, options); + } + + public static RefundResponse Refund(string token, decimal amount) + { + return Refund(token, amount, DefaultOptions()); + } + + public static RefundResponse Refund(string token, decimal amount, Options options) + { + return Transaction.Refund(token, amount, options); + } + + public static StatusResponse Status(string token) + { + return Status(token, DefaultOptions()); + } + + public static StatusResponse Status(string token, Options options) + { + return Transaction.Status(token, options); + } + + public static CaptureResponse Capture(string token, string buyOrder, string authorizationCode, + decimal captureAmount, string commerceCode = null) + { + return Capture(token, buyOrder, authorizationCode, captureAmount, commerceCode, DefaultOptions()); + } + + public static CaptureResponse Capture(string token, string buyOrder, string authorizationCode, + decimal captureAmount) + { + return Capture(token, buyOrder, authorizationCode, captureAmount, null, DefaultOptions()); + } + + public static CaptureResponse Capture(string token, string buyOrder, string authorizationCode, + decimal captureAmount, string commerceCode, Options options) + { + return ExceptionHandler.Perform(() => + { + var captureRequest = new CaptureRequest(token, buyOrder, + authorizationCode, captureAmount, commerceCode); + var response = RequestService.Perform( + captureRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/MallDeferredTransaction.cs b/Transbank/WebpayRest/WebpayPlus/MallDeferredTransaction.cs new file mode 100644 index 0000000..597fa3b --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/MallDeferredTransaction.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using Transbank.Common; +using Transbank.Onepay.Exceptions; +using Transbank.Webpay.Common; +using Transbank.Webpay.WebpayPlus.Responses; +using Transbank.WebpayRest.WebpayPlus.Exceptions; +using Transbank.WebpayRest.WebpayPlus.Requests; +using Transbank.WebpayRest.WebpayPlus.Responses; + +namespace Transbank.Webpay.WebpayPlus +{ + public static class MallDeferredTransaction + { + private static string _commerceCode = "597055555544"; + private static string _apiKey = "579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C"; + private static WebpayIntegrationType _integrationType = WebpayIntegrationType.Test; + + private static string _commerceCodeHeaderName = "Tbk-Api-Key-Id"; + private static string _apiKeyHeaderName = "Tbk-Api-Key-Secret"; + + private static RequestServiceHeaders _headers = new RequestServiceHeaders(_apiKeyHeaderName, _commerceCodeHeaderName); + + public static RequestServiceHeaders Headers + { + get => _headers; + set => _headers = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + + public static string CommerceCode + { + get => _commerceCode; + set => _commerceCode = value ?? throw new ArgumentNullException( + nameof(value), "Commerce code can't be null." + ); + } + + public static string ApiKey + { + get => _apiKey; + set => _apiKey = value ?? throw new ArgumentNullException( + nameof(value), "Api Key can't be null." + ); + } + + public static WebpayIntegrationType IntegrationType + { + get => _integrationType; + set => _integrationType = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + + public static Options DefaultOptions() + { + return new Options(CommerceCode, ApiKey, IntegrationType, Headers); + } + + public static MallCreateResponse Create(string buyOrder, string sessionId, string returnUrl, + List transactions) + { + return Create(buyOrder, sessionId, returnUrl, transactions, DefaultOptions()); + } + + public static MallCreateResponse Create(string buyOrder, string sessionId, string returnUrl, + List transactions, Options options) + { + return MallTransaction.Create(buyOrder, sessionId, returnUrl, transactions, options); + } + + public static MallCommitResponse Commit(string token) + { + return Commit(token, DefaultOptions()); + } + + public static MallCommitResponse Commit(string token, Options options) + { + return MallTransaction.Commit(token, options); + } + + public static MallRefundResponse Refund(string token, string buyOrder, string commerceCode, decimal amount) + { + return Refund(token, buyOrder, commerceCode, amount, DefaultOptions()); + } + + public static MallRefundResponse Refund(string token, string buyOrder, string commerceCode, decimal amount, + Options options) + { + return MallTransaction.Refund(token, buyOrder, commerceCode, amount, options); + } + + public static MallStatusResponse Status(string token) + { + return Status(token, DefaultOptions()); + } + + public static MallStatusResponse Status(string token, Options options) + { + return MallTransaction.Status(token, options); + } + + public static MallCaptureResponse Capture(string token, string commerceCode, string buyOrder, + string authorizationCode, decimal amount) + { + return Capture(token, commerceCode, buyOrder, authorizationCode, amount, DefaultOptions()); + } + + public static MallCaptureResponse Capture(string token, string commerceCode, string buyOrder, + string authorizationCode, decimal amount, Options options) + { + return ExceptionHandler.Perform(() => + { + var mallCaptureRequest = new MallCaptureRequest(token, commerceCode, buyOrder, authorizationCode, amount); + var response = RequestService.Perform(mallCaptureRequest, options); + return JsonConvert.DeserializeObject(response); + }); + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/MallTransaction.cs b/Transbank/WebpayRest/WebpayPlus/MallTransaction.cs new file mode 100644 index 0000000..efc953f --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/MallTransaction.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using Transbank.Common; +using Transbank.Webpay.Common; +using Transbank.Webpay.WebpayPlus.Exceptions; +using Transbank.Webpay.WebpayPlus.Requests; +using Transbank.Webpay.WebpayPlus.Responses; + +namespace Transbank.Webpay.WebpayPlus +{ + public static class MallTransaction + { + private static string _commerceCode = "597055555535"; + private static string _apiKey = "579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C"; + private static WebpayIntegrationType _integrationType = WebpayIntegrationType.Test; + + private static string _commerceCodeHeaderName = "Tbk-Api-Key-Id"; + private static string _apiKeyHeaderName = "Tbk-Api-Key-Secret"; + + private static RequestServiceHeaders _headers = new RequestServiceHeaders(_apiKeyHeaderName, _commerceCodeHeaderName); + + public static RequestServiceHeaders Headers + { + get => _headers; + set => _headers = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + public static string CommerceCode + { + get => _commerceCode; + set => _commerceCode = value ?? throw new ArgumentNullException( + nameof(value), "Commerce code can't be null." + ); + } + + public static string ApiKey + { + get => _apiKey; + set => _apiKey = value ?? throw new ArgumentNullException( + nameof(value), "Api Key can't be null." + ); + } + + public static WebpayIntegrationType IntegrationType + { + get => _integrationType; + set => _integrationType = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + + public static Options DefaultOptions() + { + return new Options(CommerceCode, ApiKey, IntegrationType, Headers); + } + + public static MallCreateResponse Create(string buyOrder, string sessionId, + string returnUrl, List transactions) + { + return Create(buyOrder, sessionId, returnUrl, transactions, DefaultOptions()); + } + + public static MallCreateResponse Create(string buyOrder, string sessionId, + string returnUrl, List transactions, Options options) + { + return ExceptionHandler.Perform(() => + { + var mallCreateRequest = new MallCreateRequest(buyOrder, sessionId, + returnUrl, transactions); + var response = RequestService.Perform( + mallCreateRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static MallCommitResponse Commit(string token) + { + return Commit(token, DefaultOptions()); + } + + public static MallCommitResponse Commit(string token, Options options) + { + return ExceptionHandler.Perform(() => + { + var mallCommitRequest = new MallCommitRequest(token); + var response = RequestService.Perform( + mallCommitRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static MallRefundResponse Refund(string token, string buyOrder, + string commerceCode, decimal amount) + { + return Refund(token, buyOrder, commerceCode, amount, DefaultOptions()); + } + + public static MallRefundResponse Refund(string token, string buyOrder, + string commerceCode, decimal amount, Options options) + { + return ExceptionHandler.Perform(() => + { + var mallRefundRequest = new MallRefundRequest(token, buyOrder, + commerceCode, amount); + var response = RequestService.Perform( + mallRefundRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static MallStatusResponse Status(string token) + { + return Status(token, DefaultOptions()); + } + + public static MallStatusResponse Status(string token, Options options) + { + return ExceptionHandler.Perform(() => + { + var mallStatusRequest = new MallStatusRequest(token); + var response = RequestService.Perform( + mallStatusRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/CaptureRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/CaptureRequest.cs new file mode 100644 index 0000000..6fe8c39 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/CaptureRequest.cs @@ -0,0 +1,34 @@ +using System; +using System.Net.Http; +using Newtonsoft.Json; +using Transbank.Common; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + internal class CaptureRequest : BaseRequest + { + [JsonProperty("buy_order")] + internal string BuyOrder { get; set; } + + [JsonProperty("authorization_code")] + internal string AuthorizationCode { get; set; } + + [JsonProperty("capture_amount")] + internal decimal CaptureAmount { get; set; } + + [JsonProperty("commerce_code", NullValueHandling = NullValueHandling.Ignore)] + internal string CommerceCode { get; set; } + + internal CaptureRequest(string token, string buyOrder, string authorizationCode, + decimal captureAmount, string commerceCode = null) : + base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}/capture", HttpMethod.Put) + { + BuyOrder = buyOrder; + AuthorizationCode = authorizationCode; + CaptureAmount = captureAmount; + CommerceCode = commerceCode; + } + } +} + + diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/CommitRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/CommitRequest.cs new file mode 100644 index 0000000..bfc8720 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/CommitRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Net.Http; +using Transbank.Common; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + internal class CommitRequest : BaseRequest + { + internal CommitRequest(string token) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}", HttpMethod.Put) {} + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/CreateRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/CreateRequest.cs new file mode 100644 index 0000000..cf36f51 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/CreateRequest.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using Transbank.Common; +using System.Net.Http; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + internal class CreateRequest : BaseRequest + { + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("session_id")] + public string SessionId { get; set; } + + [JsonProperty("amount")] + public decimal Amount { get; set; } + + [JsonProperty("return_url")] + public string ReturnUrl { get; set; } + + public override string ToString() + { + return $"BuyOrder={BuyOrder}, SessionId={SessionId}, " + + $"Amount={Amount}, ReturnUrl={ReturnUrl}"; + } + + internal CreateRequest(string buyOrder, string sessionId, decimal amount, string returnUrl) + : base("/rswebpaytransaction/api/webpay/v1.0/transactions", HttpMethod.Post) + { + BuyOrder = buyOrder; + SessionId = sessionId; + Amount = amount; + ReturnUrl = returnUrl; + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/MallCaptureRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/MallCaptureRequest.cs new file mode 100644 index 0000000..a66a8b3 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/MallCaptureRequest.cs @@ -0,0 +1,37 @@ +using System.Net.Http; +using Newtonsoft.Json; +using Transbank.Common; + +namespace Transbank.WebpayRest.WebpayPlus.Requests +{ + public class MallCaptureRequest : BaseRequest + { + [JsonProperty("commerce_code")] + private string CommerceCode { get; set; } + + [JsonProperty("buy_order")] + private string BuyOrder { get; set; } + + [JsonProperty("authorization_code")] + private string AuthorizationCode { get; set; } + + [JsonProperty("capture_amount")] + private decimal CaptureAmount { get; set; } + + public MallCaptureRequest(string token, string commerceCode, string buyOrder, string authorizationCode, + decimal captureAmount) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}/capture", HttpMethod.Put) + { + CommerceCode = commerceCode; + BuyOrder = buyOrder; + AuthorizationCode = authorizationCode; + CaptureAmount = captureAmount; + } + + public override string ToString() + { + return + $"{nameof(CommerceCode)}: {CommerceCode}, {nameof(BuyOrder)}: {BuyOrder}, {nameof(AuthorizationCode)}: {AuthorizationCode}, {nameof(CaptureAmount)}: {CaptureAmount}"; + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/MallCommitRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/MallCommitRequest.cs new file mode 100644 index 0000000..e59f834 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/MallCommitRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Net.Http; +using Transbank.Common; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + public class MallCommitRequest : BaseRequest + { + public MallCommitRequest(string token) : + base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}", HttpMethod.Put) { } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/MallCreateRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/MallCreateRequest.cs new file mode 100644 index 0000000..fff1642 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/MallCreateRequest.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Net.Http; +using Newtonsoft.Json; +using Transbank.Common; +using Transbank.Webpay.Common; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + internal class MallCreateRequest : BaseRequest + { + [JsonProperty("buy_order")] + internal string BuyOrder { get; set; } + [JsonProperty("session_id")] + internal string SessionId { get; set; } + [JsonProperty("return_url")] + internal string ReturnUrl { get; set; } + [JsonProperty("details", ItemReferenceLoopHandling = ReferenceLoopHandling.Serialize)] + internal List Transactions { get; set; } + + internal MallCreateRequest(string buyOrder, string sessionId, string returnUrl, + List transactions) : base( + "/rswebpaytransaction/api/webpay/v1.0/transactions", HttpMethod.Post) + { + BuyOrder = buyOrder; + SessionId = sessionId; + ReturnUrl = returnUrl; + Transactions = transactions; + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/MallRefundRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/MallRefundRequest.cs new file mode 100644 index 0000000..7c6f823 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/MallRefundRequest.cs @@ -0,0 +1,27 @@ +using System; +using Newtonsoft.Json; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + internal class MallRefundRequest : RefundRequest + { + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + + [JsonProperty("commerce_code")] + public string CommerceCode { get; set; } + + internal MallRefundRequest( + string token, string buyOrder, string commerceCode, + decimal amount) : base(token, amount) + { + BuyOrder = buyOrder; + CommerceCode = commerceCode; + } + + public override string ToString() + { + return $"BuyOrder={BuyOrder}, CommerceCode={CommerceCode}, Amount={Amount}"; + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/MallStatusRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/MallStatusRequest.cs new file mode 100644 index 0000000..b88bb46 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/MallStatusRequest.cs @@ -0,0 +1,10 @@ +using System; +using Transbank.Webpay.Common; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + public class MallStatusRequest : StatusRequest + { + internal MallStatusRequest(string token) : base(token) { } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/RefundRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/RefundRequest.cs new file mode 100644 index 0000000..c5ee1d5 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/RefundRequest.cs @@ -0,0 +1,24 @@ +using System; +using Transbank.Common; +using Newtonsoft.Json; +using System.Net.Http; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + internal class RefundRequest : BaseRequest + { + [JsonProperty("amount")] + public decimal Amount { get; set; } + + public override string ToString() + { + return $"Amount={Amount}"; + } + + internal RefundRequest(string token, decimal amount) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}/refunds", HttpMethod.Post) + { + Amount = amount; + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Requests/StatusRequest.cs b/Transbank/WebpayRest/WebpayPlus/Requests/StatusRequest.cs new file mode 100644 index 0000000..501d66f --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Requests/StatusRequest.cs @@ -0,0 +1,12 @@ +using System; +using Transbank.Common; +using System.Net.Http; + +namespace Transbank.Webpay.WebpayPlus.Requests +{ + public class StatusRequest : BaseRequest + { + internal StatusRequest(string token) + : base($"/rswebpaytransaction/api/webpay/v1.0/transactions/{token}", HttpMethod.Get) { } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/CaptureResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/CaptureResponse.cs new file mode 100644 index 0000000..263fbec --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/CaptureResponse.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; +using Transbank.Webpay.Common; + +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class CaptureResponse + { + [JsonProperty("token")] + public string Token { get; set; } + [JsonProperty("authorization_code")] + public string AuthorizationCode { get; set; } + [JsonProperty("authorization_date")] + public DateTime AuthorizationDate { get; set; } + [JsonProperty("captured_amount")] + public decimal CapturedAmount { get; set; } + [JsonProperty("response_code")] + public int ResponseCode { get; set; } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/CommitResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/CommitResponse.cs new file mode 100644 index 0000000..5c5550c --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/CommitResponse.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; +using Transbank.Webpay.Common; + +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class CommitResponse + { + [JsonProperty("vci")] + public string Vci { get; set; } + [JsonProperty("amount")] + public decimal Amount { get; set; } + [JsonProperty("status")] + public string Status { get; set; } + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + [JsonProperty("session_id")] + public string SessionId { get; set; } + [JsonProperty("card_detail")] + public CardDetail CardDetail { get; set; } + [JsonProperty("accounting_date")] + public string AccountingDate { get; set; } + [JsonProperty("transaction_date")] + public DateTime TransactionDate { get; set; } + [JsonProperty("authorization_code")] + public string AuthorizationCode { get; set; } + [JsonProperty("payment_type_code")] + public string PaymentTypeCode { get; set; } + [JsonProperty("response_code")] + public int ResponseCode { get; set; } + [JsonProperty("installments_amount")] + public int InstallmentsAmount { get; set; } + [JsonProperty("installments_number")] + public int InstallmentsNumber { get; set; } + [JsonProperty("balance")] + public decimal Balance { get; set; } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/CreateResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/CreateResponse.cs new file mode 100644 index 0000000..0b653ca --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/CreateResponse.cs @@ -0,0 +1,18 @@ +using System; +using Newtonsoft.Json; + +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class CreateResponse + { + [JsonProperty("token")] + public string Token { get; private set; } + [JsonProperty("url")] + public string Url { get; private set; } + + public override string ToString() + { + return $"Token={Token},\nUrl={Url}\n"; + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/MallCaptureResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/MallCaptureResponse.cs new file mode 100644 index 0000000..7be562f --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/MallCaptureResponse.cs @@ -0,0 +1,8 @@ +using Transbank.Webpay.WebpayPlus.Responses; + +namespace Transbank.WebpayRest.WebpayPlus.Responses +{ + public class MallCaptureResponse : CaptureResponse + { + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/MallCommitResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/MallCommitResponse.cs new file mode 100644 index 0000000..d7ee21b --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/MallCommitResponse.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; +using Transbank.Webpay.Common; + +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class MallCommitResponse + { + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + [JsonProperty("session_id")] + public string SessionId { get; set; } + [JsonProperty("vci")] + public string Vci { get; set; } + [JsonProperty("card_detail")] + public CardDetail CardDetail { get; set; } + [JsonProperty("accounting_date")] + public string AccountingDate { get; set; } + [JsonProperty("transaction_date")] + public DateTime TransactionDate { get; set; } + [JsonProperty("details")] + public List Details { get; set; } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = null; + System.Diagnostics.Debug.WriteLine($"{name}={value}"); + if (name == "Details") + { + value = string.Join(", ", (List)descriptor.GetValue(this)); + value = $" {{{value}}} "; + } else + { + value = descriptor.GetValue(this); + } + properties.Add($"{name}={value}"); + } + return String.Join(", ", properties); + } + + public class Detail + { + [JsonProperty("buy_order")] + public string BuyOrder { get; set; } + [JsonProperty("commerce_code")] + public string CommerceCode { get; set; } + [JsonProperty("amount")] + public decimal Amount { get; set; } + [JsonProperty("status")] + public string Status { get; set; } + [JsonProperty("authorization_code")] + public string AuthorizationCode { get; set; } + [JsonProperty("payment_type_code")] + public string PaymentTypeCode { get; set; } + [JsonProperty("response_code")] + public int ResponseCode { get; set; } + [JsonProperty("installments_number")] + public int InstallmentsNumber { get; set; } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } + } + +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/MallCreateResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/MallCreateResponse.cs new file mode 100644 index 0000000..9e51d70 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/MallCreateResponse.cs @@ -0,0 +1,5 @@ +using System; +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class MallCreateResponse : CreateResponse {} +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/MallRefundResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/MallRefundResponse.cs new file mode 100644 index 0000000..7513620 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/MallRefundResponse.cs @@ -0,0 +1,9 @@ +using System; +using Newtonsoft.Json; + +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class MallRefundResponse : RefundResponse + { + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/MallStatusResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/MallStatusResponse.cs new file mode 100644 index 0000000..48f75e0 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/MallStatusResponse.cs @@ -0,0 +1,5 @@ +using System; +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class MallStatusResponse : MallCommitResponse { } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/RefundResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/RefundResponse.cs new file mode 100644 index 0000000..c1d63fa --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/RefundResponse.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class RefundResponse + { + [JsonProperty("type")] + public string Type { get; set; } + [JsonProperty("authorization_code")] + public string AuthorizationCode { get; set; } + [JsonProperty("authorization_date")] + public DateTime AuthorizationDate { get; set; } + [JsonProperty("nullified_amount")] + public decimal NullifiedAmount { get; set; } + [JsonProperty("balance")] + public decimal Balance { get; set; } + [JsonProperty("response_code")] + public int ResponseCode { get; set; } + + public override string ToString() + { + var properties = new List(); + foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(this)) + { + string name = descriptor.Name; + object value = descriptor.GetValue(this); + properties.Add($"{name}={value}"); + } + return String.Join(",\n", properties); + } + } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Responses/StatusResponse.cs b/Transbank/WebpayRest/WebpayPlus/Responses/StatusResponse.cs new file mode 100644 index 0000000..59b8958 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Responses/StatusResponse.cs @@ -0,0 +1,5 @@ +using System; +namespace Transbank.Webpay.WebpayPlus.Responses +{ + public class StatusResponse : CommitResponse { } +} diff --git a/Transbank/WebpayRest/WebpayPlus/Transaction.cs b/Transbank/WebpayRest/WebpayPlus/Transaction.cs new file mode 100644 index 0000000..0784550 --- /dev/null +++ b/Transbank/WebpayRest/WebpayPlus/Transaction.cs @@ -0,0 +1,129 @@ +using System; +using Transbank.Common; +using Transbank.Exceptions; +using Transbank.Webpay.WebpayPlus.Requests; +using Transbank.Webpay.Common; +using Transbank.Webpay.WebpayPlus.Responses; +using Newtonsoft.Json; +using Transbank.Webpay.WebpayPlus.Exceptions; + +namespace Transbank.Webpay.WebpayPlus +{ + public static class Transaction + { + private static string _commerceCode = "597055555532"; + private static string _apiKey = "579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C"; + private static WebpayIntegrationType _integrationType = WebpayIntegrationType.Test; + + private static string _commerceCodeHeaderName = "Tbk-Api-Key-Id"; + private static string _apiKeyHeaderName = "Tbk-Api-Key-Secret"; + + private static RequestServiceHeaders _headers = new RequestServiceHeaders(_apiKeyHeaderName, _commerceCodeHeaderName); + + public static RequestServiceHeaders Headers + { + get => _headers; + set => _headers = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + public static string CommerceCode + { + get => _commerceCode; + set => _commerceCode = value ?? throw new ArgumentNullException( + nameof(value), "Commerce code can't be null." + ); + } + + public static string ApiKey + { + get => _apiKey; + set => _apiKey = value ?? throw new ArgumentNullException( + nameof(value), "Api Key can't be null." + ); + } + + public static WebpayIntegrationType IntegrationType + { + get => _integrationType; + set => _integrationType = value ?? throw new ArgumentNullException( + nameof(value), "Integration type can't be null." + ); + } + + public static Options DefaultOptions() + { + return new Options(CommerceCode, ApiKey, IntegrationType, Headers); + } + + public static CreateResponse Create(string buyOrder, string sessionId, + decimal amount, string returnUrl) + { + return Create(buyOrder, sessionId, amount, returnUrl, DefaultOptions()); + } + + public static CreateResponse Create(string buyOrder, string sessionId, + decimal amount, string returnUrl, Options options) + { + return ExceptionHandler.Perform(() => + { + var createRequest = new CreateRequest(buyOrder, sessionId, amount, returnUrl); + var response = RequestService.Perform( + createRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static CommitResponse Commit(string token) + { + return Commit(token, DefaultOptions()); + } + + public static CommitResponse Commit(string token, Options options) + { + return ExceptionHandler.Perform(() => + { + var commitRequest = new CommitRequest(token); + var response = RequestService.Perform( + commitRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static RefundResponse Refund(string token, decimal amount) + { + return Refund(token, amount, DefaultOptions()); + } + + public static RefundResponse Refund(string token, decimal amount, Options options) + { + return ExceptionHandler.Perform(() => + { + var refundRequest = new RefundRequest(token, amount); + var response = RequestService.Perform( + refundRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + + public static StatusResponse Status(string token) + { + return Status(token, DefaultOptions()); + } + + public static StatusResponse Status(string token, Options options) + { + return ExceptionHandler.Perform(() => + { + var statusRequest = new StatusRequest(token); + var response = RequestService.Perform( + statusRequest, options); + + return JsonConvert.DeserializeObject(response); + }); + } + } +}