Skip to content
Merged
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
21 changes: 8 additions & 13 deletions Channels/Batch.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
using SaferPay.Config;
using SaferPay.Config;
using SaferPay.Interfaces;
using SaferPay.Models.Batch;
using SaferPay.Models.Core;

namespace SaferPay.Channels;

public class Batch : IBatch

Check warning on line 8 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / run_test

Missing XML comment for publicly visible type or member 'Batch'

Check warning on line 8 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'Batch'
{

private readonly ISaferPayClient _client;

public Batch(SaferPaySettings settings) => _client = new SaferPayClient(settings);

Check warning on line 13 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / run_test

Missing XML comment for publicly visible type or member 'Batch.Batch(SaferPaySettings)'

Check warning on line 13 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'Batch.Batch(SaferPaySettings)'
public Batch(ISaferPayClient client) => _client = client;
public Batch(string customerId, string terminalId, string userName, string passWord, bool sandBox = false) => _client = new SaferPayClient(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox));
public Batch(ISaferPayClient client) => _client = client ?? throw new ArgumentNullException(nameof(client));

Check warning on line 14 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / run_test

Missing XML comment for publicly visible type or member 'Batch.Batch(ISaferPayClient)'

Check warning on line 14 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'Batch.Batch(ISaferPayClient)'
public Batch(string customerId, string terminalId, string userName, string passWord, bool sandBox = false)

Check warning on line 15 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / run_test

Missing XML comment for publicly visible type or member 'Batch.Batch(string, string, string, string, bool)'

Check warning on line 15 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'Batch.Batch(string, string, string, string, bool)'
=> _client = new SaferPayClient(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox));


public BatchResponse Close(BatchRequest request)
{
if (_client != null) return _client.Send<BatchResponse, BatchRequest>(SaferPayEndpoints.BatchEndpoint + SaferPayMethods.BatchClose, request);
return null;
}
public BatchResponse Close(BatchRequest request) =>

Check warning on line 19 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / run_test

Missing XML comment for publicly visible type or member 'Batch.Close(BatchRequest)'

Check warning on line 19 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'Batch.Close(BatchRequest)'
_client.Send<BatchResponse, BatchRequest>(SaferPayEndpoints.BatchEndpoint + SaferPayMethods.BatchClose, request);

public Task<BatchResponse> CloseAsync(BatchRequest request)
{
if (_client != null) return _client.SendAsync<BatchResponse, BatchRequest>(SaferPayEndpoints.BatchEndpoint + SaferPayMethods.BatchClose, request);
return null;
}
public Task<BatchResponse> CloseAsync(BatchRequest request) =>

Check warning on line 22 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / run_test

Missing XML comment for publicly visible type or member 'Batch.CloseAsync(BatchRequest)'

Check warning on line 22 in Channels/Batch.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'Batch.CloseAsync(BatchRequest)'
_client.SendAsync<BatchResponse, BatchRequest>(SaferPayEndpoints.BatchEndpoint + SaferPayMethods.BatchClose, request);
}
153 changes: 44 additions & 109 deletions Channels/ManagementApi.cs
Original file line number Diff line number Diff line change
@@ -1,172 +1,107 @@
using SaferPay.Interfaces;
using SaferPay.Interfaces;
using SaferPay.Models.Core;
using SaferPay.Models.Management;

namespace SaferPay.Channels;

public class ManagementApi : IManagementApi

Check warning on line 7 in Channels/ManagementApi.cs

View workflow job for this annotation

GitHub Actions / run_test

Missing XML comment for publicly visible type or member 'ManagementApi'

