Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
# - 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
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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);
Expand All @@ -90,11 +91,11 @@ All SDK calls can be configured using the `<appSettings>` section in configurati

```xml
<appSettings>
<add key="GloballyPaidPublishableApiKey" value="Your Publishable API Key"></add>
<add key="GloballyPaidSharedSecret" value="Your Shared Secret"></add>
<add key="GloballyPaidAppId" value="Your APP ID"></add>
<add key="GloballyPaidUseSandbox" value="false"></add> <!--true if you need to test through Globally Paid sandbox-->
<add key="GloballyPaidRequestTimeoutSeconds" value="90"></add>
<add key="DeepStackPublishableApiKey" value="Your Publishable API Key"></add>
<add key="DeepStackSharedSecret" value="Your Shared Secret"></add>
<add key="DeepStackAppId" value="Your APP ID"></add>
<add key="DeepStackUseSandbox" value="false"></add> <!--true if you need to test through Globally Paid sandbox-->
<add key="DeepStackRequestTimeoutSeconds" value="90"></add>
</appSettings>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Net.Http;
using Xunit;

namespace GloballyPaid.Tests
namespace DeepStack.Tests
{
[CollectionDefinition("Globally Paid SDK tests")]
public class BaseMockTestCollection :
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>

Expand All @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GloballyPaid.CSharp.Sdk\GloballyPaid.CSharp.Sdk.csproj" />
<ProjectReference Include="..\DeepStack.CSharp.Sdk\DeepStack.CSharp.Sdk.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace GloballyPaid.Tests
namespace DeepStack.Tests
{
public class MockHttpClientFixture
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -51,11 +56,11 @@ public void Capture_Error_Invalid_ResponseCode()

StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, expectedResult.ToJson());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}

Expand All @@ -64,11 +69,11 @@ public void Capture_Error_Invalid_API_Response()
{
StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, GetInvalidJson());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand All @@ -78,11 +83,11 @@ public void Capture_Error_Invalid_Status()
{
StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -101,11 +109,11 @@ public void Charge_Error_Invalid_API_Response()
{
StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, GetInvalidJson());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand All @@ -115,11 +123,11 @@ public void Capture_Error_Invalid_Status()
{
StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Threading.Tasks;
using Xunit;

namespace GloballyPaid.Tests
namespace DeepStack.Tests
{
public class CustomerServiceTest : BaseTest
{
Expand Down Expand Up @@ -71,11 +71,11 @@ public void List_Error_Invalid_API_Response()
{
StubRequest(HttpMethod.Get, BasePath, HttpStatusCode.OK, GetInvalidJson());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand All @@ -85,11 +85,11 @@ public void List_Error_Invalid_Status()
{
StubRequest(HttpMethod.Get, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand Down Expand Up @@ -138,11 +138,11 @@ public void Get_Error_Invalid_API_Response()
{
StubRequest(HttpMethod.Get, $"{BasePath}/id", HttpStatusCode.OK, GetInvalidJson());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand All @@ -152,11 +152,11 @@ public void Get_Error_Invalid_Status()
{
StubRequest(HttpMethod.Get, $"{BasePath}/id", HttpStatusCode.BadRequest, GetInvalidStatusError());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand Down Expand Up @@ -192,11 +192,11 @@ public void Create_Error_Invalid_API_Response()
{
StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.OK, GetInvalidJson());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand All @@ -206,11 +206,11 @@ public void Create_Error_Invalid_Status()
{
StubRequest(HttpMethod.Post, BasePath, HttpStatusCode.BadRequest, GetInvalidStatusError());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand Down Expand Up @@ -246,11 +246,11 @@ public void Update_Error_Invalid_API_Response()
{
StubRequest(HttpMethod.Put, $"{BasePath}/id", HttpStatusCode.OK, GetInvalidJson());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand All @@ -260,11 +260,11 @@ public void Update_Error_Invalid_Status()
{
StubRequest(HttpMethod.Put, $"{BasePath}/id", HttpStatusCode.BadRequest, GetInvalidStatusError());

var exception = Assert.Throws<GloballyPaidException>(() =>
var exception = Assert.Throws<DeepStackException>(() =>
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);
}
Expand Down
Loading