Skip to content

Commit 31bca2a

Browse files
Add Network Token API endpoints and related models
1 parent 8eeab28 commit 31bca2a

29 files changed

+684
-11
lines changed

src/CheckoutSdk/CheckoutApi.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Checkout.Forward;
99
using Checkout.Instruments;
1010
using Checkout.Metadata;
11+
using Checkout.NetworkTokens;
1112
using Checkout.Payments;
1213
using Checkout.Payments.Contexts;
1314
using Checkout.Payments.Hosted;
@@ -45,6 +46,7 @@ public class CheckoutApi : ICheckoutApi
4546
private readonly IPaymentContextsClient _paymentContextsClient;
4647
private readonly IPaymentSessionsClient _paymentSessionsClient;
4748
private readonly IForwardClient _forwardClient;
49+
private readonly INetworkTokenClient _networkTokenClient;
4850

4951
public CheckoutApi(CheckoutConfiguration configuration)
5052
{
@@ -75,6 +77,7 @@ public CheckoutApi(CheckoutConfiguration configuration)
7577
_paymentContextsClient = new PaymentContextsClient(baseApiClient, configuration);
7678
_paymentSessionsClient = new PaymentSessionsClient(baseApiClient, configuration);
7779
_forwardClient = new ForwardClient(baseApiClient, configuration);
80+
_networkTokenClient = new NetworkTokenClient(baseApiClient, configuration);
7881
}
7982

8083
private static ApiClient BaseApiClient(CheckoutConfiguration configuration)
@@ -212,5 +215,11 @@ public IForwardClient ForwardClient()
212215
{
213216
return _forwardClient;
214217
}
218+
219+
public INetworkTokenClient NetworkTokenClient()
220+
{
221+
return _networkTokenClient;
222+
}
223+
215224
}
216-
}
225+
}

src/CheckoutSdk/Common/Resource.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public Link GetUploadLink()
2323
return GetLink("upload");
2424
}
2525