Check warning on line 7 in Channels/ManagementApi.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'ManagementApi'
{
private readonly ISaferPayClient _client;

public ManagementApi(SaferPaySettings settings) => _client = new SaferPayClient(settings);

Check warning on line 11 in Channels/ManagementApi.cs

View workflow job for this annotation

GitHub Actions / run_test

Missing XML comment for publicly visible type or member 'ManagementApi.ManagementApi(SaferPaySettings)'

Check warning on line 11 in Channels/ManagementApi.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Missing XML comment for publicly visible type or member 'ManagementApi.ManagementApi(SaferPaySettings)'

public ManagementApi(ISaferPayClient client) => _client = client;
public ManagementApi(ISaferPayClient client) => _client = client ?? throw new ArgumentNullException(nameof(client));

public ManagementApi(string customerId, string terminalId, string userName, string passWord, bool sandBox = false) => _client = new SaferPayClient(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox));
public ManagementApi(string customerId, string terminalId, string userName, string passWord, bool sandBox = false)
=> _client = new SaferPayClient(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox));

public ManagementBaseResponse LicensingCustomerLicense()
{
if (_client == null) return default;
var data = LicensingCustomerLicenseAsync().GetAwaiter().GetResult();
return data;
}
public ManagementBaseResponse LicensingCustomerLicense() =>
LicensingCustomerLicenseAsync().GetAwaiter().GetResult();

public async Task<ManagementBaseResponse> LicensingCustomerLicenseAsync()
public Task<ManagementBaseResponse> LicensingCustomerLicenseAsync()
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/license";

var response = await _client.GetAsync<ManagementBaseResponse>(endpoint);
return response;
return _client.GetAsync<ManagementBaseResponse>(endpoint);
}

public RestResponseBase LicensingCustomerLicenseConfiguration()
{
if (_client == null) return default;
var data = LicensingCustomerLicenseConfigurationAsync().GetAwaiter().GetResult();
return data;
}
public RestResponseBase LicensingCustomerLicenseConfiguration() =>
LicensingCustomerLicenseConfigurationAsync().GetAwaiter().GetResult();

public async Task<RestResponseBase> LicensingCustomerLicenseConfigurationAsync()
public Task<RestResponseBase> LicensingCustomerLicenseConfigurationAsync()
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/license-configuration";

var response = await _client.GetAsync<RestResponseBase>(endpoint);
return response;
return _client.GetAsync<RestResponseBase>(endpoint);
}

public ManagementConfigurations PaymentPageConfigGetConfigurations()
{
if (_client == null) return default;
var data = PaymentPageConfigGetConfigurationsAsync().GetAwaiter().GetResult();
return data;
}
public ManagementConfigurations PaymentPageConfigGetConfigurations() =>
PaymentPageConfigGetConfigurationsAsync().GetAwaiter().GetResult();

public async Task<ManagementConfigurations> PaymentPageConfigGetConfigurationsAsync()
public Task<ManagementConfigurations> PaymentPageConfigGetConfigurationsAsync()
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/payment-page/configurations";

var response = await _client.GetAsync<ManagementConfigurations>(endpoint);
return response;
return _client.GetAsync<ManagementConfigurations>(endpoint);
}

public CreateAccessTokenResponse SaferpayFieldsAccessTokenCreateAccessToken(CreateAccessTokenRequest request)
{
if (_client == null) return default;
var data = SaferpayFieldsAccessTokenCreateAccessTokenAsync(request).GetAwaiter().GetResult();
return data;
}
public CreateAccessTokenResponse SaferpayFieldsAccessTokenCreateAccessToken(CreateAccessTokenRequest request) =>
SaferpayFieldsAccessTokenCreateAccessTokenAsync(request).GetAwaiter().GetResult();

public async Task<CreateAccessTokenResponse> SaferpayFieldsAccessTokenCreateAccessTokenAsync(CreateAccessTokenRequest request)
public Task<CreateAccessTokenResponse> SaferpayFieldsAccessTokenCreateAccessTokenAsync(CreateAccessTokenRequest request)
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/terminals/{_client.TerminalId}/fields-access-tokens";

var response = await _client.PostAsync<CreateAccessTokenResponse, CreateAccessTokenRequest>(endpoint, request);
return response;
return _client.PostAsync<CreateAccessTokenResponse, CreateAccessTokenRequest>(endpoint, request);
}

