-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31f553d
commit 8cb9ab4
Showing
18 changed files
with
231 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System.Text.Json; | ||
using Mercoa.Client; | ||
|
||
#nullable enable | ||
|
||
namespace Mercoa.Client; | ||
|
||
public class CalculateClient | ||
{ | ||
private RawClient _client; | ||
|
||
public CalculateClient(RawClient client) | ||
{ | ||
_client = client; | ||
} | ||
|
||
/// <summary> | ||
/// Calculate the estimated fees associated with an payment given the amount, payment source, and disbursement method. Can be used to calculate fees for a payment before creating an invoice. | ||
/// </summary> | ||
public async Task<InvoiceFeesResponse> FeeAsync(CalculateFeesRequest request) | ||
{ | ||
var response = await _client.MakeRequestAsync( | ||
new RawClient.ApiRequest | ||
{ | ||
Method = HttpMethod.Post, | ||
Path = "/fees", | ||
Body = request | ||
} | ||
); | ||
string responseBody = await response.Raw.Content.ReadAsStringAsync(); | ||
if (response.StatusCode >= 200 && response.StatusCode < 400) | ||
{ | ||
return JsonSerializer.Deserialize<InvoiceFeesResponse>(responseBody); | ||
} | ||
throw new Exception(responseBody); | ||
} | ||
|
||
/// <summary> | ||
/// Calculate the estimated payment timing given the deduction date, payment source, and disbursement method. Can be used to calculate timing for a payment. | ||
/// </summary> | ||
public async Task<CalculatePaymentTimingResponse> PaymentTimingAsync( | ||
CalculatePaymentTimingRequest request | ||
) | ||
{ | ||
var response = await _client.MakeRequestAsync( | ||
new RawClient.ApiRequest | ||
{ | ||
Method = HttpMethod.Post, | ||
Path = "/paymentTiming", | ||
Body = request | ||
} | ||
); | ||
string responseBody = await response.Raw.Content.ReadAsStringAsync(); | ||
if (response.StatusCode >= 200 && response.StatusCode < 400) | ||
{ | ||
return JsonSerializer.Deserialize<CalculatePaymentTimingResponse>(responseBody); | ||
} | ||
throw new Exception(responseBody); | ||
} | ||
} |
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
src/Mercoa.Client/Calculate/Types/CalculatePaymentTimingRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Text.Json.Serialization; | ||
using Mercoa.Client; | ||
|
||
#nullable enable | ||
|
||
namespace Mercoa.Client; | ||
|
||
public class CalculatePaymentTimingRequest | ||
{ | ||
/// <summary> | ||
/// Date the payment is scheduled to be deducted from the payer's account. Use this field if the payment has not yet been deducted. | ||
/// </summary> | ||
[JsonPropertyName("estimatedDeductionDate")] | ||
public DateTime? EstimatedDeductionDate { get; init; } | ||
|
||
/// <summary> | ||
/// Date the payment was processed. Use this field if the payment has already been deducted. | ||
/// </summary> | ||
[JsonPropertyName("processedAt")] | ||
public DateTime? ProcessedAt { get; init; } | ||
|
||
/// <summary> | ||
/// ID of payment source. | ||
/// </summary> | ||
[JsonPropertyName("paymentSourceId")] | ||
public string PaymentSourceId { get; init; } | ||
|
||
/// <summary> | ||
/// ID of payment destination. | ||
/// </summary> | ||
[JsonPropertyName("paymentDestinationId")] | ||
public string PaymentDestinationId { get; init; } | ||
|
||
/// <summary> | ||
/// Options for the payment destination. Depending on the payment destination, this may include things such as check delivery method. | ||
/// </summary> | ||
[JsonPropertyName("paymentDestinationOptions")] | ||
public PaymentDestinationOptions? PaymentDestinationOptions { get; init; } | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Mercoa.Client/Calculate/Types/CalculatePaymentTimingResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace Mercoa.Client; | ||
|
||
public class CalculatePaymentTimingResponse | ||
{ | ||
/// <summary> | ||
/// Estimated date the payment will be or was processed. | ||
/// </summary> | ||
[JsonPropertyName("estimatedProcessingDate")] | ||
public DateTime EstimatedProcessingDate { get; init; } | ||
|
||
/// <summary> | ||
/// Number of business days between the estimated processing date and the estimated settlement date. This does not take into account bank holidays or weekends. | ||
/// </summary> | ||
[JsonPropertyName("businessDays")] | ||
public int BusinessDays { get; init; } | ||
|
||
/// <summary> | ||
/// Estimated payment time in days. This time takes into account bank holidays and weekends. | ||
/// </summary> | ||
[JsonPropertyName("estimatedProcessingTime")] | ||
public int EstimatedProcessingTime { get; init; } | ||
|
||
/// <summary> | ||
/// Estimated date the payment will be or was settled. This is the same as the request's deductionDate plus the paymentTiming. | ||
/// </summary> | ||
[JsonPropertyName("estimatedSettlementDate")] | ||
public DateTime EstimatedSettlementDate { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace Mercoa.Client; | ||
|
||
public class IndustryCodes | ||
{ | ||
[JsonPropertyName("mcc")] | ||
public string? Mcc { get; init; } | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Mercoa.Client/InvoiceTypes/Types/InvoiceFeesRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace Mercoa.Client; | ||
|
||
public class InvoiceFeesRequest | ||
{ | ||
/// <summary> | ||
/// Fee charged to the payer (C2). | ||
/// </summary> | ||
[JsonPropertyName("sourcePlatformMarkupFee")] | ||
public double SourcePlatformMarkupFee { get; init; } | ||
|
||
/// <summary> | ||
/// Fee charged to the payee (C3). | ||
/// </summary> | ||
[JsonPropertyName("destinationPlatformMarkupFee")] | ||
public double DestinationPlatformMarkupFee { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters