diff --git a/.vscode/launch.json b/.vscode/launch.json index 9169439..1a580a1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,24 @@ "type": "dotnet", "request": "launch", "projectPath": "${workspaceFolder}/samples/PaymentGateways/SipayIntegrationSampleConsoleApp/SipayIntegrationSampleConsoleApp.csproj" + }, + { + "name": "C#: Paynet Debug", + "type": "dotnet", + "request": "launch", + "projectPath": "${workspaceFolder}/samples/PaymentGateways/PaynetIntegrationSampleConsoleApp/PaynetIntegrationSampleConsoleApp.csproj" + }, + { + "name": "C#: Hepsiburada Debug", + "type": "dotnet", + "request": "launch", + "projectPath": "${workspaceFolder}/samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/HepsiburadaIntegrationSampleConsoleApp.csproj" + }, + { + "name": "C#: Trendyol Debug", + "type": "dotnet", + "request": "launch", + "projectPath": "${workspaceFolder}/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/TrendyolIntegrationSampleConsoleApp.csproj" } - ] } \ No newline at end of file diff --git a/samples/PaymentGateways/SipayIntegrationSampleConsoleApp/Program.cs b/samples/PaymentGateways/SipayIntegrationSampleConsoleApp/Program.cs index c6f2bf7..8b62270 100644 --- a/samples/PaymentGateways/SipayIntegrationSampleConsoleApp/Program.cs +++ b/samples/PaymentGateways/SipayIntegrationSampleConsoleApp/Program.cs @@ -9,11 +9,13 @@ isInProduction: false ); +await sipayPaymentIntegration.SetTokenAsync(); + // Get installments var installments = await sipayPaymentIntegration.CheckInstallmentsAsync(new CheckInstallmentRequestModel( - creaditCard: "123456", + creditCard: "450803", amount: 100, - currenyCode: "TRY" + currencyCode: "TRY" )); // Non secure payment diff --git a/src/Integration.Hub/ICardIntegration.cs b/src/Integration.Hub/ICardIntegration.cs new file mode 100644 index 0000000..cc28158 --- /dev/null +++ b/src/Integration.Hub/ICardIntegration.cs @@ -0,0 +1,6 @@ +namespace Integration.Hub; + +public interface ICardIntegration +{ + +} \ No newline at end of file diff --git a/src/Integration.Hub/IntegrationBase.cs b/src/Integration.Hub/IntegrationBase.cs index 23d37be..fb81986 100644 --- a/src/Integration.Hub/IntegrationBase.cs +++ b/src/Integration.Hub/IntegrationBase.cs @@ -14,17 +14,22 @@ static IntegrationBase() protected void InitializeDefaultHeaders(Dictionary headers) { - // Add default headers to the request foreach (var header in headers) _httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); } + protected void SetHeader(KeyValuePair header) + { + _httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); + } + protected void SetSerializerOptions(JsonSerializerOptions options) { _options = options; } - public async Task InvokeRequestAsync(Func> httpRequest) where TResponse : IResponseModel + public async Task InvokeRequestAsync(Func> httpRequest) + where TResponse : IResponseModel { var response = await httpRequest.Invoke(_httpClient); var responseAsString = await response.Content.ReadAsStringAsync(); @@ -46,9 +51,11 @@ public async Task InvokeRequestAsync(Func InvokeRequestAsync(Func> httpRequest, IRequestModel requestModel) where TResponse : IResponseModel + public async Task InvokeRequestAsync(Func> httpRequest, TRequest requestModel) + where TResponse : IResponseModel + where TRequest : IRequestModel { - var jsonData = JsonSerializer.Serialize(requestModel); + var jsonData = JsonSerializer.Serialize(requestModel, _options); var requestBody = new StringContent(jsonData, Encoding.UTF8, "application/json"); var response = await httpRequest.Invoke(_httpClient, requestBody); @@ -59,9 +66,10 @@ public async Task InvokeRequestAsync(Func(responseAsString, _options)!; } - public async Task InvokeRequestAsync(Func> httpRequest, IRequestModel requestModel) + public async Task InvokeRequestAsync(Func> httpRequest, TRequest requestModel) + where TRequest : IRequestModel { - var jsonData = JsonSerializer.Serialize(requestModel); + var jsonData = JsonSerializer.Serialize(requestModel, _options); var requestBody = new StringContent(jsonData, Encoding.UTF8, "application/json"); var response = await httpRequest.Invoke(_httpClient, requestBody); diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Constants/ProductStatus.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Constants/ProductStatus.cs new file mode 100644 index 0000000..371eeb7 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Constants/ProductStatus.cs @@ -0,0 +1,13 @@ +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Constants; +public enum ProductStatus +{ + WAITING, + IN_EXTRENAL_PROGESS, + PRE_MATCHED, + MATCHED, + REJECTED, + MATCHED_WITH_STAGED, + MISSING_INFO, + CREATED, + BLOCKED +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/HepsiburadaProductIntegration.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/HepsiburadaProductIntegration.cs index 7d8ca54..8c6e535 100644 --- a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/HepsiburadaProductIntegration.cs +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/HepsiburadaProductIntegration.cs @@ -1,4 +1,6 @@ +using System.Text.Json; using Integration.Hub; +using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Request; using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; using Integration.Marketplaces.Trendyol.Infrastructure; @@ -9,6 +11,16 @@ public class HepsiburadaProductIntegration : HepsiburadaIntegrationBase, IHepsib private string GetCategoriesUrl() => $"{GetBaseUrl()}product/api/categories/get-all-categories"; private string GetCategoryAttributesUrl(int categoryId) => $"{GetBaseUrl()}product/api/categories/{categoryId}/attributes"; private string GetCategoryAttributeValueUrl(int categoryId, string attributeId) => $"{GetBaseUrl()}product/api/categories/{categoryId}/attribute/{attributeId}/v"; + private string GetRejectPrematchUrl() => $"{GetBaseUrl()}product/api/products/reject-prematch"; + private string GetCreateProductUrl() => $"{GetBaseUrl()}product/api/products/import"; + private string GetFastListingUrl() => $"{GetBaseUrl()}product/api/products/fastlisting"; + private string GetCheckProductStatusUrl() => $"{GetBaseUrl()}product/api/products/check-product-status"; + private string GetApprovePrematchUrl() => $"{GetBaseUrl()}product/api/products/approve-prematch"; + private string GetTrackingIdHistoryUrl() => $"{GetBaseUrl()}product/api/products/trackingId-history"; + private string GetCheckProductStatusByTrackingIdUrl(string trackingId) => $"{GetBaseUrl()}product/api/products/status/{trackingId}"; + private string GetProductsByStatusUrl(string merchantId, string productStatus) => $"{GetBaseUrl()}product/api/products/products-by-merchant-and-status?merchantId={merchantId}&productStatus={productStatus}"; + private string GetCheckDeleteProductProcessUrl(string trackingId) => $"{GetBaseUrl()}product/api/products/delete-process/{trackingId}"; + private string GetMerchatProductsUrl(string merchantId) => $"{GetBaseUrl()}product/api/products/all-products-of-merchant/{merchantId}"; public HepsiburadaProductIntegration(string username, string password, bool isInProduction = true) : base(username, password, isInProduction) { @@ -18,9 +30,9 @@ public HepsiburadaProductIntegration(string username, string password, bool isIn /// /// /// - public async Task GetCategoriesAsync() + public async Task>> GetCategoriesAsync() { - return await InvokeRequestAsync((client) => client.GetAsync(GetCategoriesUrl())); + return await InvokeRequestAsync>>((client) => client.GetAsync(GetCategoriesUrl())); } /// @@ -28,9 +40,9 @@ public async Task GetCategoriesAsync() /// /// /// - public async Task GetCategoryAttributesAsync(int categoryId) + public async Task>> GetCategoryAttributesAsync(int categoryId) { - return await InvokeRequestAsync((client) => client.GetAsync(GetCategoryAttributesUrl(categoryId))); + return await InvokeRequestAsync>>((client) => client.GetAsync(GetCategoryAttributesUrl(categoryId))); } /// @@ -39,8 +51,110 @@ public async Task GetCategoryAttributesAsync /// /// /// - public async Task GetCategoryAttributeValuesAsync(int categoryId, string attributeId) + public async Task>> GetCategoryAttributeValuesAsync(int categoryId, string attributeId) { - return await InvokeRequestAsync((client) => client.GetAsync(GetCategoryAttributeValueUrl(categoryId, attributeId))); + return await InvokeRequestAsync>>((client) => client.GetAsync(GetCategoryAttributeValueUrl(categoryId, attributeId))); + } + + /// + /// + /// + /// + /// + public async Task> GetCategoryAttributeValuesAsync(RejectPrematchRequestModel rejectPrematchRequestModel) + { + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetRejectPrematchUrl(), requestBody), rejectPrematchRequestModel); + } + + /// + /// + /// + /// + /// + public async Task> CreateProductsAsync(BulkModel createProductRequestModels) + { + var requestString = JsonSerializer.Serialize(createProductRequestModels); + //Todo copy request string to json file + return await InvokeRequestAsync, HepsiburadaBaseResponseModel>((client, requestBody) => client.PostAsync(GetCreateProductUrl(), requestBody), createProductRequestModels); + } + + /// + /// + /// + /// + /// + public async Task>> FastListingAsync(BulkModel fastListingRequestModels) + { + return await InvokeRequestAsync, HepsiburadaBaseResponseModel>>((client, requestBody) => client.PostAsync(GetFastListingUrl(), requestBody), fastListingRequestModels); + } + + /// + /// + /// + /// + /// + public async Task> CheckProductStatusAsync(BulkModel checkProductStatusRequestModels) + { + return await InvokeRequestAsync, HepsiburadaBaseResponseModel>((client, requestBody) => client.PostAsync(GetCheckProductStatusUrl(), requestBody), checkProductStatusRequestModels); + } + + /// + /// + /// + /// + /// + public async Task> ApprovePrematchAsync(BulkModel approvePrematchRequestModels) + { + return await InvokeRequestAsync, HepsiburadaBaseResponseModel>((client, requestBody) => client.PostAsync(GetApprovePrematchUrl(), requestBody), approvePrematchRequestModels); + } + + /// + /// + /// + /// + public async Task>> GetTrackingIdHistoryAsync() + { + return await InvokeRequestAsync>>((client) => client.GetAsync(GetTrackingIdHistoryUrl())); + } + + /// + /// + /// + /// + /// + public async Task> GetProductStatusByTrackingIdAsync(string trackingId) + { + return await InvokeRequestAsync>((client) => client.GetAsync(GetCheckProductStatusByTrackingIdUrl(trackingId))); + } + + /// + /// + /// + /// + /// + /// + public async Task>> GetProductsByStatusAsync(string merchantId, string productStatus) + { + return await InvokeRequestAsync>>((client) => client.GetAsync(GetProductsByStatusUrl(merchantId, productStatus))); + } + + /// + /// + /// + /// + /// + public async Task> CheckDeleteProductProcessAsync(string trackingId) + { + return await InvokeRequestAsync>((client) => client.GetAsync(GetCheckDeleteProductProcessUrl(trackingId))); + } + + /// + /// + /// + /// + /// + public async Task>> GetMerchantProductsAsync(string merchantId) + { + return await InvokeRequestAsync>>((client) => client.GetAsync(GetMerchatProductsUrl(merchantId))); } } \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/IHepsiburadaProductIntegration.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/IHepsiburadaProductIntegration.cs index cda0432..e3c258b 100644 --- a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/IHepsiburadaProductIntegration.cs +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/IHepsiburadaProductIntegration.cs @@ -1,3 +1,5 @@ +using Integration.Hub; +using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Request; using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration; @@ -7,14 +9,14 @@ public interface IHepsiburadaProductIntegration /// Bu metod ile Hepsiburada kategorileri bilgilerini alabilirsiniz. /// /// - public Task GetCategoriesAsync(); + public Task>> GetCategoriesAsync(); /// /// Bu metod ile Hepsiburada’ daki uç kategorilerin özellik bilgilerini alabilirsiniz. /// Kategori özellikleri, sadece ‘leaf’ ve ‘available’ değerleri ‘true’ olan kategorilerde mevcuttur. /// /// - public Task GetCategoryAttributesAsync(int categoryId); + public Task>> GetCategoryAttributesAsync(int categoryId); /// /// Bu metod ile ‘type’ alanı değeri ‘enum’ olan özellikler için kullanılabilecek değerleri alabilirsiniz. @@ -22,5 +24,85 @@ public interface IHepsiburadaProductIntegration /// Category id /// Attribute id /// - public Task GetCategoryAttributeValuesAsync(int categoryId, string attributeId); + public Task>> GetCategoryAttributeValuesAsync(int categoryId, string attributeId); + + /// + /// Eşleşen statü red endpointi ile eşleşen statüdeki ürünlerinize api üzerinden red işlemi yapılabilmektedir. + /// + /// Category id + /// + public Task> GetCategoryAttributeValuesAsync(RejectPrematchRequestModel rejectPrematchRequestModel); + + /// + /// Bu metod ile; ürün bilgilerini, ürün giriş sürecine dahil olması için Hepsiburada’ ya gönderebilirsiniz. + /// + /// Category id + /// + public Task> CreateProductsAsync(BulkModel createProductRequestModels); + + /// + /// Bu method ile HB katalogunda kayıtlı olan ve global barkod içeren ürünleri mapping + /// sürecine gerek kalmadan hızlı bir şekilde mağazanıza yükleyebilirsiniz. + /// HB katalogunda kayıtlı olmayan ürünler bu method kullanıldığında yüklenmeyecektir. + /// HB katalogunda kayıtlı olmayan ilk defa açılacak ürünler için “Ürün Bilgisi Gönderme” + /// methodu kullanılmalıdır. Süreç aşağıda aşamalarıyla birlikte anlatılmıştır. + /// + /// + /// + public Task>> FastListingAsync(BulkModel fastListingRequestModels); + + /// + /// Bu method ile bir Merchant'a ait ürünlerin statü bilgilerine ulaşabilirsiniz. + /// İstek limiti her bir IP başına “500 istek/1 saniye” + /// + /// + /// + public Task> CheckProductStatusAsync(BulkModel checkProductStatusRequestModels); + + /// + /// Eşleşen statü onay endpointi ile eşleşen statüdeki ürünlerinize api üzerinden onay işlemi yapılabilmektedir. + /// + /// + /// + public Task> ApprovePrematchAsync(BulkModel approvePrematchRequestModels); + + /// + /// Bu metod ile, daha önce almış olduğunuz ‘trackingId’ bilgilerini alabilirsiniz.Pagination yapısı ve sıralama özelliği geliştirilmiştir. + /// + /// + public Task>> GetTrackingIdHistoryAsync(); + + + /// + /// Bu metod ile; ‘trackingId’ bilgisine sahip olduğunuz ürünlerin durumlarını alabilirsiniz. + /// + /// + /// + public Task> GetProductStatusByTrackingIdAsync(string trackingId); + + /// + /// Bu method ile bir Merchanta ait ürünlerin statü bazlı ürün bilgilerine ulaşabilirsiniz. + /// + /// + /// + /// + public Task>> GetProductsByStatusAsync(string merchantId, string productStatus); + + /// + /// Silme isteğinin sonucunu kontrol için trackingid değerini sorgulamanız gerekir. + /// + /// + /// + public Task> CheckDeleteProductProcessAsync(string trackingId); + + /// + /// Bu metod ile mağazaların tüm ürünlerinin (ürün özellik değerleriyle birlikte) api üzerinden + /// listeleyebilirsiniz. Bu servisle artık mağazaların entegratör değişikliği yaptığı durumlarda + /// eski çalıştığı entegratörden ürün bilgilerini talep etmesine gerek kalmayacak, Hepsiburada API + /// servisi üzerinden bütün ürün bilgilerini listeleyebilecektir. + /// + /// + /// + public Task>> GetMerchantProductsAsync(string merchantId); + } \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/ApprovePrematchRequestModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/ApprovePrematchRequestModel.cs new file mode 100644 index 0000000..d8ce77d --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/ApprovePrematchRequestModel.cs @@ -0,0 +1,13 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Request; +public class ApprovePrematchRequestModel : IRequestModel +{ + public ApprovePrematchRequestModel(string merchant, List merchantSkuList) + { + Merchant = merchant; + MerchantSkuList = merchantSkuList; + } + + public string Merchant { get; set; } + public List MerchantSkuList { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/CheckProductStatusRequestModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/CheckProductStatusRequestModel.cs new file mode 100644 index 0000000..cc64e95 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/CheckProductStatusRequestModel.cs @@ -0,0 +1,13 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Request; +public class CheckProductStatusRequestModel : IRequestModel +{ + public CheckProductStatusRequestModel(string merchant, List merchantSkuList) + { + Merchant = merchant; + MerchantSkuList = merchantSkuList; + } + + public string Merchant { get; set; } + public List MerchantSkuList { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/CreateProductRequestModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/CreateProductRequestModel.cs new file mode 100644 index 0000000..c9dd0be --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/CreateProductRequestModel.cs @@ -0,0 +1,61 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Request; +public class CreateProductRequestModel : IRequestModel +{ + public CreateProductRequestModel(int categoryId, string merchant, List attributes) + { + CategoryId = categoryId; + Merchant = merchant; + Attributes = attributes; + } + + public int CategoryId { get; set; } + public string Merchant { get; set; } + public List Attributes { get; set; } +} + +public class CreateProductAttributeRequestModel : IRequestModel +{ + public CreateProductAttributeRequestModel(string merchantSku, string varyantGroupID, string barcode, string urunAdi, string urunAciklamasi, string marka, int garantiSuresi, string kg, string taxVatRate, string price, string stock, string image1, string image2, string image3, string image4, string image5, string video1, string renkVariantProperty, string ebatlarVariantProperty) + { + MerchantSku = merchantSku; + VaryantGroupID = varyantGroupID; + Barcode = barcode; + UrunAdi = urunAdi; + UrunAciklamasi = urunAciklamasi; + Marka = marka; + GarantiSuresi = garantiSuresi; + Kg = kg; + TaxVatRate = taxVatRate; + Price = price; + Stock = stock; + Image1 = image1; + Image2 = image2; + Image3 = image3; + Image4 = image4; + Image5 = image5; + Video1 = video1; + RenkVariantProperty = renkVariantProperty; + EbatlarVariantProperty = ebatlarVariantProperty; + } + + public string MerchantSku { get; set; } + public string VaryantGroupID { get; set; } + public string Barcode { get; set; } + public string UrunAdi { get; set; } + public string UrunAciklamasi { get; set; } + public string Marka { get; set; } + public int GarantiSuresi { get; set; } + public string Kg { get; set; } + public string TaxVatRate { get; set; } + public string Price { get; set; } + public string Stock { get; set; } + public string Image1 { get; set; } + public string Image2 { get; set; } + public string Image3 { get; set; } + public string Image4 { get; set; } + public string Image5 { get; set; } + public string Video1 { get; set; } + public string RenkVariantProperty { get; set; } + public string EbatlarVariantProperty { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/FastListingRequestModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/FastListingRequestModel.cs new file mode 100644 index 0000000..a4b777f --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/FastListingRequestModel.cs @@ -0,0 +1,23 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Request; +public class FastListingRequestModel : IRequestModel +{ + public FastListingRequestModel(string merchant, string merchantSku, string productName, string barcode, string? stock = null, string? price = null, long? itemOrderId = null) + { + Merchant = merchant; + MerchantSku = merchantSku; + ProductName = productName; + Barcode = barcode; + Stock = stock; + Price = price; + ItemOrderId = itemOrderId; + } + + public string Merchant { get; set; } + public string MerchantSku { get; set; } + public string ProductName { get; set; } + public string Barcode { get; set; } + public string? Stock { get; set; } + public string? Price { get; set; } + public long? ItemOrderId { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/RejectPrematchRequestModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/RejectPrematchRequestModel.cs new file mode 100644 index 0000000..e76c5bb --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Request/RejectPrematchRequestModel.cs @@ -0,0 +1,13 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Request; +public class RejectPrematchRequestModel : IRequestModel +{ + public RejectPrematchRequestModel(string merchant, List merchantSkuList) + { + Merchant = merchant; + MerchantSkuList = merchantSkuList; + } + + public string Merchant { get; set; } + public List MerchantSkuList { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/ApprovePrematchResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/ApprovePrematchResponseModel.cs new file mode 100644 index 0000000..d70ecb7 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/ApprovePrematchResponseModel.cs @@ -0,0 +1,5 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class ApprovePrematchResponseModel : IResponseModel +{ +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CheckProductStatusByTrackingIdResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CheckProductStatusByTrackingIdResponseModel.cs new file mode 100644 index 0000000..09e722b --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CheckProductStatusByTrackingIdResponseModel.cs @@ -0,0 +1,7 @@ +using Integration.Hub; + +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class CheckProductStatusByTrackingIdResponseModel : IResponseModel +{ + +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CheckProductStatusResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CheckProductStatusResponseModel.cs new file mode 100644 index 0000000..03c08a9 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CheckProductStatusResponseModel.cs @@ -0,0 +1,6 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class CheckProductStatusResponseModel : IResponseModel +{ + +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CreateProductResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CreateProductResponseModel.cs new file mode 100644 index 0000000..12a5020 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/CreateProductResponseModel.cs @@ -0,0 +1,7 @@ +using Integration.Hub; + +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class CreateProductResponseModel : IResponseModel +{ + +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/DeleteProductProcessResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/DeleteProductProcessResponseModel.cs new file mode 100644 index 0000000..7184e2c --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/DeleteProductProcessResponseModel.cs @@ -0,0 +1,19 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class CheckDeleteProductProcessResponseModel : IResponseModel +{ + public string Id { get; set; } + public string CreatedBy { get; set; } + public string ModifiedBy { get; set; } + public string TrackingId { get; set; } + public List DeletedProductList { get; set; } + public bool Completed { get; set; } +} + +public class CheckDeleteProductProcessDeletedProductResponseModel : IResponseModel +{ + public string Merchant { get; set; } + public string MerchantSku { get; set; } + public bool Deleted { get; set; } + public string ErrorMessage { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/FastListingResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/FastListingResponseModel.cs new file mode 100644 index 0000000..c484b2b --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/FastListingResponseModel.cs @@ -0,0 +1,7 @@ +using Integration.Hub; + +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class FastListingResponseModel : IResponseModel +{ + +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs index 17cfa76..ca50691 100644 --- a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs @@ -2,12 +2,7 @@ namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; -public class GetCategoriesResponseModel : HepsiburadaBaseResponseModel -{ - public List Data { get; set; } -} - -public class GetCategoryResponseModel : IResponseModel +public class GetCategoriesResponseModel : IResponseModel { public int CategoryId { get; set; } public string Name { get; set; } diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributeValuesResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributeValuesResponseModel.cs index 37d8c7c..71c8fda 100644 --- a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributeValuesResponseModel.cs +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributeValuesResponseModel.cs @@ -2,12 +2,7 @@ namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; -public class GetCategoryAttributeValuesResponseModel : HepsiburadaBaseResponseModel -{ - public List Data { get; set; } -} - -public class GetCategoryAttributeValueResponseModel : IResponseModel +public class GetCategoryAttributeValuesResponseModel : IResponseModel { public string Value { get; set; } } \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs index 101bcdc..59c4a8b 100644 --- a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs @@ -2,12 +2,7 @@ namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; -public class GetCategoryAttributesResponseModel : HepsiburadaBaseResponseModel -{ - public List Data { get; set; } -} - -public class GetCategoryAttributesMappingResponseModel : IResponseModel +public class GetCategoryAttributesResponseModel : IResponseModel { public List BaseAttributes { get; set; } public List Attributes { get; set; } diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetMerchantProductResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetMerchantProductResponseModel.cs new file mode 100644 index 0000000..5a4bec6 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetMerchantProductResponseModel.cs @@ -0,0 +1,50 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class GetMerchantProductResponseModel : IResponseModel +{ + public string MerchantSku { get; set; } + public string Barcode { get; set; } + public string HbSku { get; set; } + public string VariantGroupId { get; set; } + public string ProductName { get; set; } + public string Brand { get; set; } + public List Images { get; set; } + public int CategoryId { get; set; } + public string CategoryName { get; set; } + public string Tax { get; set; } + public string Price { get; set; } + public string Description { get; set; } + public string Status { get; set; } + public List BaseAttributes { get; set; } + public List VariantTypeAttributes { get; set; } + public List ProductAttributes { get; set; } + public List ValidationResults { get; set; } + public string RejectReasons { get; set; } +} + +public class GetMerchantProductBaseAttributeResponseModel : IResponseModel +{ + public string Name { get; set; } + public string Value { get; set; } + public bool Mandatory { get; set; } +} + +public class GetMerchantProductVariantTypeAttributeResponseModel : IResponseModel +{ + public string Name { get; set; } + public string Value { get; set; } + public bool Mandatory { get; set; } +} + +public class GetMerchantProductProductAttributeResponseModel : IResponseModel +{ + public string Name { get; set; } + public string Value { get; set; } + public bool Mandatory { get; set; } +} + +public class GetMerchantProductValidationResultResponseModel : IResponseModel +{ + public string AttributeName { get; set; } + public string Message { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetProductsByStatusResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetProductsByStatusResponseModel.cs new file mode 100644 index 0000000..6c88219 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetProductsByStatusResponseModel.cs @@ -0,0 +1,51 @@ +using Integration.Hub; + +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class GetProductByStatusResponseModel : IResponseModel +{ + public string MerchantSku { get; set; } + public string Barcode { get; set; } + public string HbSku { get; set; } + public string VariantGroupId { get; set; } + public string ProductName { get; set; } + public string ProductStatus { get; set; } + public List TaskDetails { get; set; } + public List ValidationResults { get; set; } + public List MatchedHbProductInfo { get; set; } + public string RejectReasonsMessages { get; set; } + public string VideoStatus { get; set; } +} + +public class GetProductsByStatusTaskResponseModel : IResponseModel +{ + public string Reason { get; set; } + public string Url { get; set; } + public List CommentList { get; set; } +} + +public class GetProductsByStatusTaskListCommentResponseModel : IResponseModel +{ + public string Message { get; set; } + public string User { get; set; } +} + +public class GetProductsByStatusValidationResultResponseModel : IResponseModel +{ + public string AttributeName { get; set; } + public string Message { get; set; } +} + +public class GetProductsByStatusMatchedHbProductInfoResponseModel : IResponseModel +{ + public string HbSku { get; set; } + public string ProductName { get; set; } + public string Brand { get; set; } + public List Images { get; set; } + public List VariantTypeAttributes { get; set; } +} + +public class GetProductsByStatusVariantTypeAttributeResponseModel : IResponseModel +{ + public string Name { get; set; } + public string Value { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetTrackingIdHistoriesResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetTrackingIdHistoriesResponseModel.cs new file mode 100644 index 0000000..c07a7b2 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetTrackingIdHistoriesResponseModel.cs @@ -0,0 +1,8 @@ +using Integration.Hub; +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class GetTrackingIdHistoriesResponseModel : IResponseModel +{ + public string CreatedDate { get; set; } + public string TrackingId { get; set; } +} + diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs index e7997d1..fd9bd23 100644 --- a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs @@ -1,10 +1,11 @@ using Integration.Hub; namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; -public class HepsiburadaBaseResponseModel : IResponseModel +public class HepsiburadaBaseResponseModel : IResponseModel { public bool Success { get; set; } public int Code { get; set; } public int Version { get; set; } public string Message { get; set; } + public TResponse Data { get; set; } } \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/RejectPrematchResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/RejectPrematchResponseModel.cs new file mode 100644 index 0000000..b20b6da --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/RejectPrematchResponseModel.cs @@ -0,0 +1,7 @@ +using Integration.Hub; + +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; +public class RejectPrematchResponseModel : IResponseModel +{ + +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Trendyol/Infrastructure/ProductIntegration/TrendyolProductIntegration.cs b/src/Marketplaces/Integration.Marketplaces.Trendyol/Infrastructure/ProductIntegration/TrendyolProductIntegration.cs index e41467d..bdf89a0 100644 --- a/src/Marketplaces/Integration.Marketplaces.Trendyol/Infrastructure/ProductIntegration/TrendyolProductIntegration.cs +++ b/src/Marketplaces/Integration.Marketplaces.Trendyol/Infrastructure/ProductIntegration/TrendyolProductIntegration.cs @@ -28,9 +28,7 @@ public TrendyolProductIntegration(string supplierId, string apiKey, string apiSe /// public async Task CreateProductsV2Async(BulkModel products) { - var response = await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetCreateProducsUrl(), requestBody), products); - - return true; + return await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetCreateProducsUrl(), requestBody), products); } /// @@ -40,9 +38,7 @@ public async Task CreateProductsV2Async(BulkModel public async Task DeleteProductsAsync(BulkModel products) { - var response = await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetDeleteProductUrl(), requestBody), products); - - return true; + return await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetDeleteProductUrl(), requestBody), products); } /// @@ -118,9 +114,7 @@ public List GetProviders() /// public async Task UpdatePriceAndInventoryAsync(BulkModel products) { - var response = await InvokeRequestAsync((client, requestBody) => client.PutAsync(GetUpdatePriceAndStockUrl(), requestBody), products); - - return true; + return await InvokeRequestAsync((client, requestBody) => client.PutAsync(GetUpdatePriceAndStockUrl(), requestBody), products); } /// @@ -130,8 +124,6 @@ public async Task UpdatePriceAndInventoryAsync(BulkModel public async Task UpdateProductAsync(BulkModel products) { - var response = await InvokeRequestAsync((client, requestBody) => client.PutAsync(GetUpdateProductUrl(), requestBody), products); - - return true; + return await InvokeRequestAsync((client, requestBody) => client.PutAsync(GetUpdateProductUrl(), requestBody), products); } } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/ISipayAuthIntegration.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/ISipayAuthIntegration.cs index f4d7dca..90b4eba 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/ISipayAuthIntegration.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/ISipayAuthIntegration.cs @@ -5,5 +5,5 @@ namespace Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration; public interface ISipayAuthIntegration : IAuthIntegration { - Task GetAuthTokenAsync(GetAuthTokenRequestModel requestModel); + public Task> GetAuthTokenAsync(GetAuthTokenRequestModel requestModel); } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Request/GetAuthTokenRequestModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Request/GetAuthTokenRequestModel.cs index 7633cae..96e98e2 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Request/GetAuthTokenRequestModel.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Request/GetAuthTokenRequestModel.cs @@ -1,13 +1,14 @@ using Integration.Hub; + namespace Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Request; + public class GetAuthTokenRequestModel : IRequestModel { + public string AppId { get; set; } + public string AppSecret { get; set; } public GetAuthTokenRequestModel(string appId, string appSecret) { AppId = appId; AppSecret = appSecret; } - - public string AppId { get; set; } - public string AppSecret { get; set; } } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Response/GetAuthTokenResponseModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Response/GetAuthTokenResponseModel.cs index bd238ef..32b8152 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Response/GetAuthTokenResponseModel.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Response/GetAuthTokenResponseModel.cs @@ -1,7 +1,9 @@ +using Integration.Hub; + namespace Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Response; -public class GetAuthTokenResponseModel : SipayBaseResponseModel +public class GetAuthTokenResponseModel : IResponseModel { - public string StatusCode { get; set; } - public bool Is3D { get; set; } + public string Token { get; set; } + public int Is3D { get; set; } public string ExpiresAt { get; set; } } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Response/SipayBaseResponseModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Response/SipayBaseResponseModel.cs index 0736aa7..a13b959 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Response/SipayBaseResponseModel.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/Models/Response/SipayBaseResponseModel.cs @@ -3,7 +3,7 @@ namespace Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Response; public class SipayBaseResponseModel : IResponseModel { - public bool StatusCode { get; set; } - public int StatusDescription { get; set; } + public int StatusCode { get; set; } + public string StatusDescription { get; set; } public TResponse Data { get; set; } } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/SipayAuthIntegration.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/SipayAuthIntegration.cs index 51faab4..cee0521 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/SipayAuthIntegration.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/AuthIntegration/SipayAuthIntegration.cs @@ -11,8 +11,8 @@ public SipayAuthIntegration(string merchantKey, string appKey, string appSecret, { } - public async Task GetAuthTokenAsync(GetAuthTokenRequestModel requestModel) + public async Task> GetAuthTokenAsync(GetAuthTokenRequestModel requestModel) { - return await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetTokentUrl(), requestBody), requestModel); + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetTokentUrl(), requestBody), requestModel); } } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/ISipayCardIntegration.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/ISipayCardIntegration.cs new file mode 100644 index 0000000..3542a02 --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/ISipayCardIntegration.cs @@ -0,0 +1,52 @@ +using Integration.Hub; +using Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Response; +using Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Request; +using Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Response; +using Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Request; + +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration; + +public interface ISipayCardIntegration : ICardIntegration +{ + /// + /// Saklı kart ile ödeme servisi, sipariş vermek için kullanılır. Üye işyeri web + /// sitesi ödeme formunu doldurup gönderdikten sonra kullanıcı doğrudan banka sayfasına + /// yönlendirilecektir. Ödeme, banka ağ geçidinde bir SMS koduyla doğrulanacaktır. + /// Ödeme başarılı olduktan sonra, kullanıcı üye iş yerinin başarılı URL'sine yeniden + /// yönlendirilecektir, aksi takdirde, üye iş yeri tarafından belirlenen URL'yi iptal + /// etmek için yeniden yönlendirilecektir. Bu getpos API 'sinde diğer ödeme api adı + /// verilenler gibi getPos Api'yi çağırmaya gerek yoktur. + /// + /// + /// + Task> NonSecurePaymentWithCardTokenAsync(NonSecurePaymentWithCardTokenRequestModel nonSecurePaymentWithCardTokenRequestModel); + + /// + /// Kart Kayıt servisi, kart bilgilerini Sipay Sisteminde saklamak ve bir tokenı geri + /// göndermek için kullanılır. payByCardToken API 'de kullanılacak yanıt. + /// + /// + /// + Task> SaveCardAsync(SaveCardRequestModel saveCardRequestModel); + + /// + /// Müşteri için kaydedilmiş kartları çağırabileceğiniz servistir. + /// + /// + /// + Task>> GetCardAsync(GetCardRequestModel getCardRequestModel); + + /// + /// Müşterinin kartında yapılacak değişiklik için kullanılan servistir. + /// + /// + /// + Task> UpdateCardAsync(UpdateCardRequestModel updateCardRequestModel); + + /// + /// Müşteriye ait daha önce kaydedilmiş bir kartı silmeye yarayan servistir. + /// + /// + /// + Task> DeleteCardAsync(DeleteCardRequestModel deleteCardRequestModel); +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/DeleteCardRequestModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/DeleteCardRequestModel.cs new file mode 100644 index 0000000..50bbc85 --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/DeleteCardRequestModel.cs @@ -0,0 +1,18 @@ +using Integration.Hub; +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Request; + +public class DeleteCardRequestModel : IRequestModel +{ + public DeleteCardRequestModel(string merchantKey, string cardToken, int customerNumber, string hashKey) + { + MerchantKey = merchantKey; + CardToken = cardToken; + CustomerNumber = customerNumber; + HashKey = hashKey; + } + + public string MerchantKey { get; set; } + public string CardToken { get; set; } + public int CustomerNumber { get; set; } + public string HashKey { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/GetCardRequestModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/GetCardRequestModel.cs new file mode 100644 index 0000000..95bcfba --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/GetCardRequestModel.cs @@ -0,0 +1,13 @@ +using Integration.Hub; +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Request; +public class GetCardRequestModel : IRequestModel +{ + public GetCardRequestModel(string merchantKey, int customerNumber) + { + MerchantKey = merchantKey; + CustomerNumber = customerNumber; + } + + public string MerchantKey { get; set; } + public int CustomerNumber { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/NonSecurePaymentWithCardTokenRequestModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/NonSecurePaymentWithCardTokenRequestModel.cs new file mode 100644 index 0000000..51cb05e --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/NonSecurePaymentWithCardTokenRequestModel.cs @@ -0,0 +1,57 @@ +using Integration.Hub; +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Request; +public class NonSecurePaymentWithCardTokenRequestModel : IRequestModel +{ + public NonSecurePaymentWithCardTokenRequestModel(string cardToken, int customerNumber, string customerEmail, string customerPhone, string customerName, string currencyCode, int installmentsNumber, string invoiceId, string invoiceDescription, double total, string merchantKey, string items, string cancelUrl, string returnUrl, string hashKey, int orderType) + { + CardToken = cardToken; + CustomerNumber = customerNumber; + CustomerEmail = customerEmail; + CustomerPhone = customerPhone; + CustomerName = customerName; + CurrencyCode = currencyCode; + InstallmentsNumber = installmentsNumber; + InvoiceId = invoiceId; + InvoiceDescription = invoiceDescription; + Total = total; + MerchantKey = merchantKey; + Items = items; + CancelUrl = cancelUrl; + ReturnUrl = returnUrl; + HashKey = hashKey; + OrderType = orderType; + } + + public string CardToken { get; set; } + public int CustomerNumber { get; set; } + public string CustomerEmail { get; set; } + public string CustomerPhone { get; set; } + public string CustomerName { get; set; } + public string CurrencyCode { get; set; } + public int InstallmentsNumber { get; set; } + public string InvoiceId { get; set; } + public string InvoiceDescription { get; set; } + public double Total { get; set; } + public string MerchantKey { get; set; } + public string Items { get; set; } + public string CancelUrl { get; set; } + public string ReturnUrl { get; set; } + public string HashKey { get; set; } + public string BillAddress1 { get; set; } + public string BillAddress2 { get; set; } + public string BillCity { get; set; } + public string BillPostcode { get; set; } + public string BillState { get; set; } + public string BillCountry { get; set; } + public string BillEmail { get; set; } + public string BillPhone { get; set; } + public string CardProgram { get; set; } + public string Ip { get; set; } + public string TransactionType { get; set; } + public string SaleWebHookKey { get; set; } + public int OrderType { get; set; } + public int RecurringPaymentNumber { get; set; } + public string RecurringPaymentCycle { get; set; } + public string RecurringPaymentInterval { get; set; } + public string RecurringWebHookKey { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/SaveCardRequestModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/SaveCardRequestModel.cs new file mode 100644 index 0000000..7be7b12 --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/SaveCardRequestModel.cs @@ -0,0 +1,26 @@ +using Integration.Hub; +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Request; +public class SaveCardRequestModel : IRequestModel +{ + public SaveCardRequestModel(string merchantKey, string cardHolderName, long cardNumber, int expiryMonth, int expiryYear, int customerNumber, string hashKey) + { + MerchantKey = merchantKey; + CardHolderName = cardHolderName; + CardNumber = cardNumber; + ExpiryMonth = expiryMonth; + ExpiryYear = expiryYear; + CustomerNumber = customerNumber; + HashKey = hashKey; + } + + public string MerchantKey { get; set; } + public string CardHolderName { get; set; } + public long CardNumber { get; set; } + public int ExpiryMonth { get; set; } + public int ExpiryYear { get; set; } + public int CustomerNumber { get; set; } + public string HashKey { get; set; } + public string CustomerName { get; set; } + public string CustomerEmail { get; set; } + public long CustomerPhone { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/UpdateCardRequestModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/UpdateCardRequestModel.cs new file mode 100644 index 0000000..792f8ba --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Request/UpdateCardRequestModel.cs @@ -0,0 +1,23 @@ +using Integration.Hub; +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Request; + +public class UpdateCardRequestModel : IRequestModel +{ + public UpdateCardRequestModel(string merchantKey, string cardToken, int customerNumber, int expiryMonth, int expiryYear, string hashKey) + { + MerchantKey = merchantKey; + CardToken = cardToken; + CustomerNumber = customerNumber; + ExpiryMonth = expiryMonth; + ExpiryYear = expiryYear; + HashKey = hashKey; + } + + public string MerchantKey { get; set; } + public string CardToken { get; set; } + public int CustomerNumber { get; set; } + public int ExpiryMonth { get; set; } + public int ExpiryYear { get; set; } + public string HashKey { get; set; } + public string CardHolderName { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/GetCardResponseModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/GetCardResponseModel.cs new file mode 100644 index 0000000..36fa442 --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/GetCardResponseModel.cs @@ -0,0 +1,17 @@ +using Integration.Hub; +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Response; + +public class GetCardResponseModel : IResponseModel +{ + public int Id { get; set; } + public int PosId { get; set; } + public string CardToken { get; set; } + public int MerchantId { get; set; } + public int CustomerNumber { get; set; } + public string CustomerName { get; set; } + public string CustomerEmail { get; set; } + public long CustomerPhone { get; set; } + public int Bin { get; set; } + public DateTime CreatedAt { get; set; } + public DateTime UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/NonSecurePaymentWithCardTokenResponseModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/NonSecurePaymentWithCardTokenResponseModel.cs new file mode 100644 index 0000000..7c58ec3 --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/NonSecurePaymentWithCardTokenResponseModel.cs @@ -0,0 +1,18 @@ +using Integration.Hub; + +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Response; +public class NonSecurePaymentWithCardTokenResponseModel : IResponseModel +{ + public int SipayStatus { get; set; } + public string OrderNo { get; set; } + public string OrderId { get; set; } + public string InvoiceId { get; set; } + public int SipayPaymentMethod { get; set; } + public string CreditCardNo { get; set; } + public string TransactionType { get; set; } + public int PaymentStatus { get; set; } + public int PaymentMethod { get; set; } + public int ErrorCode { get; set; } + public string Error { get; set; } + public string HashKey { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/SaveCardResponseModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/SaveCardResponseModel.cs new file mode 100644 index 0000000..6852b08 --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/SaveCardResponseModel.cs @@ -0,0 +1,6 @@ +using Integration.Hub; +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Response; +public class SaveCardResponseModel : IResponseModel +{ + public string CardToken { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/UpdateCardResponseModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/UpdateCardResponseModel.cs new file mode 100644 index 0000000..6cd6e21 --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/Models/Response/UpdateCardResponseModel.cs @@ -0,0 +1,6 @@ +using Integration.Hub; +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Response; +public class UpdateCardResponseModel : IResponseModel +{ + public string CardToken { get; set; } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/SipayCardIntegration.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/SipayCardIntegration.cs new file mode 100644 index 0000000..5141fc1 --- /dev/null +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/CardIntegration/SipayCardIntegration.cs @@ -0,0 +1,81 @@ +using Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration; +using Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Request; +using Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Response; +using Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Request; +using Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Models.Response; +using Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration.Request; +using Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration; + +namespace Integration.PaymentGateways.Sipay.Infrastructure.CardIntegration; + +public class SipayCardIntegration : SipayIntegrationBase, ISipayCardIntegration +{ + private readonly ISipayAuthIntegration _authIntegration; + private string GetDeleteCardUrl() => $"{GetBaseUrl()}api/deleteCard"; + private string GetCardUrl() => $"{GetBaseUrl()}api/getCardTokens"; + private string GetSaveCardUrl() => $"{GetBaseUrl()}api/saveCard"; + private string GetUpdateCardUrl() => $"{GetBaseUrl()}api/editCard"; + private string GetNonSecurePaymentWithCardTokenUrl() => $"{GetBaseUrl()}api/payByCardToken"; + public SipayCardIntegration(string merchantKey, string appKey, string appSecret, int merchantId, bool isInProduction = true) : base(merchantKey, appKey, appSecret, merchantId, isInProduction) + { + _authIntegration = new SipayAuthIntegration(merchantKey, appKey, appSecret, merchantId, isInProduction); + } + + public async Task SetTokenAsync() + { + var authResponse = await _authIntegration.GetAuthTokenAsync(new GetAuthTokenRequestModel(_appKey, _appSecret)); + SetHeader(new KeyValuePair("Authorization", $"Bearer {authResponse.Data.Token}")); + return true; + } + + /// + /// + /// + /// + /// + public async Task> DeleteCardAsync(DeleteCardRequestModel deleteCardRequestModel) + { + deleteCardRequestModel.MerchantKey = _merchantKey; + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetDeleteCardUrl(), requestBody), deleteCardRequestModel); + } + + /// + /// + /// + /// + /// + public async Task>> GetCardAsync(GetCardRequestModel getCardRequestModel) + { + return await InvokeRequestAsync>>((client, requestBody) => client.PostAsync(GetCardUrl(), requestBody), getCardRequestModel); + } + + /// + /// + /// + /// + /// + public async Task> NonSecurePaymentWithCardTokenAsync(NonSecurePaymentWithCardTokenRequestModel nonSecurePaymentWithCardTokenRequestModel) + { + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetNonSecurePaymentWithCardTokenUrl(), requestBody), nonSecurePaymentWithCardTokenRequestModel); + } + + /// + /// + /// + /// + /// + public async Task> SaveCardAsync(SaveCardRequestModel saveCardRequestModel) + { + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetSaveCardUrl(), requestBody), saveCardRequestModel); + } + + /// + /// + /// + /// + /// + public async Task> UpdateCardAsync(UpdateCardRequestModel updateCardRequestModel) + { + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetUpdateCardUrl(), requestBody), updateCardRequestModel); + } +} \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/ISipayPaymentIntegration.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/ISipayPaymentIntegration.cs index e43b50f..29523a1 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/ISipayPaymentIntegration.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/ISipayPaymentIntegration.cs @@ -1,4 +1,5 @@ using Integration.Hub; +using Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Response; using Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration.Models.Request; using Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration.Models.Response; @@ -6,6 +7,11 @@ namespace Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration; public interface ISipayPaymentIntegration : IPaymentIntegration { + /// + /// Sets bearer token for authorization + /// + /// + public Task SetTokenAsync(); /// /// Kullanıcı kart numarasının ilk 6 hanesini, tarım kartları için @@ -14,7 +20,7 @@ public interface ISipayPaymentIntegration : IPaymentIntegration /// tarım kartları için vade aralığını ve ödeme sıklığını sağlamaktan sorumludur. /// /// - Task CheckInstallmentsAsync(CheckInstallmentRequestModel checkInstallmentRequestModel); + Task>> CheckInstallmentsAsync(CheckInstallmentRequestModel checkInstallmentRequestModel); /// /// Sipay admini, üye işyeri web sitesinden yapılan ödemenin Non-Secure mi @@ -24,7 +30,7 @@ public interface ISipayPaymentIntegration : IPaymentIntegration /// /// /// - Task NonSecurePaymentAsync(NonSecurePaymentRequestModel nonSecurePaymentRequestModel); + Task> NonSecurePaymentAsync(NonSecurePaymentRequestModel nonSecurePaymentRequestModel); /// /// Initial request to pay secure. This method returns html template. @@ -34,25 +40,24 @@ public interface ISipayPaymentIntegration : IPaymentIntegration /// string SecurePaymentInitial(SecurePaymentInitialRequestModel securePaymentInitialRequestModel); - /// /// Charge request to pay secure /// /// /// - Task SecurePaymentChargeAsync(SecurePaymentChargeRequestModel securePaymentChargeRequestModel); + Task> SecurePaymentChargeAsync(SecurePaymentChargeRequestModel securePaymentChargeRequestModel); /// /// Cancel payment /// /// /// - Task CancelAsync(CancellationRequestModel cancellationRequestModel); + Task> CancelAsync(CancellationRequestModel cancellationRequestModel); /// /// Refund payment /// /// /// - Task RefundAsync(RefundRequestModel refundRequestModel); + Task> RefundAsync(RefundRequestModel refundRequestModel); } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/Models/Request/CheckInstallmentRequestModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/Models/Request/CheckInstallmentRequestModel.cs index 2b3ebba..b736e87 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/Models/Request/CheckInstallmentRequestModel.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/Models/Request/CheckInstallmentRequestModel.cs @@ -3,21 +3,21 @@ namespace Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration.Models.Request; public class CheckInstallmentRequestModel : IRequestModel { - public CheckInstallmentRequestModel(string creaditCard, double amount, string currenyCode, string? commissionBy = null, bool? isRecurring = null, bool? is_2d = null) + public CheckInstallmentRequestModel(string creditCard, double amount, string currencyCode, string? commissionBy = null, bool? isRecurring = null, bool? is2d = null) { - CreaditCard = creaditCard; + CreditCard = creditCard; Amount = amount; - CurrenyCode = currenyCode; + CurrencyCode = currencyCode; CommissionBy = commissionBy; IsRecurring = isRecurring; - Is_2d = is_2d; + Is2d = is2d; } - public string CreaditCard { get; set; } + public string CreditCard { get; set; } public double Amount { get; set; } - public string CurrenyCode { get; set; } + public string CurrencyCode { get; set; } public string MerchantKey { get; set; } public string? CommissionBy { get; set; } public bool? IsRecurring { get; set; } - public bool? Is_2d { get; set; } + public bool? Is2d { get; set; } } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/Models/Response/CheckInstallmentResponseModel.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/Models/Response/CheckInstallmentResponseModel.cs index 62ee5c0..39d9df6 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/Models/Response/CheckInstallmentResponseModel.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/Models/Response/CheckInstallmentResponseModel.cs @@ -3,4 +3,17 @@ namespace Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration.Models.Response; public class CheckInstallmentResponseModel : IResponseModel { + public int PosId { get; set; } + public int CampaignId { get; set; } + public int AllocationId { get; set; } + public int InstallmentsNumber { get; set; } + public string CardType { get; set; } + public string CardScheme { get; set; } + public string CardProgram { get; set; } + public double PayableAmount { get; set; } + public string HashKey { get; set; } + public string AmountToBePaid { get; set; } + public string CurrencyCode { get; set; } + public int CurrencyId { get; set; } + public string Title { get; set; } } \ No newline at end of file diff --git a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/SipayPaymentIntegration.cs b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/SipayPaymentIntegration.cs index d3318c7..0c44fc6 100644 --- a/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/SipayPaymentIntegration.cs +++ b/src/PaymentGateways/Integration.PaymentGateways.Sipay/Infrastructure/PaymentIntegration/SipayPaymentIntegration.cs @@ -3,20 +3,28 @@ using Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration.Models.Response; using Integration.PaymentGateways.Sipay.Infrastructure.PaymentIntegration; using Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Request; +using Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration; +using Integration.PaymentGateways.Sipay.Infrastructure.AuthIntegration.Models.Response; public class SipayPaymentIntegration : SipayIntegrationBase, ISipayPaymentIntegration { + private readonly ISipayAuthIntegration _authIntegration; private string GetCheckInstallmentsUrl() => $"{GetBaseUrl()}api/getpos"; private string GetNonSecurePaymentUrl() => $"{GetBaseUrl()}api/paySmart2D"; private string GetSecurePaymentInitialUrl() => $"{GetBaseUrl()}api/paySmart3D"; private string GetSecurePaymentChargeUrl() => $"{GetBaseUrl()}api/complete"; private string GetRefundUrl() => $"{GetBaseUrl()}api/refund"; private string GetCancelUrl() => $"{GetBaseUrl()}api/refund"; - public SipayPaymentIntegration(string merchantKey, string appKey, string appSecret, int merchantId, bool isInProduction = true) : base(merchantKey, appKey, appSecret, merchantId, isInProduction) { - var sipayAuthIntegration = new SipayAuthIntegration(merchantKey, appKey, appSecret, merchantId, isInProduction); - var token = sipayAuthIntegration.GetAuthTokenAsync(new GetAuthTokenRequestModel(appKey, appSecret)); + _authIntegration = new SipayAuthIntegration(merchantKey, appKey, appSecret, merchantId, isInProduction); + } + + public async Task SetTokenAsync() + { + var authResponse = await _authIntegration.GetAuthTokenAsync(new GetAuthTokenRequestModel(_appKey, _appSecret)); + SetHeader(new KeyValuePair("Authorization", $"Bearer {authResponse.Data.Token}")); + return true; } /// @@ -24,10 +32,10 @@ public SipayPaymentIntegration(string merchantKey, string appKey, string appSecr /// /// /// - public async Task CheckInstallmentsAsync(CheckInstallmentRequestModel checkInstallmentRequestModel) + public async Task>> CheckInstallmentsAsync(CheckInstallmentRequestModel checkInstallmentRequestModel) { checkInstallmentRequestModel.MerchantKey = _merchantKey; - return await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetCheckInstallmentsUrl(), requestBody), checkInstallmentRequestModel); + return await InvokeRequestAsync>>((client, requestBody) => client.PostAsync(GetCheckInstallmentsUrl(), requestBody), checkInstallmentRequestModel); } /// @@ -35,10 +43,10 @@ public async Task CheckInstallmentsAsync(CheckIns /// /// /// - public async Task NonSecurePaymentAsync(NonSecurePaymentRequestModel nonSecurePaymentRequestModel) + public async Task> NonSecurePaymentAsync(NonSecurePaymentRequestModel nonSecurePaymentRequestModel) { nonSecurePaymentRequestModel.MerchantKey = _merchantKey; - return await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetNonSecurePaymentUrl(), requestBody), nonSecurePaymentRequestModel); + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetNonSecurePaymentUrl(), requestBody), nonSecurePaymentRequestModel); } /// @@ -66,11 +74,11 @@ public string SecurePaymentInitial(SecurePaymentInitialRequestModel securePaymen /// /// /// - public async Task SecurePaymentChargeAsync(SecurePaymentChargeRequestModel securePaymentChargeRequestModel) + public async Task> SecurePaymentChargeAsync(SecurePaymentChargeRequestModel securePaymentChargeRequestModel) { securePaymentChargeRequestModel.MerchantKey = _merchantKey; - return await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetSecurePaymentChargeUrl(), requestBody), securePaymentChargeRequestModel); + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetSecurePaymentChargeUrl(), requestBody), securePaymentChargeRequestModel); } /// @@ -78,13 +86,13 @@ public async Task SecurePaymentChargeAsync(Sec /// /// /// - public async Task CancelAsync(CancellationRequestModel cancellationRequestModel) + public async Task> CancelAsync(CancellationRequestModel cancellationRequestModel) { cancellationRequestModel.MerchantKey = _merchantKey; cancellationRequestModel.AppSecret = _appSecret; cancellationRequestModel.AppId = _appKey; - return await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetCancelUrl(), requestBody), cancellationRequestModel); + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetCancelUrl(), requestBody), cancellationRequestModel); } /// @@ -92,12 +100,12 @@ public async Task CancelAsync(CancellationRequestMode /// /// /// - public async Task RefundAsync(RefundRequestModel refundRequestModel) + public async Task> RefundAsync(RefundRequestModel refundRequestModel) { refundRequestModel.MerchantKey = _merchantKey; refundRequestModel.AppSecret = _appSecret; refundRequestModel.AppId = _appKey; - return await InvokeRequestAsync((client, requestBody) => client.PostAsync(GetRefundUrl(), requestBody), refundRequestModel); + return await InvokeRequestAsync>((client, requestBody) => client.PostAsync(GetRefundUrl(), requestBody), refundRequestModel); } } \ No newline at end of file