public RestResponseBase SaferpayFieldsAccessTokenDeleteAccessToken(string accessToken)
{
if (_client == null) return default;
var data = SaferpayFieldsAccessTokenDeleteAccessTokenAsync(accessToken).GetAwaiter().GetResult();
return data;
}
public RestResponseBase SaferpayFieldsAccessTokenDeleteAccessToken(string accessToken) =>
SaferpayFieldsAccessTokenDeleteAccessTokenAsync(accessToken).GetAwaiter().GetResult();

public async Task<RestResponseBase> SaferpayFieldsAccessTokenDeleteAccessTokenAsync(string accessToken)
public Task<RestResponseBase> SaferpayFieldsAccessTokenDeleteAccessTokenAsync(string accessToken)
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/terminals/{_client.TerminalId}/fields-access-tokens/{accessToken}";

var response = await _client.DeleteAsync<RestResponseBase>(endpoint);
return response;
return _client.DeleteAsync<RestResponseBase>(endpoint);
}

public CreateSingleUsePaymentLinkResponse SecurePayGateCreateSingleUsePaymentLink(CreateSingleUsePaymentLinkRequest request)
{
if (_client == null) return default;
var data = SecurePayGateCreateSingleUsePaymentLinkAsync(request).GetAwaiter().GetResult();
return data;
}
public CreateSingleUsePaymentLinkResponse SecurePayGateCreateSingleUsePaymentLink(CreateSingleUsePaymentLinkRequest request) =>
SecurePayGateCreateSingleUsePaymentLinkAsync(request).GetAwaiter().GetResult();

public async Task<CreateSingleUsePaymentLinkResponse> SecurePayGateCreateSingleUsePaymentLinkAsync(CreateSingleUsePaymentLinkRequest request)
public Task<CreateSingleUsePaymentLinkResponse> SecurePayGateCreateSingleUsePaymentLinkAsync(CreateSingleUsePaymentLinkRequest request)
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/terminals/{_client.TerminalId}/spg-offers";

var response = await _client.PostAsync<CreateSingleUsePaymentLinkResponse, CreateSingleUsePaymentLinkRequest>(endpoint, request);
return response;
return _client.PostAsync<CreateSingleUsePaymentLinkResponse, CreateSingleUsePaymentLinkRequest>(endpoint, request);
}

public SingleUsePaymentLinkResponse SecurePayGateSingleUsePaymentLink(string offerId)
{
if (_client == null) return default;
var data = SecurePayGateSingleUsePaymentLinkAsync(offerId).GetAwaiter().GetResult();
return data;
}
public SingleUsePaymentLinkResponse SecurePayGateSingleUsePaymentLink(string offerId) =>
SecurePayGateSingleUsePaymentLinkAsync(offerId).GetAwaiter().GetResult();

public async Task<SingleUsePaymentLinkResponse> SecurePayGateSingleUsePaymentLinkAsync(string offerId)
public Task<SingleUsePaymentLinkResponse> SecurePayGateSingleUsePaymentLinkAsync(string offerId)
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/terminals/{_client.TerminalId}/spg-offers/{offerId}";
var response = await _client.GetAsync<SingleUsePaymentLinkResponse>(endpoint);
return response;
return _client.GetAsync<SingleUsePaymentLinkResponse>(endpoint);
}

public TerminalResponse TerminalGetTerminal()
{
if (_client == null) return default;
var data = TerminalGetTerminalAsync().GetAwaiter().GetResult();
return data;
}
public TerminalResponse TerminalGetTerminal() =>
TerminalGetTerminalAsync().GetAwaiter().GetResult();

public async Task<TerminalResponse> TerminalGetTerminalAsync()
public Task<TerminalResponse> TerminalGetTerminalAsync()
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/terminals/{_client.TerminalId}";
var response = await _client.GetAsync<TerminalResponse>(endpoint);
return response;
return _client.GetAsync<TerminalResponse>(endpoint);
}

