diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f886c7a..6ec2666 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,20 +16,20 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.301 + dotnet-version: 6.* - name: Install dependencies working-directory: ./src run: dotnet restore - name: Build - working-directory: ./src + working-directory: ./src/DeepStack.CSharp.Sdk run: dotnet build -c Release --no-restore - name: Test - working-directory: ./src + working-directory: ./src/DeepStack.CSharp.Sdk.Tests run: dotnet test --no-restore --verbosity normal - - name: Pack - working-directory: ./src/GloballyPaid.CSharp.Sdk - run: dotnet pack -c Release -p:PackageVersion=1.0.0.$GITHUB_RUN_NUMBER - - uses: actions/upload-artifact@v2 - with: - name: globallypaid-sdk-dotnet.1.0.0.${{ github.run_number }}.nupkg - path: ./src/GloballyPaid.CSharp.Sdk/bin/Release/*.nupkg \ No newline at end of file + # - name: Pack + # working-directory: ./src/DeepStack.CSharp.Sdk + # run: dotnet pack -c Release -p:PackageVersion=1.0.1.$GITHUB_RUN_NUMBER + # - uses: actions/upload-artifact@v2 + # with: + # name: deepstack-sdk-dotnet.1.0.1.${{ github.run_number }}.nupkg + # path: ./src/DeepStack.CSharp.Sdk/bin/Release/*.nupkg diff --git a/README.md b/README.md index fd11e3f..0c67046 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -# Globally Paid .NET SDK +# Deepstack .NET SDK [![NuGet](https://img.shields.io/nuget/v/globallypaid.net.svg)](https://www.nuget.org/packages/GloballyPaid.net/) ![CI](https://github.com/globallypaid/globallypaid-sdk-dotnet/workflows/CI/badge.svg) -The official [Globally Paid][gp] .NET library +The official Deepstack .NET library Supporting [.NET Standard 2.0][netstandard] +// Update installing after fixing deployment for deepstack... ## Installation @@ -67,18 +68,18 @@ To register the Globally Paid services only, `AddGloballyPaidServices` extension services.AddGloballyPaidServices(); ``` -##### 2. GloballyPaidConfiguration object +##### 2. DeepStackConfiguration object All SDK calls can be configured using the static `GloballyPaidConfiguration` object: ```c# -GloballyPaidConfiguration.PublishableApiKey = "Your Publishable API Key"; -GloballyPaidConfiguration.SharedSecret = "Your Shared Secret"; -GloballyPaidConfiguration.AppId = "Your APP ID"; -GloballyPaidConfiguration.UseSandbox = false; //true if you need to test through Globally Paid sandbox -GloballyPaidConfiguration.RequestTimeoutSeconds = 90; +DeepStackConfiguration.PublishableApiKey = "Your Publishable API Key"; +DeepStackConfiguration.SharedSecret = "Your Shared Secret"; +DeepStackConfiguration.AppId = "Your APP ID"; +DeepStackConfiguration.UseSandbox = false; //true if you need to test through Globally Paid sandbox +DeepStackConfiguration.RequestTimeoutSeconds = 90; ``` -Or using the `GloballyPaidConfiguration` *Setup* method: +Or using the `DeepStackConfiguration` *Setup* method: ```c# GloballyPaidConfiguration.Setup("Your Publishable API Key", "Your Shared Secret", "Your APP ID", useSandbox: false, requestTimeoutSeconds: 90); @@ -90,11 +91,11 @@ All SDK calls can be configured using the `` section in configurati ```xml - - - - - + + + + + ``` diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/BaseMockTestCollection.cs b/src/DeepStack.CSharp.Sdk.Tests/BaseMockTestCollection.cs similarity index 93% rename from src/GloballyPaid.CSharp.Sdk.Tests/BaseMockTestCollection.cs rename to src/DeepStack.CSharp.Sdk.Tests/BaseMockTestCollection.cs index 0a8a10f..159a321 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/BaseMockTestCollection.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/BaseMockTestCollection.cs @@ -2,7 +2,7 @@ using System.Net.Http; using Xunit; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { [CollectionDefinition("Globally Paid SDK tests")] public class BaseMockTestCollection : diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/BaseTest.cs b/src/DeepStack.CSharp.Sdk.Tests/BaseTest.cs similarity index 95% rename from src/GloballyPaid.CSharp.Sdk.Tests/BaseTest.cs rename to src/DeepStack.CSharp.Sdk.Tests/BaseTest.cs index c8067e8..3b5f6c9 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/BaseTest.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/BaseTest.cs @@ -1,9 +1,15 @@ using System; using System.Net; using System.Net.Http; +using DeepStack.Core; +using DeepStack.Entities; +using DeepStack.Entities.Common; +using DeepStack.Enums; +using DeepStack.Requests; +using DeepStack.Requests.Base; using Xunit; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { [Collection("Globally Paid SDK tests")] public class BaseTest diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/GloballyPaid.CSharp.Sdk.Tests.csproj b/src/DeepStack.CSharp.Sdk.Tests/DeepStack.CSharp.Sdk.Tests.csproj similarity index 86% rename from src/GloballyPaid.CSharp.Sdk.Tests/GloballyPaid.CSharp.Sdk.Tests.csproj rename to src/DeepStack.CSharp.Sdk.Tests/DeepStack.CSharp.Sdk.Tests.csproj index 0dc3125..b7ec5aa 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/GloballyPaid.CSharp.Sdk.Tests.csproj +++ b/src/DeepStack.CSharp.Sdk.Tests/DeepStack.CSharp.Sdk.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 false @@ -23,7 +23,7 @@ - + diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/MockHttpClientFixture.cs b/src/DeepStack.CSharp.Sdk.Tests/MockHttpClientFixture.cs similarity index 98% rename from src/GloballyPaid.CSharp.Sdk.Tests/MockHttpClientFixture.cs rename to src/DeepStack.CSharp.Sdk.Tests/MockHttpClientFixture.cs index 2635317..cb5cf9b 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/MockHttpClientFixture.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/MockHttpClientFixture.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { public class MockHttpClientFixture { diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/CaptureServiceTest.cs b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/CaptureServiceTest.cs similarity index 84% rename from src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/CaptureServiceTest.cs rename to src/DeepStack.CSharp.Sdk.Tests/Services/v1/CaptureServiceTest.cs index c956cca..9e4e48d 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/CaptureServiceTest.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/CaptureServiceTest.cs @@ -1,9 +1,14 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; +using DeepStack.Core; +using DeepStack.Entities; +using DeepStack.Extensions; +using DeepStack.Requests; +using DeepStack.Services.v1; using Xunit; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { public class CaptureServiceTest : BaseTest { @@ -51,11 +56,11 @@ public void Capture_Error_Invalid_ResponseCode() StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, expectedResult.ToJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Capture(GetCaptureRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.HttpStatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal("Not Approved", exception.ErrorMessage); } @@ -64,11 +69,11 @@ public void Capture_Error_Invalid_API_Response() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Capture(GetCaptureRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -78,11 +83,11 @@ public void Capture_Error_Invalid_Status() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Capture(GetCaptureRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/ChargeServiceTest.cs b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/ChargeServiceTest.cs similarity index 92% rename from src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/ChargeServiceTest.cs rename to src/DeepStack.CSharp.Sdk.Tests/Services/v1/ChargeServiceTest.cs index 4cea988..9ca3049 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/ChargeServiceTest.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/ChargeServiceTest.cs @@ -1,9 +1,17 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; +using DeepStack.Core; +using DeepStack.Entities; +using DeepStack.Entities.Common; +using DeepStack.Entities.Interface; +using DeepStack.Enums; +using DeepStack.Extensions; +using DeepStack.Requests; +using DeepStack.Services.v1; using Xunit; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { public class ChargeServiceTest : BaseTest { @@ -101,11 +109,11 @@ public void Charge_Error_Invalid_API_Response() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Charge(GetChargeRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -115,11 +123,11 @@ public void Capture_Error_Invalid_Status() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Charge(GetChargeRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } @@ -155,7 +163,7 @@ private ChargeResponse GetCharge(bool captured = true, bool savePaymentInstrumen { Type = PaymentSourceType.CARD_ON_FILE, Id = "id" - }, + } Amount = 1299, ResponseCode = "00", Message = "charged", diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/CustomerServiceTest.cs b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/CustomerServiceTest.cs similarity index 87% rename from src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/CustomerServiceTest.cs rename to src/DeepStack.CSharp.Sdk.Tests/Services/v1/CustomerServiceTest.cs index 8d6fa3f..bc8529c 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/CustomerServiceTest.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/CustomerServiceTest.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Xunit; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { public class CustomerServiceTest : BaseTest { @@ -71,11 +71,11 @@ public void List_Error_Invalid_API_Response() { StubRequest(HttpMethod.Get, BasePath, HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.List()); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -85,11 +85,11 @@ public void List_Error_Invalid_Status() { StubRequest(HttpMethod.Get, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.List()); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } @@ -138,11 +138,11 @@ public void Get_Error_Invalid_API_Response() { StubRequest(HttpMethod.Get, $"{BasePath}/id", HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Get("id")); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -152,11 +152,11 @@ public void Get_Error_Invalid_Status() { StubRequest(HttpMethod.Get, $"{BasePath}/id", HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Get("id")); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } @@ -192,11 +192,11 @@ public void Create_Error_Invalid_API_Response() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Create(GetCustomer(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -206,11 +206,11 @@ public void Create_Error_Invalid_Status() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Create(GetCustomer(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } @@ -246,11 +246,11 @@ public void Update_Error_Invalid_API_Response() { StubRequest(HttpMethod.Put, $"{BasePath}/id", HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Update(GetCustomer(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -260,11 +260,11 @@ public void Update_Error_Invalid_Status() { StubRequest(HttpMethod.Put, $"{BasePath}/id", HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Update(GetCustomer(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/PaymentInstrumentServiceTest.cs b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/PaymentInstrumentServiceTest.cs similarity index 89% rename from src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/PaymentInstrumentServiceTest.cs rename to src/DeepStack.CSharp.Sdk.Tests/Services/v1/PaymentInstrumentServiceTest.cs index 641fcca..4074a07 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/PaymentInstrumentServiceTest.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/PaymentInstrumentServiceTest.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Xunit; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { public class PaymentInstrumentServiceTest : BaseTest { @@ -71,11 +71,11 @@ public void List_Error_Invalid_API_Response() { StubRequest(HttpMethod.Get, $"{BasePath}/list/customer_id", HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.List("customer_id")); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -85,11 +85,11 @@ public void List_Error_Invalid_Status() { StubRequest(HttpMethod.Get, $"{BasePath}/list/customer_id", HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.List("customer_id")); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } @@ -138,11 +138,11 @@ public void Get_Error_Invalid_API_Response() { StubRequest(HttpMethod.Get, $"{BasePath}/customerId/id", HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Get("id", "customerId")); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -152,11 +152,11 @@ public void Get_Error_Invalid_Status() { StubRequest(HttpMethod.Get, $"{BasePath}/customerId/id", HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Get("id", "customerId")); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } @@ -218,11 +218,11 @@ public void Update_Error_Invalid_API_Response() { StubRequest(HttpMethod.Put, $"{BasePath}/{_customerId}/{_Id}", HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Update(GetPaymentInstrument(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -232,11 +232,11 @@ public void Update_Error_Invalid_Status() { StubRequest(HttpMethod.Put, $"{BasePath}/{_customerId}/{_Id}", HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Update(GetPaymentInstrument(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/RefundServiceTest.cs b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/RefundServiceTest.cs similarity index 86% rename from src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/RefundServiceTest.cs rename to src/DeepStack.CSharp.Sdk.Tests/Services/v1/RefundServiceTest.cs index 0481571..32228bb 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/RefundServiceTest.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/RefundServiceTest.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using Xunit; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { public class RefundServiceTest : BaseTest { @@ -51,11 +51,11 @@ public void Refund_Error_Invalid_ResponseCode() StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, expectedResult.ToJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Refund(GetRefundRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.HttpStatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal("Not Approved", exception.ErrorMessage); } @@ -64,11 +64,11 @@ public void Refund_Error_Invalid_API_Response() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Refund(GetRefundRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -78,11 +78,11 @@ public void Refund_Error_Invalid_Status() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Refund(GetRefundRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } diff --git a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/TokenServiceTest.cs b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/TokenServiceTest.cs similarity index 87% rename from src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/TokenServiceTest.cs rename to src/DeepStack.CSharp.Sdk.Tests/Services/v1/TokenServiceTest.cs index f28e7bd..3a03c8b 100644 --- a/src/GloballyPaid.CSharp.Sdk.Tests/Services/v1/TokenServiceTest.cs +++ b/src/DeepStack.CSharp.Sdk.Tests/Services/v1/TokenServiceTest.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using Xunit; -namespace GloballyPaid.Tests +namespace DeepStack.Tests { public class TokenServiceTest : BaseTest { @@ -49,11 +49,11 @@ public void Tokenize_Error_Invalid_API_Response() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, GetInvalidJson()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Tokenize(GetTokenizeRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); //Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage); Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content); } @@ -63,11 +63,11 @@ public void Tokenize_Error_Invalid_Status() { StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError()); - var exception = Assert.Throws(() => + var exception = Assert.Throws(() => service.Tokenize(GetTokenizeRequest(), GetTestRequestOptions())); Assert.Equal(HttpStatusCode.BadRequest, exception.GloballyPaidResponse.StatusCode); - Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message); + Assert.Equal("Exception of type 'GloballyPaid.DeepStackException' was thrown.", exception.Message); Assert.Equal($"{GetInvalidStatusError()}", exception.ErrorMessage); Assert.Equal($"{GetInvalidStatusError()}", exception.GloballyPaidResponse.Content); } diff --git a/src/GloballyPaid.CSharp.Sdk.sln b/src/DeepStack.CSharp.Sdk.sln similarity index 62% rename from src/GloballyPaid.CSharp.Sdk.sln rename to src/DeepStack.CSharp.Sdk.sln index 62ac7a2..cf349d7 100644 --- a/src/GloballyPaid.CSharp.Sdk.sln +++ b/src/DeepStack.CSharp.Sdk.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30611.23 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GloballyPaid.CSharp.Sdk", "GloballyPaid.CSharp.Sdk\GloballyPaid.CSharp.Sdk.csproj", "{7DD38CF8-C8BF-4ABB-A910-EFB80AFCD357}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepStack.CSharp.Sdk.Tests", "DeepStack.CSharp.Sdk.Tests\DeepStack.CSharp.Sdk.Tests.csproj", "{BB1D59B7-85B5-45C7-91ED-A53C075A86DF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GloballyPaid.CSharp.Sdk.Tests", "GloballyPaid.CSharp.Sdk.Tests\GloballyPaid.CSharp.Sdk.Tests.csproj", "{BB1D59B7-85B5-45C7-91ED-A53C075A86DF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepStack.CSharp.Sdk", "DeepStack.CSharp.Sdk\DeepStack.CSharp.Sdk.csproj", "{532835A9-D220-488A-95B2-CA09C8D02E51}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +13,14 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7DD38CF8-C8BF-4ABB-A910-EFB80AFCD357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7DD38CF8-C8BF-4ABB-A910-EFB80AFCD357}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7DD38CF8-C8BF-4ABB-A910-EFB80AFCD357}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7DD38CF8-C8BF-4ABB-A910-EFB80AFCD357}.Release|Any CPU.Build.0 = Release|Any CPU {BB1D59B7-85B5-45C7-91ED-A53C075A86DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BB1D59B7-85B5-45C7-91ED-A53C075A86DF}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB1D59B7-85B5-45C7-91ED-A53C075A86DF}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB1D59B7-85B5-45C7-91ED-A53C075A86DF}.Release|Any CPU.Build.0 = Release|Any CPU + {532835A9-D220-488A-95B2-CA09C8D02E51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {532835A9-D220-488A-95B2-CA09C8D02E51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {532835A9-D220-488A-95B2-CA09C8D02E51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {532835A9-D220-488A-95B2-CA09C8D02E51}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidConfiguration.cs b/src/DeepStack.CSharp.Sdk/Core/DeepStackConfiguration.cs similarity index 84% rename from src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidConfiguration.cs rename to src/DeepStack.CSharp.Sdk/Core/DeepStackConfiguration.cs index c301d9c..a6761c6 100644 --- a/src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidConfiguration.cs +++ b/src/DeepStack.CSharp.Sdk/Core/DeepStackConfiguration.cs @@ -1,17 +1,17 @@ using System.Configuration; -namespace GloballyPaid +namespace DeepStack.Core { /// /// Global configuration class for Globally Paid SDK settings /// - public static class GloballyPaidConfiguration + public static class DeepStackConfiguration { - private const string PUBLISHALE_API_KEY = "GloballyPaidPublishableApiKey"; - private const string SHARED_SECRET = "GloballyPaidSharedSecret"; - private const string APP_ID = "GloballyPaidAppId"; - private const string USE_SANDBOX = "GloballyPaidUseSandbox"; - private const string REQUEST_TIMEOUT_SECONDS = "GloballyPaidRequestTimeoutSeconds"; + private const string PUBLISHALE_API_KEY = "DeepStackPublishableApiKey"; + private const string SHARED_SECRET = "DeepStackSharedSecret"; + private const string APP_ID = "DeepStackAppId"; + private const string USE_SANDBOX = "DeepStackUseSandbox"; + private const string REQUEST_TIMEOUT_SECONDS = "DeepStackRequestTimeoutSeconds"; private static string publishableApiKey; private static string sharedSecret; @@ -22,14 +22,14 @@ public static class GloballyPaidConfiguration private static HttpServiceClient client; /// - /// Static method that can be used for globally configuring Globally Paid SDK settings + /// Static method that can be used for globally configuring DeepStack SDK settings /// - /// Globally Paid Publishable API Key - /// Globally Paid Shared Secret - /// Globally Paid APP ID - /// True if your service calls should go through the Globally Paid Sandbox API, - /// False if your service calls should go through the Globally Paid API - /// The request timeout (in seconds) of all Globally Paid Sandbox API service calls. Default is 30 seconds. + /// DeepStack Publishable API Key + /// DeepStack Shared Secret + /// DeepStack APP ID + /// True if your service calls should go through the DeepStack Sandbox API, + /// False if your service calls should go through the DeepStack API + /// The request timeout (in seconds) of all DeepStack Sandbox API service calls. Default is 30 seconds. public static void Setup(string publishableApiKey, string sharedSecret, string appId, bool? useSandbox = null, int? requestTimeoutSeconds = null) { PublishableApiKey = publishableApiKey; @@ -53,8 +53,8 @@ internal static HttpServiceClient Client { if (client == null) { - var baseUrl = UseSandbox ? GloballyPaidConstants.DefaultSandboxBaseUrl : GloballyPaidConstants.DefaultBaseUrl; - client = new HttpServiceClient(new HttpServiceClientConfiguration(baseUrl, GloballyPaidConstants.BearerAuthenticationScheme, PublishableApiKey, RequestTimeoutSeconds)); + var baseUrl = UseSandbox ? DeepStackConstants.DefaultSandboxBaseUrl : DeepStackConstants.DefaultBaseUrl; + client = new HttpServiceClient(new HttpServiceClientConfiguration(baseUrl, DeepStackConstants.BearerAuthenticationScheme, PublishableApiKey, RequestTimeoutSeconds)); } return client; diff --git a/src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidConstants.cs b/src/DeepStack.CSharp.Sdk/Core/DeepStackConstants.cs similarity index 88% rename from src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidConstants.cs rename to src/DeepStack.CSharp.Sdk/Core/DeepStackConstants.cs index ad1a70e..3f1e33d 100644 --- a/src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidConstants.cs +++ b/src/DeepStack.CSharp.Sdk/Core/DeepStackConstants.cs @@ -1,12 +1,12 @@ using System.Collections.Generic; using System.Net; -namespace GloballyPaid +namespace DeepStack.Core { - internal static class GloballyPaidConstants + internal static class DeepStackConstants { public const string DefaultBaseUrl = "https://api.globallypaid.com"; - public const string DefaultSandboxBaseUrl = "https://sandbox.api.globallypaid.com"; + public const string DefaultSandboxBaseUrl = "https://qa.api.globallypaid.com"; public static readonly string ApplicationJson = "application/json"; public static readonly string BearerAuthenticationScheme = "Bearer"; diff --git a/src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidException.cs b/src/DeepStack.CSharp.Sdk/Core/DeepStackException.cs similarity index 59% rename from src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidException.cs rename to src/DeepStack.CSharp.Sdk/Core/DeepStackException.cs index 828818e..1627a3e 100644 --- a/src/GloballyPaid.CSharp.Sdk/Core/GloballyPaidException.cs +++ b/src/DeepStack.CSharp.Sdk/Core/DeepStackException.cs @@ -1,26 +1,26 @@ using System; using System.Net; -namespace GloballyPaid +namespace DeepStack.Core { /// - /// Globally Paid custom exception class, thrown each time there is an error with some service call + /// DeepStack custom exception class, thrown each time there is an error with some service call /// - public class GloballyPaidException : Exception + public class DeepStackException : Exception { - public GloballyPaidException() + public DeepStackException() { } - public GloballyPaidException(string message) : base(message) + public DeepStackException(string message) : base(message) { } - public GloballyPaidException(string message, Exception innerException) : base(message, innerException) + public DeepStackException(string message, Exception innerException) : base(message, innerException) { } - public GloballyPaidException(HttpStatusCode httpStatusCode, string errorMessage, HttpServiceClientResponse globallyPaidResponse) + public DeepStackException(HttpStatusCode httpStatusCode, string errorMessage, HttpServiceClientResponse globallyPaidResponse) { HttpStatusCode = httpStatusCode; ErrorMessage = !string.IsNullOrWhiteSpace(errorMessage) ? errorMessage : GetErrorMessageFromStatusCode(httpStatusCode); @@ -44,8 +44,8 @@ public GloballyPaidException(HttpStatusCode httpStatusCode, string errorMessage, private string GetErrorMessageFromStatusCode(HttpStatusCode httpStatusCode) { - return GloballyPaidConstants.ErrorStatusCodes.ContainsKey(httpStatusCode) - ? GloballyPaidConstants.ErrorStatusCodes[httpStatusCode] + return DeepStackConstants.ErrorStatusCodes.ContainsKey(httpStatusCode) + ? DeepStackConstants.ErrorStatusCodes[httpStatusCode] : string.Empty; } } diff --git a/src/GloballyPaid.CSharp.Sdk/Core/HmacUtility.cs b/src/DeepStack.CSharp.Sdk/Core/HmacUtility.cs similarity index 98% rename from src/GloballyPaid.CSharp.Sdk/Core/HmacUtility.cs rename to src/DeepStack.CSharp.Sdk/Core/HmacUtility.cs index 19d9804..c50e546 100644 --- a/src/GloballyPaid.CSharp.Sdk/Core/HmacUtility.cs +++ b/src/DeepStack.CSharp.Sdk/Core/HmacUtility.cs @@ -2,7 +2,7 @@ using System.Security.Cryptography; using System.Text; -namespace GloballyPaid +namespace DeepStack.Core { /// /// HMAC Utility Class, used for HMACSHA256 hash generation diff --git a/src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClient.cs b/src/DeepStack.CSharp.Sdk/Core/HttpServiceClient.cs similarity index 86% rename from src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClient.cs rename to src/DeepStack.CSharp.Sdk/Core/HttpServiceClient.cs index c512997..ed18ebf 100644 --- a/src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClient.cs +++ b/src/DeepStack.CSharp.Sdk/Core/HttpServiceClient.cs @@ -1,12 +1,12 @@ -using Newtonsoft.Json; -using System; +using System; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading; using System.Threading.Tasks; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Core { public partial class HttpServiceClient : IDisposable { @@ -65,9 +65,10 @@ public TEntity Patch(string resourceUri, TData data, bool checkR .GetAwaiter().GetResult(); } - public void Delete(string resourceUri) + public bool Delete(string resourceUri) { - GetResponseMessageAsync(GetDeleteAction(resourceUri)).GetAwaiter().GetResult(); + var httpResponseMessage = GetResponseMessageAsync(GetDeleteAction(resourceUri)).GetAwaiter().GetResult(); + return httpResponseMessage.IsSuccessStatusCode; } private void InitializeHttpClient() @@ -84,7 +85,7 @@ private void InitializeHttpClient() { if (string.IsNullOrEmpty(Configuration.AuthenticationValue)) { - throw new GloballyPaidException("Your Globally Paid Token API Key is not configured"); + throw new DeepStackException("Your Globally Paid Token API Key is not configured"); } HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Configuration.AuthenticationScheme, Configuration.AuthenticationValue); @@ -93,19 +94,19 @@ private void InitializeHttpClient() private Func> GetPostAction(string resourceUri, TData data, CancellationToken cancellationToken = default) { - return x => x.PostAsync(resourceUri, new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, GloballyPaidConstants.ApplicationJson), cancellationToken); + return x => x.PostAsync(resourceUri, new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, DeepStackConstants.ApplicationJson), cancellationToken); } private Func> GetPutAction(string resourceUri, TData data, CancellationToken cancellationToken = default) { - return x => x.PutAsync(resourceUri, new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, GloballyPaidConstants.ApplicationJson), cancellationToken); + return x => x.PutAsync(resourceUri, new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, DeepStackConstants.ApplicationJson), cancellationToken); } private Func> GetPatchAction(string resourceUri, TData data, CancellationToken cancellationToken = default) { return x => x.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), resourceUri) { - Content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, GloballyPaidConstants.ApplicationJson) + Content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, DeepStackConstants.ApplicationJson) }, cancellationToken); } @@ -113,7 +114,7 @@ private Func> GetDeleteAction(string resou { return x => x.SendAsync(new HttpRequestMessage(HttpMethod.Delete, resourceUri) { - Content = new StringContent(JsonConvert.SerializeObject(string.Empty), Encoding.UTF8, GloballyPaidConstants.ApplicationJson) + Content = new StringContent(JsonConvert.SerializeObject(string.Empty), Encoding.UTF8, DeepStackConstants.ApplicationJson) }, cancellationToken); } diff --git a/src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientAsync.cs b/src/DeepStack.CSharp.Sdk/Core/HttpServiceClientAsync.cs similarity index 86% rename from src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientAsync.cs rename to src/DeepStack.CSharp.Sdk/Core/HttpServiceClientAsync.cs index f3fb308..0858f62 100644 --- a/src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientAsync.cs +++ b/src/DeepStack.CSharp.Sdk/Core/HttpServiceClientAsync.cs @@ -1,11 +1,11 @@ -using Newtonsoft.Json; -using System; +using System; using System.Net; using System.Net.Http; using System.Threading; using System.Threading.Tasks; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Core { public partial class HttpServiceClient { @@ -64,12 +64,12 @@ private async Task ReadResponseAsync(HttpResponseMessage respo catch (JsonException jex) { System.Diagnostics.Debug.Write($"Invalid response object {typeof(TEntity)} from API: \"{content}\", message: \"{jex.Message}\""); - throw new GloballyPaidException(responseMessage.StatusCode, $"Invalid response object from API: \"{content}\", message: \"{jex.Message}\"", globallyPaidResponse); + throw new DeepStackException(responseMessage.StatusCode, $"Invalid response object from API: \"{content}\", message: \"{jex.Message}\"", globallyPaidResponse); } } else { - throw new GloballyPaidException(responseMessage.StatusCode, content, globallyPaidResponse); + throw new DeepStackException(responseMessage.StatusCode, content, globallyPaidResponse); } } @@ -83,7 +83,7 @@ private void CheckResponseCode(string content, HttpServiceClientResponse globall } catch (JsonException jex) { - throw new GloballyPaidException(globallyPaidResponse.StatusCode, $"Invalid response object from API: \"{content}\", message: \"{jex.Message}\"", globallyPaidResponse); + throw new DeepStackException(globallyPaidResponse.StatusCode, $"Invalid response object from API: \"{content}\", message: \"{jex.Message}\"", globallyPaidResponse); } if (response != null @@ -91,7 +91,7 @@ private void CheckResponseCode(string content, HttpServiceClientResponse globall && !string.IsNullOrEmpty(response.message) && response.response_code != "00") { - throw new GloballyPaidException(HttpStatusCode.BadRequest, response.message, globallyPaidResponse); + throw new DeepStackException(HttpStatusCode.BadRequest, response.message, globallyPaidResponse); } } } diff --git a/src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientConfiguration.cs b/src/DeepStack.CSharp.Sdk/Core/HttpServiceClientConfiguration.cs similarity index 78% rename from src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientConfiguration.cs rename to src/DeepStack.CSharp.Sdk/Core/HttpServiceClientConfiguration.cs index a3f5827..2a139f8 100644 --- a/src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientConfiguration.cs +++ b/src/DeepStack.CSharp.Sdk/Core/HttpServiceClientConfiguration.cs @@ -1,12 +1,12 @@ -namespace GloballyPaid +namespace DeepStack.Core { public class HttpServiceClientConfiguration { public HttpServiceClientConfiguration(string baseUrl) { BaseUrl = baseUrl; - AcceptsMimeType = GloballyPaidConstants.ApplicationJson; - TimeoutSeconds = GloballyPaidConstants.DefaultTimoutSeconds; + AcceptsMimeType = DeepStackConstants.ApplicationJson; + TimeoutSeconds = DeepStackConstants.DefaultTimoutSeconds; } public HttpServiceClientConfiguration(string baseUrl, string acceptsMimeType) @@ -18,7 +18,7 @@ public HttpServiceClientConfiguration(string baseUrl, string acceptsMimeType) public HttpServiceClientConfiguration(string baseUrl, int? timeoutSeconds) : this(baseUrl) { - TimeoutSeconds = timeoutSeconds ?? GloballyPaidConstants.DefaultTimoutSeconds; + TimeoutSeconds = timeoutSeconds ?? DeepStackConstants.DefaultTimoutSeconds; } public HttpServiceClientConfiguration(string baseUrl, string acceptsMimeType, int timeoutSeconds) @@ -27,14 +27,14 @@ public HttpServiceClientConfiguration(string baseUrl, string acceptsMimeType, in TimeoutSeconds = timeoutSeconds; } - public HttpServiceClientConfiguration(string baseUrl, string authenticationScheme, string authenticationValue, int timeoutSeconds = GloballyPaidConstants.DefaultTimoutSeconds) + public HttpServiceClientConfiguration(string baseUrl, string authenticationScheme, string authenticationValue, int timeoutSeconds = DeepStackConstants.DefaultTimoutSeconds) : this(baseUrl) { AuthenticationScheme = authenticationScheme; AuthenticationValue = authenticationValue; TimeoutSeconds = timeoutSeconds != default ? timeoutSeconds - : GloballyPaidConstants.DefaultTimoutSeconds; + : DeepStackConstants.DefaultTimoutSeconds; } public string BaseUrl { get; set; } diff --git a/src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientResponse.cs b/src/DeepStack.CSharp.Sdk/Core/HttpServiceClientResponse.cs similarity index 97% rename from src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientResponse.cs rename to src/DeepStack.CSharp.Sdk/Core/HttpServiceClientResponse.cs index cabdba3..b8475a7 100644 --- a/src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientResponse.cs +++ b/src/DeepStack.CSharp.Sdk/Core/HttpServiceClientResponse.cs @@ -1,7 +1,7 @@ using System.Net; using System.Net.Http.Headers; -namespace GloballyPaid +namespace DeepStack.Core { public class HttpServiceClientResponse { diff --git a/src/GloballyPaid.CSharp.Sdk/GloballyPaid.CSharp.Sdk.csproj b/src/DeepStack.CSharp.Sdk/DeepStack.CSharp.Sdk.csproj similarity index 86% rename from src/GloballyPaid.CSharp.Sdk/GloballyPaid.CSharp.Sdk.csproj rename to src/DeepStack.CSharp.Sdk/DeepStack.CSharp.Sdk.csproj index 4b1469d..3ff4d1a 100644 --- a/src/GloballyPaid.CSharp.Sdk/GloballyPaid.CSharp.Sdk.csproj +++ b/src/DeepStack.CSharp.Sdk/DeepStack.CSharp.Sdk.csproj @@ -1,8 +1,8 @@ - netstandard2.0 - GloballyPaid + net6.0 + DeepStack true false GloballyPaid.net @@ -18,7 +18,7 @@ Supporting .NET Standard 2.0 - + diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Base/Entity.cs b/src/DeepStack.CSharp.Sdk/Entities/Base/Entity.cs similarity index 80% rename from src/GloballyPaid.CSharp.Sdk/Entities/Base/Entity.cs rename to src/DeepStack.CSharp.Sdk/Entities/Base/Entity.cs index 76ba30c..54125a5 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Base/Entity.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Base/Entity.cs @@ -1,4 +1,6 @@ -namespace GloballyPaid +using DeepStack.Extensions; + +namespace DeepStack.Entities.Base { /// /// Base class for all Globally Paid entities diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Capture.cs b/src/DeepStack.CSharp.Sdk/Entities/Capture.cs similarity index 84% rename from src/GloballyPaid.CSharp.Sdk/Entities/Capture.cs rename to src/DeepStack.CSharp.Sdk/Entities/Capture.cs index 454dc56..81097a2 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Capture.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Capture.cs @@ -1,7 +1,8 @@ -using Newtonsoft.Json; -using System; +using System; +using DeepStack.Entities.Base; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities { public class Capture : Entity { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/CardinalMPIResponse.cs b/src/DeepStack.CSharp.Sdk/Entities/CardinalMPIResponse.cs similarity index 99% rename from src/GloballyPaid.CSharp.Sdk/Entities/CardinalMPIResponse.cs rename to src/DeepStack.CSharp.Sdk/Entities/CardinalMPIResponse.cs index e0c2b7d..6e6db84 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/CardinalMPIResponse.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/CardinalMPIResponse.cs @@ -1,7 +1,7 @@ using System.Xml.Serialization; using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities { public class CardinalMPIResponse { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/ChargeResponse.cs b/src/DeepStack.CSharp.Sdk/Entities/ChargeResponse.cs similarity index 92% rename from src/GloballyPaid.CSharp.Sdk/Entities/ChargeResponse.cs rename to src/DeepStack.CSharp.Sdk/Entities/ChargeResponse.cs index 7bae1ea..1db9765 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/ChargeResponse.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/ChargeResponse.cs @@ -1,11 +1,12 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; -using GloballyPaid.Interface; +using DeepStack.Entities.Common; +using DeepStack.Entities.Interface; +using DeepStack.Enums; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; -namespace GloballyPaid +namespace DeepStack.Entities { public class ChargeResponse { @@ -18,8 +19,8 @@ public class ChargeResponse [JsonProperty("source")] [Description("The payment source that was charged")] - [JsonConverter(typeof(PaymentInstrumentJsonConverter))] - public IPaymentInstrument Source{ get; set; } + [JsonConverter(typeof(PaymentSourceJsonConverter))] + public IPaymentSource Source{ get; set; } [JsonProperty("amount")] [Description("The original amount of the transaction in cents")] diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Address.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/Address.cs similarity index 79% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/Address.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/Address.cs index 3cb5910..a757b74 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Address.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/Address.cs @@ -1,6 +1,8 @@ -using Newtonsoft.Json; +using DeepStack.Entities.Base; +using DeepStack.Enums; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class Address : Entity { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/BillingContact.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/BillingContact.cs similarity index 75% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/BillingContact.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/BillingContact.cs index 119798a..5cb3898 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/BillingContact.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/BillingContact.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class BillingContact : Contact { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Checks.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/Checks.cs similarity index 93% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/Checks.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/Checks.cs index 548f0c2..f45b6bb 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Checks.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/Checks.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class Checks { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Contact.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/Contact.cs similarity index 82% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/Contact.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/Contact.cs index 2a265c2..06e0dfa 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Contact.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/Contact.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json; +using DeepStack.Entities.Base; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class Contact : Entity { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/CreditCard.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/CreditCard.cs similarity index 95% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/CreditCard.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/CreditCard.cs index dbba02b..c7f2bf0 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/CreditCard.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/CreditCard.cs @@ -1,7 +1,8 @@ using System.ComponentModel; +using DeepStack.Entities.Base; using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class CreditCard : Entity { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Error.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/Error.cs similarity index 91% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/Error.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/Error.cs index 7a7f69e..99fd5d2 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Error.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/Error.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class Error { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Fee.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/Fee.cs similarity index 75% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/Fee.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/Fee.cs index 9873995..0ce9f4e 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/Fee.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/Fee.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json; +using DeepStack.Entities.Base; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class Fee : Entity { diff --git a/src/DeepStack.CSharp.Sdk/Entities/Common/JSCommon/ClientAddress.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/JSCommon/ClientAddress.cs new file mode 100644 index 0000000..3040661 --- /dev/null +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/JSCommon/ClientAddress.cs @@ -0,0 +1,28 @@ +using DeepStack.Enums; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace DeepStack.Entities.Common.JSCommon +{ + public class ClientAddress + { + [JsonProperty("lineOne")] + public string Line1 { get; set; } + + [JsonProperty("lineTwo")] + public string Line2 { get; set; } + + [JsonProperty("city")] + public string City { get; set; } + + [JsonProperty("state")] + public string State { get; set; } + + [JsonProperty("postalCode")] + public string PostalCode { get; set; } + + [JsonProperty("country")] + [JsonConverter(typeof(StringEnumConverter))] + public ISO3166CountryCode CountryCode { get; set; } + } +} \ No newline at end of file diff --git a/src/DeepStack.CSharp.Sdk/Entities/Common/JSCommon/ClientBillingContact.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/JSCommon/ClientBillingContact.cs new file mode 100644 index 0000000..514978d --- /dev/null +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/JSCommon/ClientBillingContact.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace DeepStack.Entities.Common.JSCommon +{ + public class ClientBillingContact + { + [JsonProperty("firstName")] + public string FirstName { get; set; } + + [JsonProperty("lastName")] + public string LastName { get; set; } + + [JsonProperty("address")] + public ClientAddress Address { get; set; } + + [JsonProperty("phone")] + public string Phone { get; set; } + + [JsonProperty("email")] + public string Email { get; set; } + } +} \ No newline at end of file diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/PaymentInstrument.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/PaymentInstrument.cs similarity index 92% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/PaymentInstrument.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/PaymentInstrument.cs index 83d4ec3..38dae27 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/PaymentInstrument.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/PaymentInstrument.cs @@ -1,9 +1,10 @@ -using Newtonsoft.Json; +using System; +using DeepStack.Entities.Interface; +using DeepStack.Enums; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using System; -using GloballyPaid.Interface; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public abstract class PaymentInstrument : IPaymentInstrument { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/ShippingContact.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/ShippingContact.cs similarity index 65% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/ShippingContact.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/ShippingContact.cs index 1cbcaff..98525da 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/ShippingContact.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/ShippingContact.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class ShippingContact : Contact { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/TransactionMeta.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/TransactionMeta.cs similarity index 97% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/TransactionMeta.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/TransactionMeta.cs index 030a2d7..cd5c29c 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/TransactionMeta.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/TransactionMeta.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class TransactionMeta { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Common/TransactionParameters.cs b/src/DeepStack.CSharp.Sdk/Entities/Common/TransactionParameters.cs similarity index 97% rename from src/GloballyPaid.CSharp.Sdk/Entities/Common/TransactionParameters.cs rename to src/DeepStack.CSharp.Sdk/Entities/Common/TransactionParameters.cs index 4b08dc8..afa6ad2 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Common/TransactionParameters.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Common/TransactionParameters.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; +using DeepStack.Enums; using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace GloballyPaid +namespace DeepStack.Entities.Common { public class TransactionParameters { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Customer.cs b/src/DeepStack.CSharp.Sdk/Entities/Customer.cs similarity index 71% rename from src/GloballyPaid.CSharp.Sdk/Entities/Customer.cs rename to src/DeepStack.CSharp.Sdk/Entities/Customer.cs index 5942385..9d1c918 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Customer.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Customer.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json; +using DeepStack.Entities.Common; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities { public class Customer : Contact { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Interface/IPaymentInstrument.cs b/src/DeepStack.CSharp.Sdk/Entities/Interface/IPaymentInstrument.cs similarity index 78% rename from src/GloballyPaid.CSharp.Sdk/Entities/Interface/IPaymentInstrument.cs rename to src/DeepStack.CSharp.Sdk/Entities/Interface/IPaymentInstrument.cs index dbc3cea..d42d72c 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Interface/IPaymentInstrument.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Interface/IPaymentInstrument.cs @@ -1,6 +1,8 @@ +using DeepStack.Entities.Common; +using DeepStack.Enums; using Newtonsoft.Json; -namespace GloballyPaid.Interface +namespace DeepStack.Entities.Interface { [JsonConverter(typeof(PaymentInstrumentJsonConverter))] public interface IPaymentInstrument diff --git a/src/DeepStack.CSharp.Sdk/Entities/Interface/IPaymentSource.cs b/src/DeepStack.CSharp.Sdk/Entities/Interface/IPaymentSource.cs new file mode 100644 index 0000000..b0cc821 --- /dev/null +++ b/src/DeepStack.CSharp.Sdk/Entities/Interface/IPaymentSource.cs @@ -0,0 +1,11 @@ +using DeepStack.Enums; +using Newtonsoft.Json; + +namespace DeepStack.Entities.Interface +{ + [JsonConverter(typeof(PaymentSourceJsonConverter))] + public interface IPaymentSource + { + PaymentSourceType Type { get; set; } + } +} \ No newline at end of file diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/ModelBinderJsonConverter.cs b/src/DeepStack.CSharp.Sdk/Entities/ModelBinderJsonConverter.cs similarity index 97% rename from src/GloballyPaid.CSharp.Sdk/Entities/ModelBinderJsonConverter.cs rename to src/DeepStack.CSharp.Sdk/Entities/ModelBinderJsonConverter.cs index 907254e..9f80e2b 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/ModelBinderJsonConverter.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/ModelBinderJsonConverter.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace GloballyPaid +namespace DeepStack.Entities { public abstract class ModelBinderJsonConverter : JsonConverter { diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/PaymentInstrumentCardOnFile.cs b/src/DeepStack.CSharp.Sdk/Entities/PaymentInstrumentCardOnFile.cs similarity index 98% rename from src/GloballyPaid.CSharp.Sdk/Entities/PaymentInstrumentCardOnFile.cs rename to src/DeepStack.CSharp.Sdk/Entities/PaymentInstrumentCardOnFile.cs index 1495025..7bee20f 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/PaymentInstrumentCardOnFile.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/PaymentInstrumentCardOnFile.cs @@ -1,7 +1,9 @@ using System; +using DeepStack.Entities.Common; +using DeepStack.Enums; using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities { public class PaymentInstrumentCardOnFile : PaymentInstrument diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/PaymentInstrumentJsonConverter.cs b/src/DeepStack.CSharp.Sdk/Entities/PaymentInstrumentJsonConverter.cs similarity index 92% rename from src/GloballyPaid.CSharp.Sdk/Entities/PaymentInstrumentJsonConverter.cs rename to src/DeepStack.CSharp.Sdk/Entities/PaymentInstrumentJsonConverter.cs index 507a3b6..637b6eb 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/PaymentInstrumentJsonConverter.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/PaymentInstrumentJsonConverter.cs @@ -1,7 +1,8 @@ using System; +using DeepStack.Entities.Common; using Newtonsoft.Json.Linq; -namespace GloballyPaid +namespace DeepStack.Entities { public class PaymentInstrumentJsonConverter : ModelBinderJsonConverter { diff --git a/src/DeepStack.CSharp.Sdk/Entities/PaymentSourceJsonConverter.cs b/src/DeepStack.CSharp.Sdk/Entities/PaymentSourceJsonConverter.cs new file mode 100644 index 0000000..335ddc7 --- /dev/null +++ b/src/DeepStack.CSharp.Sdk/Entities/PaymentSourceJsonConverter.cs @@ -0,0 +1,23 @@ +using System; +using DeepStack.Requests; +using Newtonsoft.Json.Linq; + +namespace DeepStack.Entities +{ + public class PaymentSourceJsonConverter: ModelBinderJsonConverter + { + protected override PaymentSource Create(Type objType, JObject jObject) + { + if (objType == null) throw new ArgumentNullException(nameof(objType)); + + // backwards compatible JSON names for JS SDK + if (jObject["type"] != null && jObject["type"].Value().Equals("credit_card", StringComparison.OrdinalIgnoreCase)) + return new PaymentSourceRawCard(); + + if (jObject["type"] != null && jObject["type"].Value().Equals("card_on_file", StringComparison.OrdinalIgnoreCase)) + return new PaymentSourceCardOnFile(); + + return null; + } + } +} diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Refund.cs b/src/DeepStack.CSharp.Sdk/Entities/Refund.cs similarity index 87% rename from src/GloballyPaid.CSharp.Sdk/Entities/Refund.cs rename to src/DeepStack.CSharp.Sdk/Entities/Refund.cs index fe8e38a..990a024 100644 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Refund.cs +++ b/src/DeepStack.CSharp.Sdk/Entities/Refund.cs @@ -1,7 +1,8 @@ -using Newtonsoft.Json; -using System; +using System; +using DeepStack.Entities.Base; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Entities { public class Refund : Entity { diff --git a/src/GloballyPaid.CSharp.Sdk/Enums/CofType.cs b/src/DeepStack.CSharp.Sdk/Enums/CofType.cs similarity index 82% rename from src/GloballyPaid.CSharp.Sdk/Enums/CofType.cs rename to src/DeepStack.CSharp.Sdk/Enums/CofType.cs index 2db8106..ea6a7eb 100644 --- a/src/GloballyPaid.CSharp.Sdk/Enums/CofType.cs +++ b/src/DeepStack.CSharp.Sdk/Enums/CofType.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Enums { public enum CofType { diff --git a/src/GloballyPaid.CSharp.Sdk/Enums/CountryCode.cs b/src/DeepStack.CSharp.Sdk/Enums/CountryCode.cs similarity index 99% rename from src/GloballyPaid.CSharp.Sdk/Enums/CountryCode.cs rename to src/DeepStack.CSharp.Sdk/Enums/CountryCode.cs index 14248e0..cb2f0bd 100644 --- a/src/GloballyPaid.CSharp.Sdk/Enums/CountryCode.cs +++ b/src/DeepStack.CSharp.Sdk/Enums/CountryCode.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Enums { public enum CountryCode { diff --git a/src/GloballyPaid.CSharp.Sdk/Enums/CurrencyCode.cs b/src/DeepStack.CSharp.Sdk/Enums/CurrencyCode.cs similarity index 88% rename from src/GloballyPaid.CSharp.Sdk/Enums/CurrencyCode.cs rename to src/DeepStack.CSharp.Sdk/Enums/CurrencyCode.cs index 6d2853e..01e8777 100644 --- a/src/GloballyPaid.CSharp.Sdk/Enums/CurrencyCode.cs +++ b/src/DeepStack.CSharp.Sdk/Enums/CurrencyCode.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Enums { public enum CurrencyCode { diff --git a/src/GloballyPaid.CSharp.Sdk/Enums/ISO3166CountryCode.cs b/src/DeepStack.CSharp.Sdk/Enums/ISO3166CountryCode.cs similarity index 99% rename from src/GloballyPaid.CSharp.Sdk/Enums/ISO3166CountryCode.cs rename to src/DeepStack.CSharp.Sdk/Enums/ISO3166CountryCode.cs index 854218d..63bd81b 100644 --- a/src/GloballyPaid.CSharp.Sdk/Enums/ISO3166CountryCode.cs +++ b/src/DeepStack.CSharp.Sdk/Enums/ISO3166CountryCode.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Enums { public enum ISO3166CountryCode { diff --git a/src/GloballyPaid.CSharp.Sdk/Enums/PaymentSourceType.cs b/src/DeepStack.CSharp.Sdk/Enums/PaymentSourceType.cs similarity index 76% rename from src/GloballyPaid.CSharp.Sdk/Enums/PaymentSourceType.cs rename to src/DeepStack.CSharp.Sdk/Enums/PaymentSourceType.cs index b388364..78091ff 100644 --- a/src/GloballyPaid.CSharp.Sdk/Enums/PaymentSourceType.cs +++ b/src/DeepStack.CSharp.Sdk/Enums/PaymentSourceType.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Enums { public enum PaymentSourceType { diff --git a/src/GloballyPaid.CSharp.Sdk/Enums/PaymentType.cs b/src/DeepStack.CSharp.Sdk/Enums/PaymentType.cs similarity index 89% rename from src/GloballyPaid.CSharp.Sdk/Enums/PaymentType.cs rename to src/DeepStack.CSharp.Sdk/Enums/PaymentType.cs index 2df39d1..3bd256c 100644 --- a/src/GloballyPaid.CSharp.Sdk/Enums/PaymentType.cs +++ b/src/DeepStack.CSharp.Sdk/Enums/PaymentType.cs @@ -1,6 +1,6 @@ using System.Runtime.Serialization; -namespace GloballyPaid +namespace DeepStack.Enums { public enum PaymentType { diff --git a/src/GloballyPaid.CSharp.Sdk/Extensions/Extensions.cs b/src/DeepStack.CSharp.Sdk/Extensions/Extensions.cs similarity index 81% rename from src/GloballyPaid.CSharp.Sdk/Extensions/Extensions.cs rename to src/DeepStack.CSharp.Sdk/Extensions/Extensions.cs index 95ca1ed..6331e7f 100644 --- a/src/GloballyPaid.CSharp.Sdk/Extensions/Extensions.cs +++ b/src/DeepStack.CSharp.Sdk/Extensions/Extensions.cs @@ -1,7 +1,10 @@ -using Microsoft.Extensions.DependencyInjection; +using DeepStack.Core; +using DeepStack.Services.v1; +using DeepStack.Services.v1.Interfaces; +using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Extensions { public static class Extensions { @@ -37,12 +40,12 @@ public static string CreateHMAC(this object obj, string sharedSecret, string app { if (string.IsNullOrEmpty(sharedSecret)) { - throw new GloballyPaidException("Your Globally Paid Shared Secret is not configured"); + throw new DeepStackException("Your DeepStack Shared Secret is not configured"); } if (string.IsNullOrEmpty(appId)) { - throw new GloballyPaidException("Your Globally Paid APP ID is not configured"); + throw new DeepStackException("Your DeepStack APP ID is not configured"); } return HmacUtility.CreateHmacHeader(obj.ToJson(), sharedSecret, appId); @@ -60,11 +63,11 @@ public static string CreateHMAC(this object obj, string sharedSecret, string app /// False if your service calls should go through the Globally Paid API /// The request timeout (in seconds) of all Globally Paid Sandbox API service calls. Default is 30 seconds. /// An services collection, with configured Globally Paid SDK settings and all Globally Paid services registered. - public static IServiceCollection AddGloballyPaid(this IServiceCollection services, string publishableApiKey, string sharedSecret, string appId, bool? useSandbox = null, int? requestTimeoutSeconds = null) + public static IServiceCollection AddDeepStack(this IServiceCollection services, string publishableApiKey, string sharedSecret, string appId, bool? useSandbox = null, int? requestTimeoutSeconds = null) { - GloballyPaidConfiguration.Setup(publishableApiKey, sharedSecret, appId, useSandbox, requestTimeoutSeconds); + DeepStackConfiguration.Setup(publishableApiKey, sharedSecret, appId, useSandbox, requestTimeoutSeconds); - return AddGloballyPaidServices(services); + return AddDeepStack(services); } /// @@ -72,7 +75,7 @@ public static IServiceCollection AddGloballyPaid(this IServiceCollection service /// /// the services /// An services collection, with all Globally Paid services registered. - public static IServiceCollection AddGloballyPaidServices(this IServiceCollection services) + public static IServiceCollection AddDeepStack(this IServiceCollection services) { services.AddScoped(); services.AddScoped(); diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/Base/Request.cs b/src/DeepStack.CSharp.Sdk/Requests/Base/Request.cs similarity index 79% rename from src/GloballyPaid.CSharp.Sdk/Requests/Base/Request.cs rename to src/DeepStack.CSharp.Sdk/Requests/Base/Request.cs index 21cdfe0..8a4b025 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/Base/Request.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/Base/Request.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Requests.Base { /// /// Base class for all Globally Paid service call requests diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/Base/RequestOptions.cs b/src/DeepStack.CSharp.Sdk/Requests/Base/RequestOptions.cs similarity index 99% rename from src/GloballyPaid.CSharp.Sdk/Requests/Base/RequestOptions.cs rename to src/DeepStack.CSharp.Sdk/Requests/Base/RequestOptions.cs index 2bbb0e4..1a0e0e6 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/Base/RequestOptions.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/Base/RequestOptions.cs @@ -1,4 +1,4 @@ -namespace GloballyPaid +namespace DeepStack.Requests.Base { /// /// Class used to perform per-request configuration of Globally Paid SDK settings diff --git a/src/DeepStack.CSharp.Sdk/Requests/BaseTokenResponse.cs b/src/DeepStack.CSharp.Sdk/Requests/BaseTokenResponse.cs new file mode 100644 index 0000000..687d0a0 --- /dev/null +++ b/src/DeepStack.CSharp.Sdk/Requests/BaseTokenResponse.cs @@ -0,0 +1,156 @@ +using DeepStack.Entities; +using DeepStack.Entities.Common.JSCommon; +using Newtonsoft.Json; + +namespace DeepStack.Requests +{ + public class BaseTokenResponse + { + + /// + /// Set amount in the JS before sending to us or use an amount from elsewhere... + /// + [JsonProperty("amount")] + public int Amount { get; set; } + + [JsonProperty("token")] + public string ID { get; set; } + + + // /// + // /// Customer Id + // /// + // [JsonProperty("customer_id")] + // public string CustomerId { get; set; } + // + // /// + // /// Client Id + // /// + // [JsonIgnore] + // [JsonProperty("client_id")] + // public string ClientId { get; set; } + // + // /// + // /// ClientCustomer Id + // /// + // [JsonProperty("client_customer_id", NullValueHandling = NullValueHandling.Ignore)] + // public string ClientCustomerId { get; set; } + + /// + /// The brand of the credit card, eg: Visa, Mastercard, Discover, Amex + /// + [JsonProperty("brand", NullValueHandling = NullValueHandling.Ignore)] + public string Brand { get; set; } + + /// + /// The BIN of the account number + /// + [JsonProperty("bin")] + public string Bin { get; set; } + + /// + /// The last four digits of the account number + /// + [JsonProperty("lastFour")] + public string LastFour { get; set; } + + /// + /// Full PAN for companies where return full pan is enabled + /// + [JsonProperty("pan", NullValueHandling = NullValueHandling.Ignore)] + public string PAN { get; set; } + + /// + /// If a card, the card expiration. Blank if BankAccount. + /// + [JsonProperty("expiration")] + public string Expiration { get; set; } + + /// + /// Card CVV + /// + [JsonProperty("cvv", NullValueHandling = NullValueHandling.Ignore)] + public string CVV { get; set; } + + /// + /// Provided from JS SDK for third party fraud checks. + /// + [JsonIgnore] + [JsonProperty("kount_session_id")] + public string KountSessionId { get; set; } + + /// + /// Billing Contact + /// + [JsonProperty("billingContact")] + public ClientBillingContact BillingContact { get; set; } + + /// + /// Shipping address + /// + [JsonProperty("shippingContact", NullValueHandling = NullValueHandling.Ignore)] + public ClientAddress ShippingContact { get; set; } + + // /// + // /// Created + // /// + // [JsonProperty("created")] + // public DateTime Created { get; set; } + // + // /// + // /// Updated + // /// + // [JsonProperty("updated")] + // public DateTime Updated { get; set; } + + // /// + // /// Data + // /// + // [JsonIgnore] + // [JsonProperty("data")] + // public string Data { get; set; } + + // /// + // /// Checks + // /// + // [JsonProperty("is_default")] + // public bool IsDefault { get; set; } + + // /// + // /// V1 Legacy Token + // /// + // [JsonProperty("v1_legacy_token", NullValueHandling = NullValueHandling.Ignore)] + // public string V1LegacyToken { get; set; } + + + /// + /// TokenEx Token + /// + [JsonProperty("tokenExToken", NullValueHandling = NullValueHandling.Ignore)] + public string TokenExToken { get; set; } + + /// + /// Cardinal's cmpi_lookup response if required. + /// + [JsonProperty("cmpi_lookup_response", NullValueHandling = NullValueHandling.Ignore)] + public CardinalMPIResponse CardinalMPI { get; set; } + + /// + /// CAVV returned from Cardinal + /// + [JsonProperty("cavv", NullValueHandling = NullValueHandling.Ignore)] + public string CAVV { get; set; } + + /// + /// EciFlag returned from Cardinal + /// + [JsonProperty("eciflag", NullValueHandling = NullValueHandling.Ignore)] + public string ECIFlag { get; set; } + + /// + /// Xid returned from Cardinal (Only applicable for AMEX) + /// + [JsonProperty("xid", NullValueHandling = NullValueHandling.Ignore)] + public string Xid { get; set; } + } +} \ No newline at end of file diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/CaptureRequest.cs b/src/DeepStack.CSharp.Sdk/Requests/CaptureRequest.cs similarity index 70% rename from src/GloballyPaid.CSharp.Sdk/Requests/CaptureRequest.cs rename to src/DeepStack.CSharp.Sdk/Requests/CaptureRequest.cs index 82a4a8c..3a17cc1 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/CaptureRequest.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/CaptureRequest.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json; +using DeepStack.Requests.Base; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Requests { public class CaptureRequest : Request { diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/ChargeRequest.cs b/src/DeepStack.CSharp.Sdk/Requests/ChargeRequest.cs similarity index 74% rename from src/GloballyPaid.CSharp.Sdk/Requests/ChargeRequest.cs rename to src/DeepStack.CSharp.Sdk/Requests/ChargeRequest.cs index bc7d456..8aa839a 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/ChargeRequest.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/ChargeRequest.cs @@ -1,9 +1,9 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.Collections.Generic; -using GloballyPaid.Interface; +using DeepStack.Entities.Common; +using DeepStack.Entities.Interface; +using DeepStack.Requests.Base; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Requests { public class ChargeRequest : Request { diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/PaymentInstrumentRequest.cs b/src/DeepStack.CSharp.Sdk/Requests/PaymentInstrumentRequest.cs similarity index 82% rename from src/GloballyPaid.CSharp.Sdk/Requests/PaymentInstrumentRequest.cs rename to src/DeepStack.CSharp.Sdk/Requests/PaymentInstrumentRequest.cs index 7da9e23..ca57981 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/PaymentInstrumentRequest.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/PaymentInstrumentRequest.cs @@ -1,7 +1,10 @@ -using Newtonsoft.Json; +using DeepStack.Entities.Common; +using DeepStack.Enums; +using DeepStack.Requests.Base; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace GloballyPaid +namespace DeepStack.Requests { public class PaymentInstrumentRequest : Request { diff --git a/src/DeepStack.CSharp.Sdk/Requests/PaymentInstrumentTokenRequest.cs b/src/DeepStack.CSharp.Sdk/Requests/PaymentInstrumentTokenRequest.cs new file mode 100644 index 0000000..ddd3a8c --- /dev/null +++ b/src/DeepStack.CSharp.Sdk/Requests/PaymentInstrumentTokenRequest.cs @@ -0,0 +1,17 @@ +using DeepStack.Requests.Base; +using Newtonsoft.Json; + +namespace DeepStack.Requests +{ + public class PaymentInstrumentTokenRequest : Request + { + + [JsonProperty("source")] + public string Token { get; set; } + + [JsonProperty("client_customer_id")] + public string ClientCustomerId { get; set; } + + } +} + diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/PaymentSource.cs b/src/DeepStack.CSharp.Sdk/Requests/PaymentSource.cs similarity index 78% rename from src/GloballyPaid.CSharp.Sdk/Requests/PaymentSource.cs rename to src/DeepStack.CSharp.Sdk/Requests/PaymentSource.cs index 061bfb3..d900743 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/PaymentSource.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/PaymentSource.cs @@ -1,8 +1,10 @@ -using GloballyPaid.Interface; +using DeepStack.Entities.Common; +using DeepStack.Entities.Interface; +using DeepStack.Enums; using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace GloballyPaid +namespace DeepStack.Requests { public class PaymentSource : IPaymentSource { diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/PaymentSourceCardOnFile.cs b/src/DeepStack.CSharp.Sdk/Requests/PaymentSourceCardOnFile.cs similarity index 73% rename from src/GloballyPaid.CSharp.Sdk/Requests/PaymentSourceCardOnFile.cs rename to src/DeepStack.CSharp.Sdk/Requests/PaymentSourceCardOnFile.cs index 964d270..05f3733 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/PaymentSourceCardOnFile.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/PaymentSourceCardOnFile.cs @@ -1,7 +1,8 @@ using System.ComponentModel; +using DeepStack.Enums; using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Requests { public class PaymentSourceCardOnFile : PaymentSource { @@ -22,5 +23,9 @@ public class CardOnFile [JsonProperty("cvv")] [Description("The CVV or CVC code usually on the back of the card")] public string CVV { get; set; } + + [JsonProperty("customer_id")] + [Description("Legacy customer ID, value doesn't matter but we need something")] + public string CustomerID = "Deprecated"; } } \ No newline at end of file diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/PaymentSourceRawCard.cs b/src/DeepStack.CSharp.Sdk/Requests/PaymentSourceRawCard.cs similarity index 78% rename from src/GloballyPaid.CSharp.Sdk/Requests/PaymentSourceRawCard.cs rename to src/DeepStack.CSharp.Sdk/Requests/PaymentSourceRawCard.cs index b8a8ad7..e6e19d0 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/PaymentSourceRawCard.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/PaymentSourceRawCard.cs @@ -1,6 +1,8 @@ +using DeepStack.Entities.Common; +using DeepStack.Enums; using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Requests { public class PaymentSourceRawCard : PaymentSource { diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/RefundRequest.cs b/src/DeepStack.CSharp.Sdk/Requests/RefundRequest.cs similarity index 70% rename from src/GloballyPaid.CSharp.Sdk/Requests/RefundRequest.cs rename to src/DeepStack.CSharp.Sdk/Requests/RefundRequest.cs index b49698a..e51bd86 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/RefundRequest.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/RefundRequest.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json; +using DeepStack.Requests.Base; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Requests { public class RefundRequest : Request { diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/TokenizeRequest.cs b/src/DeepStack.CSharp.Sdk/Requests/TokenizeRequest.cs similarity index 80% rename from src/GloballyPaid.CSharp.Sdk/Requests/TokenizeRequest.cs rename to src/DeepStack.CSharp.Sdk/Requests/TokenizeRequest.cs index c03af97..a7f3dc6 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/TokenizeRequest.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/TokenizeRequest.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json; +using DeepStack.Requests.Base; +using Newtonsoft.Json; -namespace GloballyPaid +namespace DeepStack.Requests { public class TokenizeRequest : Request { diff --git a/src/GloballyPaid.CSharp.Sdk/Requests/UpdatePaymentInstrumentRequest.cs b/src/DeepStack.CSharp.Sdk/Requests/UpdatePaymentInstrumentRequest.cs similarity index 80% rename from src/GloballyPaid.CSharp.Sdk/Requests/UpdatePaymentInstrumentRequest.cs rename to src/DeepStack.CSharp.Sdk/Requests/UpdatePaymentInstrumentRequest.cs index 7553e14..f9887d9 100644 --- a/src/GloballyPaid.CSharp.Sdk/Requests/UpdatePaymentInstrumentRequest.cs +++ b/src/DeepStack.CSharp.Sdk/Requests/UpdatePaymentInstrumentRequest.cs @@ -1,7 +1,10 @@ -using Newtonsoft.Json; +using DeepStack.Entities.Common; +using DeepStack.Enums; +using DeepStack.Requests.Base; +using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace GloballyPaid +namespace DeepStack.Requests { public class UpdatePaymentInstrumentRequest : Request { diff --git a/src/GloballyPaid.CSharp.Sdk/Services/Base/Service.cs b/src/DeepStack.CSharp.Sdk/Services/Base/Service.cs similarity index 72% rename from src/GloballyPaid.CSharp.Sdk/Services/Base/Service.cs rename to src/DeepStack.CSharp.Sdk/Services/Base/Service.cs index 375bf71..60bb65c 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/Base/Service.cs +++ b/src/DeepStack.CSharp.Sdk/Services/Base/Service.cs @@ -1,7 +1,9 @@ using System; using System.Net.Http.Headers; +using DeepStack.Core; +using DeepStack.Requests.Base; -namespace GloballyPaid +namespace DeepStack.Services.Base { /// /// Base class for all Globally Paid services @@ -21,7 +23,7 @@ public Service(HttpServiceClient client) protected HttpServiceClient Client { - get => client ?? GloballyPaidConfiguration.Client; + get => client ?? DeepStackConfiguration.Client; set => client = value; } protected const string HMAC = "hmac"; @@ -34,8 +36,8 @@ protected void TryReconfigureClient(object request, RequestOptions requestOption Client.Headers.Remove(HMAC); - var sharedSecret = requestOptions?.SharedSecret ?? GloballyPaidConfiguration.SharedSecret; - var appId = requestOptions?.AppId ?? GloballyPaidConfiguration.AppId; + var sharedSecret = requestOptions?.SharedSecret ?? DeepStackConfiguration.SharedSecret; + var appId = requestOptions?.AppId ?? DeepStackConfiguration.AppId; var authenticationString = $"{appId}:{sharedSecret}"; var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(authenticationString)); @@ -51,21 +53,21 @@ protected void TryReconfigureClient(RequestOptions requestOptions = null) { var useSandbox = requestOptions?.UseSandbox != default ? requestOptions.UseSandbox.GetValueOrDefault() - : GloballyPaidConfiguration.UseSandbox; + : DeepStackConfiguration.UseSandbox; var baseUrl = useSandbox - ? GloballyPaidConstants.DefaultSandboxBaseUrl - : GloballyPaidConstants.DefaultBaseUrl; + ? DeepStackConstants.DefaultSandboxBaseUrl + : DeepStackConstants.DefaultBaseUrl; var timeout = requestOptions?.RequestTimeoutSeconds != default ? requestOptions?.RequestTimeoutSeconds - : GloballyPaidConfiguration.RequestTimeoutSeconds; + : DeepStackConfiguration.RequestTimeoutSeconds; Client = new HttpServiceClient(new HttpServiceClientConfiguration(baseUrl, timeout)); } - Client.AuthorizationHeader = new AuthenticationHeaderValue(GloballyPaidConstants.BearerAuthenticationScheme, - requestOptions?.PublishableApiKey ?? GloballyPaidConfiguration.PublishableApiKey); + Client.AuthorizationHeader = new AuthenticationHeaderValue(DeepStackConstants.BearerAuthenticationScheme, + requestOptions?.PublishableApiKey ?? DeepStackConfiguration.PublishableApiKey); } } } diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/CaptureService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/CaptureService.cs similarity index 90% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/CaptureService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/CaptureService.cs index 22acbb7..9204ef6 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/CaptureService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/CaptureService.cs @@ -1,7 +1,13 @@ using System.Threading; using System.Threading.Tasks; +using DeepStack.Core; +using DeepStack.Entities; +using DeepStack.Requests; +using DeepStack.Requests.Base; +using DeepStack.Services.Base; +using DeepStack.Services.v1.Interfaces; -namespace GloballyPaid +namespace DeepStack.Services.v1 { /// /// Service for capturing charges diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/ChargeService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/ChargeService.cs similarity index 92% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/ChargeService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/ChargeService.cs index 53704eb..68e49f1 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/ChargeService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/ChargeService.cs @@ -1,7 +1,13 @@ using System.Threading; using System.Threading.Tasks; +using DeepStack.Core; +using DeepStack.Entities; +using DeepStack.Requests; +using DeepStack.Requests.Base; +using DeepStack.Services.Base; +using DeepStack.Services.v1.Interfaces; -namespace GloballyPaid +namespace DeepStack.Services.v1 { /// /// Service for charging credit or debit card diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/CustomerService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/CustomerService.cs similarity index 97% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/CustomerService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/CustomerService.cs index 2c43058..1bafd70 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/CustomerService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/CustomerService.cs @@ -1,8 +1,13 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using DeepStack.Core; +using DeepStack.Entities; +using DeepStack.Requests.Base; +using DeepStack.Services.Base; +using DeepStack.Services.v1.Interfaces; -namespace GloballyPaid +namespace DeepStack.Services.v1 { /// /// Service for Create, Read, Update and Delete of the entity diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ICaptureService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ICaptureService.cs similarity index 91% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ICaptureService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ICaptureService.cs index 72bf3fe..dc60b9f 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ICaptureService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ICaptureService.cs @@ -1,7 +1,10 @@ using System.Threading; using System.Threading.Tasks; +using DeepStack.Entities; +using DeepStack.Requests; +using DeepStack.Requests.Base; -namespace GloballyPaid +namespace DeepStack.Services.v1.Interfaces { /// /// Interface for capturing charges diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IChargeService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IChargeService.cs similarity index 92% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IChargeService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IChargeService.cs index 90644b6..06d242b 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IChargeService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IChargeService.cs @@ -1,7 +1,10 @@ using System.Threading; using System.Threading.Tasks; +using DeepStack.Entities; +using DeepStack.Requests; +using DeepStack.Requests.Base; -namespace GloballyPaid +namespace DeepStack.Services.v1.Interfaces { /// /// Interface for charging credit or debit card diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ICustomerService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ICustomerService.cs similarity index 98% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ICustomerService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ICustomerService.cs index a886461..fb4eb4d 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ICustomerService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ICustomerService.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using DeepStack.Entities; +using DeepStack.Requests.Base; -namespace GloballyPaid +namespace DeepStack.Services.v1.Interfaces { /// /// Interface for Create, Read, Update and Delete of the entity diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IPaymentInstrumentService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IPaymentInstrumentService.cs similarity index 81% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IPaymentInstrumentService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IPaymentInstrumentService.cs index ae29d85..e209cfd 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IPaymentInstrumentService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IPaymentInstrumentService.cs @@ -1,9 +1,13 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using GloballyPaid.Interface; +using DeepStack.Entities; +using DeepStack.Entities.Common; +using DeepStack.Entities.Interface; +using DeepStack.Requests; +using DeepStack.Requests.Base; -namespace GloballyPaid +namespace DeepStack.Services.v1.Interfaces { /// /// Interface for Create, Read, Update and Delete of the entity @@ -65,6 +69,24 @@ public interface IPaymentInstrumentService /// A Task entity, representing the asynchronous operation Task CreateAsync(IPaymentInstrument paymentInstrument, RequestOptions requestOptions = null, CancellationToken cancellationToken = default); + /// + /// Sends a request to Globally Paid API to create a payment instrument from a token + /// + /// + /// + /// + IPaymentInstrument Create(PaymentInstrumentTokenRequest paymentInstrumentTokenRequest, RequestOptions requestOptions = null); + + /// + /// Sends a request to Globally Paid API to create a payment instrument from a token, as an asynchronous operation + /// + /// + /// + /// + /// + Task CreateAsync(PaymentInstrumentTokenRequest paymentInstrumentTokenRequest, + RequestOptions requestOptions = null, CancellationToken cancellationToken = default); + /// /// Sends a request to Globally Paid API to updated a payment instrument /// @@ -87,7 +109,7 @@ public interface IPaymentInstrumentService /// /// The id /// Used to reconfigure Globally Paid SDK setting for this particular call - void Delete(string id, string customerId, RequestOptions requestOptions = null); + bool Delete(string id, string customerId = "deprecated", RequestOptions requestOptions = null); /// /// Sends a request to Globally Paid API to delete a payment instrument by id, as an asynchronous operation @@ -96,6 +118,6 @@ public interface IPaymentInstrumentService /// Used to reconfigure Globally Paid SDK setting for this particular call /// /// A Task entity, representing the asynchronous operation - Task DeleteAsync(string id, string customerId, RequestOptions requestOptions = null, CancellationToken cancellationToken = default); + Task DeleteAsync(string id, string customerId = "deprecated", RequestOptions requestOptions = null, CancellationToken cancellationToken = default); } } diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IRefundService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IRefundService.cs similarity index 91% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IRefundService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IRefundService.cs index 48e4853..b168079 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/IRefundService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/IRefundService.cs @@ -1,7 +1,10 @@ using System.Threading; using System.Threading.Tasks; +using DeepStack.Entities; +using DeepStack.Requests; +using DeepStack.Requests.Base; -namespace GloballyPaid +namespace DeepStack.Services.v1.Interfaces { /// /// Interface for refunding charges diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ITokenService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ITokenService.cs similarity index 89% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ITokenService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ITokenService.cs index 06688d9..29f2e18 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/Interfaces/ITokenService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/Interfaces/ITokenService.cs @@ -1,8 +1,11 @@ using System.Threading; using System.Threading.Tasks; -using GloballyPaid.Interface; +using DeepStack.Entities.Common; +using DeepStack.Entities.Interface; +using DeepStack.Requests; +using DeepStack.Requests.Base; -namespace GloballyPaid +namespace DeepStack.Services.v1.Interfaces { /// /// Interface to tokenize the card data diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/PaymentInstrumentService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/PaymentInstrumentService.cs similarity index 81% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/PaymentInstrumentService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/PaymentInstrumentService.cs index 160cdd3..21e87f1 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/PaymentInstrumentService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/PaymentInstrumentService.cs @@ -1,9 +1,15 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using GloballyPaid.Interface; +using DeepStack.Core; +using DeepStack.Entities; +using DeepStack.Entities.Interface; +using DeepStack.Requests; +using DeepStack.Requests.Base; +using DeepStack.Services.Base; +using DeepStack.Services.v1.Interfaces; -namespace GloballyPaid +namespace DeepStack.Services.v1 { /// /// Service for Create, Read, Update and Delete of the entity @@ -105,6 +111,35 @@ public async Task CreateAsync(IPaymentInstrument paymentInst return await Client.PostAsync($"{BasePath}/{paymentInstrument.CustomerId}", paymentInstrument, checkResponseCode: false, cancellationToken); } + /// + /// Sends a request to Globally Paid API to create a payment instrument from a token + /// + /// + /// + /// + public IPaymentInstrument Create(PaymentInstrumentTokenRequest paymentInstrumentTokenRequest, + RequestOptions requestOptions = null) + { + TryReconfigureClient(paymentInstrumentTokenRequest, requestOptions); + return Client.Post($"{BasePath}/token", + paymentInstrumentTokenRequest); + } + + /// + /// Sends a request to Globally Paid API to create a payment instrument from a token, as an asynchronous operation + /// + /// + /// + /// + /// + public async Task CreateAsync(PaymentInstrumentTokenRequest paymentInstrumentTokenRequest, + RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + TryReconfigureClient(paymentInstrumentTokenRequest, requestOptions); + return await Client.PostAsync($"{BasePath}/token", + paymentInstrumentTokenRequest, checkResponseCode: false, cancellationToken); + } + /// /// Sends a request to Globally Paid API to updated a payment instrument /// @@ -135,10 +170,10 @@ public async Task UpdateAsync(IPaymentInstrument paymentInst /// /// The id /// Used to reconfigure Globally Paid SDK setting for this particular call - public void Delete(string id, string customerId, RequestOptions requestOptions = null) + public bool Delete(string id, string customerId = "deprecated", RequestOptions requestOptions = null) { TryReconfigureClient(string.Empty, requestOptions); - Client.Delete($"{BasePath}/{customerId}/{id}"); + return Client.Delete($"{BasePath}/{customerId}/{id}"); } /// @@ -148,7 +183,7 @@ public void Delete(string id, string customerId, RequestOptions requestOptions = /// Used to reconfigure Globally Paid SDK setting for this particular call /// /// A Task entity, representing the asynchronous operation - public async Task DeleteAsync(string id, string customerId, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + public async Task DeleteAsync(string id, string customerId = "deprecated", RequestOptions requestOptions = null, CancellationToken cancellationToken = default) { TryReconfigureClient(string.Empty, requestOptions); await Client.DeleteAsync($"{BasePath}/{customerId}/{id}", cancellationToken); diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/RefundService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/RefundService.cs similarity index 90% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/RefundService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/RefundService.cs index 8716517..b16baaa 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/RefundService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/RefundService.cs @@ -1,7 +1,13 @@ using System.Threading; using System.Threading.Tasks; +using DeepStack.Core; +using DeepStack.Entities; +using DeepStack.Requests; +using DeepStack.Requests.Base; +using DeepStack.Services.Base; +using DeepStack.Services.v1.Interfaces; -namespace GloballyPaid +namespace DeepStack.Services.v1 { /// /// Service for refunding charges diff --git a/src/GloballyPaid.CSharp.Sdk/Services/v1/TokenService.cs b/src/DeepStack.CSharp.Sdk/Services/v1/TokenService.cs similarity index 88% rename from src/GloballyPaid.CSharp.Sdk/Services/v1/TokenService.cs rename to src/DeepStack.CSharp.Sdk/Services/v1/TokenService.cs index 660a598..b598d43 100644 --- a/src/GloballyPaid.CSharp.Sdk/Services/v1/TokenService.cs +++ b/src/DeepStack.CSharp.Sdk/Services/v1/TokenService.cs @@ -1,8 +1,14 @@ using System.Threading; using System.Threading.Tasks; -using GloballyPaid.Interface; +using DeepStack.Core; +using DeepStack.Entities.Common; +using DeepStack.Entities.Interface; +using DeepStack.Requests; +using DeepStack.Requests.Base; +using DeepStack.Services.Base; +using DeepStack.Services.v1.Interfaces; -namespace GloballyPaid +namespace DeepStack.Services.v1 { /// /// Service to tokenize the card data diff --git a/src/GloballyPaid.CSharp.Sdk/Entities/Interface/IPaymentSource.cs b/src/GloballyPaid.CSharp.Sdk/Entities/Interface/IPaymentSource.cs deleted file mode 100644 index 987443b..0000000 --- a/src/GloballyPaid.CSharp.Sdk/Entities/Interface/IPaymentSource.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace GloballyPaid.Interface -{ - public interface IPaymentSource - { - PaymentSourceType Type { get; set; } - } -} \ No newline at end of file