26+
public Link GetCryptogramLink()
27+
{
28+
return GetLink("cryptogram");
29+
}
30+
2631
public bool HasLink(string relation)
2732
{
2833
return Links.ContainsKey(relation);

src/CheckoutSdk/Forward/ForwardClient.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using Checkout.Forward.Requests;
22
using Checkout.Forward.Responses;
3-
using System;
43
using System.Threading;
54
using System.Threading.Tasks;
65

76
namespace Checkout.Forward
87
{
8+
/// <summary>
9+
/// Forward
10+
/// </summary>
911
public class ForwardClient : AbstractClient, IForwardClient
1012
{
1113
private const string Forward = "forward";
@@ -15,6 +17,12 @@ public ForwardClient(IApiClient apiClient, CheckoutConfiguration configuration)
1517
{
1618
}
1719

20+
/// <summary>
21+
/// Forward an API request
22+
/// [BETA]
23+
/// Forwards an API request to a third-party endpoint.
24+
/// For example, you can forward payment credentials you've stored in our Vault to a third-party payment processor.
25+
/// </summary>
1826
public Task<ForwardAnApiResponse> ForwardAnApiRequest(ForwardRequest forwardRequest,
1927
CancellationToken cancellationToken = default)
2028
{
@@ -27,6 +35,11 @@ public Task<ForwardAnApiResponse> ForwardAnApiRequest(ForwardRequest forwardRequ
2735
);
2836
}
2937

38+
/// <summary>
39+
/// Get forward request
40+
/// Retrieve the details of a successfully forwarded API request.
41+
/// The details can be retrieved for up to 14 days after the request was initiated.
42+
/// </summary>
3043
public Task<GetForwardResponse> GetForwardRequest(string forwardId,
3144
CancellationToken cancellationToken = default)
3245
{

src/CheckoutSdk/Forward/IForwardClient.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55

66
namespace Checkout.Forward
77
{
8+
/// <summary>
9+
/// Forward
10+
/// </summary>
811
public interface IForwardClient
912
{
1013
/// <summary>
11-
/// Forward an API request<br />
12-
/// <b>Beta</b><br />
13-
/// Forwards an API request to a third-party endpoint.<br />
14-
/// For example, you can forward payment credentials you've stored in our Vault to a third-party payment processor.
14+
/// Forward an API request
15+
/// [BETA]
16+
/// Forwards an API request to a third-party endpoint.
17+
/// For example, you can forward payment credentials you've stored in our Vault to a third-party payment processor.
1518
/// </summary>
1619
Task<ForwardAnApiResponse> ForwardAnApiRequest(ForwardRequest forwardRequest,
1720
CancellationToken cancellationToken = default);
1821

1922
/// <summary>
20-
/// Get forward request<br />
21-
/// Retrieve the details of a successfully forwarded API request.<br />
22-
/// The details can be retrieved for up to 14 days after the request was initiated.
23+
/// Get forward request
24+
/// Retrieve the details of a successfully forwarded API request.
25+
/// The details can be retrieved for up to 14 days after the request was initiated.
2326
/// </summary>
2427
Task<GetForwardResponse> GetForwardRequest(string forwardId, CancellationToken cancellationToken = default);
2528
}

src/CheckoutSdk/ICheckoutApi.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Checkout.Forward;
99
using Checkout.Instruments;
1010
using Checkout.Metadata;
11+
using Checkout.NetworkTokens;
1112
using Checkout.Payments;
1213
using Checkout.Payments.Contexts;
1314
using Checkout.Payments.Hosted;
@@ -65,5 +66,7 @@ public interface ICheckoutApi : ICheckoutApiClient
6566
IPaymentSessionsClient PaymentSessionsClient();
6667

6768
IForwardClient ForwardClient();
69+
70+
INetworkTokenClient NetworkTokenClient();
6871
}
69-
}
72+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Checkout.NetworkTokens.Common.Responses
2+
{
3+
public class Card
4+
{
5+
/// <summary> The last four digits of the card number (Required, constraints: ^[0-9]{4}$) </summary>
6+
public string Last4 { get; set; }
7+
8+
/// <summary> The card's expiration month (Required, constraints: [ 1 .. 12 ], ^[0-9]{1,2}$) </summary>
9+
public string ExpiryMonth { get; set; }
10+
11+
/// <summary> The card's expiration year (Required, constraints: ^[0-9]{4}$) </summary>
12+
public string ExpiryYear { get; set; }
13+
}
14+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
namespace Checkout.NetworkTokens.Common.Responses
2+
{
3+
public class NetworkToken
4+
{
5+
/// <summary> Unique token ID assigned by Checkout.com for each token (Required) </summary>
6+
public string Id { get; set; }
7+
8+
/// <summary> Token status (Required) </summary>
9+
public StateType State { get; set; }
10+
11+
/// <summary>
12+
/// The network token number. This field is only returned when the network token status is one of the
13+
/// following: active, suspended, inactive (Constraints: ^[0-9]+$)
14+
/// </summary>
15+
public string Number { get; set; }
16+
17+
/// <summary>
18+
/// The network token's expiration month. This field is only returned when the network token status is
19+
/// one of the following: active, suspended, inactive (Constraints: ^[0-9]{1,2}$)
20+
/// </summary>
21+
public string ExpiryMonth { get; set; }
22+
23+
/// <summary>
24+
/// The network token's expiration year. This field is only returned when the network token status is
25+
/// one of the following: active, suspended, inactive (Constraints: ^[0-9]{4}$)
26+
/// </summary>
27+
public string ExpiryYear { get; set; }
28+
29+
/// <summary> The type of token (Required) </summary>
30+
public NetworkTokenType Type { get; set; }
31+
32+
/// <summary> When the network token was created (Required) </summary>
33+
public string CreatedOn { get; set; }
34+
35+
/// <summary> When the network token was modified (Required) </summary>
36+
public string ModifiedOn { get; set; }
37+
38+
/// <summary>
39+
/// Unique Payment account reference value assigned to payment account. All affiliated payment tokens,
40+
/// as well as the underlying PAN, have the same payment_account_reference (Optional)
41+
/// </summary>
42+
public string PaymentAccountReference { get; set; }
43+
44+
}
45+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Checkout.Common;
2+
3+
namespace Checkout.NetworkTokens.Common.Responses
4+
{
5+
public class NetworkTokenResponse : Resource
6+
{
7+
/// <summary> The card details (Required: true) </summary>
8+
public Card Card { get; set; }
9+
10+
/// <summary> Network token details (Required: true) </summary>
11+
public NetworkToken NetworkToken { get; set; }
12+
13+
/// <summary> Token requestor ID (Required: false) </summary>
14+
public string TokenRequestorId { get; set; }
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Checkout.NetworkTokens.Common.Responses
4+
{
5+
public enum NetworkTokenType
6+
{
7+
[EnumMember(Value = "vts")] Vts,
8+
9+
[EnumMember(Value = "mdes")] Mdes,
10+
11+
}
12+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Checkout.NetworkTokens.Common.Responses
4+
{
5+
public enum StateType
6+
{
7+
[EnumMember(Value = "active")]
8+
Active,
9+
10+
[EnumMember(Value = "suspended")]
11+
Suspended,
12+
13+
[EnumMember(Value = "inactive")]
14+
Inactive,
15+
16+
[EnumMember(Value = "declined")]
17+
Declined,
18+
19+
[EnumMember(Value = "requested")]
20+
Requested
21+
}
22+
}

0 commit comments

Comments
 (0)