public TerminalsResponse TerminalsGetTerminals()
{
if (_client == null) return default;
var data = TerminalsGetTerminalsAsync().GetAwaiter().GetResult();
return data;
}
public TerminalsResponse TerminalsGetTerminals() =>
TerminalsGetTerminalsAsync().GetAwaiter().GetResult();

public async Task<TerminalsResponse> TerminalsGetTerminalsAsync()
public Task<TerminalsResponse> TerminalsGetTerminalsAsync()
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/terminals";
var response = await _client.GetAsync<TerminalsResponse>(endpoint);
return response;
return _client.GetAsync<TerminalsResponse>(endpoint);
}

public ReportingGetTransactionsResponse TransactionReportingGetTransactions(ReportingGetTransactionsRequest request)
{
if (_client == null) return default;
var data = TransactionReportingGetTransactionsAsync(request).GetAwaiter().GetResult();
return data;
}
public ReportingGetTransactionsResponse TransactionReportingGetTransactions(ReportingGetTransactionsRequest request) =>
TransactionReportingGetTransactionsAsync(request).GetAwaiter().GetResult();

public async Task<ReportingGetTransactionsResponse> TransactionReportingGetTransactionsAsync(ReportingGetTransactionsRequest request)
public Task<ReportingGetTransactionsResponse> TransactionReportingGetTransactionsAsync(ReportingGetTransactionsRequest request)
{
if (_client == null) return default;
var endpoint = $"rest/customers/{_client.CustomerId}/transactions";
var response = await _client.GetAsync<ReportingGetTransactionsResponse, ReportingGetTransactionsRequest>(endpoint, request);
return response;
return _client.GetAsync<ReportingGetTransactionsResponse, ReportingGetTransactionsRequest>(endpoint, request);
}
}
45 changes: 17 additions & 28 deletions Channels/OmniChannel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using SaferPay.Config;
using SaferPay.Config;
using SaferPay.Interfaces;
using SaferPay.Models.Core;
using SaferPay.Models.OmniChannel;
Expand All @@ -14,31 +14,20 @@ public class OmniChannel : IOmniChannel
private readonly ISaferPayClient _client;

public OmniChannel(SaferPaySettings settings) => _client = new SaferPayClient(settings);
public OmniChannel(ISaferPayClient client) => _client = client;
public OmniChannel(string customerId, string terminalId, string userName, string passWord, bool sandBox = false) => _client = new SaferPayClient(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox));


public AcquireTransactionResponse AcquireTransaction(AcquireTransactionRequest request)
{
if (_client != null) return _client.Send<AcquireTransactionResponse, AcquireTransactionRequest>(SaferPayEndpoints.OmniChannelEndpoint + SaferPayMethods.OmniChannelAcquireTransaction, request);
return null;
}

public Task<AcquireTransactionResponse> AcquireTransactionAsync(AcquireTransactionRequest request)
{
if (_client != null) return _client.SendAsync<AcquireTransactionResponse, AcquireTransactionRequest>(SaferPayEndpoints.OmniChannelEndpoint + SaferPayMethods.OmniChannelAcquireTransaction, request);
return null;
}

public InsertAliasResponse InsertAlias(InsertAliasRequest request)
{
if (_client != null) return _client.Send<InsertAliasResponse, InsertAliasRequest>(SaferPayEndpoints.OmniChannelEndpoint + SaferPayMethods.OmniChannelInsertAlias, request);
return null;
}

public Task<InsertAliasResponse> InsertAliasAsync(InsertAliasRequest request)
{
if (_client != null) return _client.SendAsync<InsertAliasResponse, InsertAliasRequest>(SaferPayEndpoints.OmniChannelEndpoint + SaferPayMethods.OmniChannelInsertAlias, request);
return null;
}
public OmniChannel(ISaferPayClient client) => _client = client ?? throw new ArgumentNullException(nameof(client));
public OmniChannel(string customerId, string terminalId, string userName, string passWord, bool sandBox = false)
=> _client = new SaferPayClient(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox));


public AcquireTransactionResponse AcquireTransaction(AcquireTransactionRequest request) =>
_client.Send<AcquireTransactionResponse, AcquireTransactionRequest>(SaferPayEndpoints.OmniChannelEndpoint + SaferPayMethods.OmniChannelAcquireTransaction, request);

public Task<AcquireTransactionResponse> AcquireTransactionAsync(AcquireTransactionRequest request) =>
_client.SendAsync<AcquireTransactionResponse, AcquireTransactionRequest>(SaferPayEndpoints.OmniChannelEndpoint + SaferPayMethods.OmniChannelAcquireTransaction, request);

public InsertAliasResponse InsertAlias(InsertAliasRequest request) =>
_client.Send<InsertAliasResponse, InsertAliasRequest>(SaferPayEndpoints.OmniChannelEndpoint + SaferPayMethods.OmniChannelInsertAlias, request);

public Task<InsertAliasResponse> InsertAliasAsync(InsertAliasRequest request) =>
_client.SendAsync<InsertAliasResponse, InsertAliasRequest>(SaferPayEndpoints.OmniChannelEndpoint + SaferPayMethods.OmniChannelInsertAlias, request);
}
21 changes: 11 additions & 10 deletions Channels/PaymentPage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using SaferPay.Config;
using SaferPay.Config;
using SaferPay.Interfaces;
using SaferPay.Models.Core;
using SaferPay.Models.PaymentPage;
Expand All @@ -19,28 +19,29 @@ public class PaymentPage : IPaymentPage

#region Ctors
public PaymentPage(SaferPaySettings settings) => _client = new SaferPayClient(settings);
public PaymentPage(ISaferPayClient client) => _client = client;
public PaymentPage(string customerId, string terminalId, string userName, string passWord, bool sandBox = false) => _client = new SaferPayClient(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox));
public PaymentPage(ISaferPayClient client) => _client = client ?? throw new ArgumentNullException(nameof(client));
public PaymentPage(string customerId, string terminalId, string userName, string passWord, bool sandBox = false)
=> _client = new SaferPayClient(new SaferPaySettings(customerId, terminalId, userName, passWord, sandBox));
#endregion

#region Methods
public AssertResponse Assert(AssertRequest request) =>
_client?.Send<AssertResponse, AssertRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageAssert, request);
public AssertResponse Assert(AssertRequest request) =>
_client.Send<AssertResponse, AssertRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageAssert, request);

public AssertResponse Assert(string token) =>
_client?.Send<AssertResponse, AssertRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageAssert, new AssertRequest(token));
_client.Send<AssertResponse, AssertRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageAssert, new AssertRequest(token));

public Task<AssertResponse> AssertAsync(AssertRequest request) =>
_client?.SendAsync<AssertResponse, AssertRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageAssert, request);
_client.SendAsync<AssertResponse, AssertRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageAssert, request);

public Task<AssertResponse> AssertAsync(string token) =>
_client?.SendAsync<AssertResponse, AssertRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageAssert, new AssertRequest(token));
_client.SendAsync<AssertResponse, AssertRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageAssert, new AssertRequest(token));

public InitializePaymentPageResponse Initialize(InitializePaymentPageRequest request) =>
_client?.Send<InitializePaymentPageResponse, InitializePaymentPageRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageInitialize, request);
_client.Send<InitializePaymentPageResponse, InitializePaymentPageRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageInitialize, request);

public Task<InitializePaymentPageResponse> InitializeAsync(InitializePaymentPageRequest request) =>
_client?.SendAsync<InitializePaymentPageResponse, InitializePaymentPageRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageInitialize, request);
_client.SendAsync<InitializePaymentPageResponse, InitializePaymentPageRequest>(SaferPayEndpoints.PaymentPageEndpoint + SaferPayMethods.PaymentPageInitialize, request);
#endregion

public override string ToString() => base.ToString() ?? "Payment Page";
Expand Down
Loading
Loading