Skip to content

Commit b49ac18

Browse files
Refactor payment context classes and update PaymentSessionsClient authorization type
1 parent ee68827 commit b49ac18

File tree

10 files changed

+65
-51
lines changed

10 files changed

+65
-51
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using Checkout.Common;
2+
using Checkout.Payments.Contexts;
23
using System;
34
using System.Collections.Generic;
45

5-
namespace Checkout.Payments.Contexts
6+
namespace Checkout.Payments
67
{
7-
public class PaymentContextsAccommodationData
8+
public class AccommodationData
89
{
910
public string Name { get; set; }
1011

src/CheckoutSdk/Payments/Contexts/PaymentContextsProcessing.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Checkout.Payments.Request.Source.Contexts;
21
using System.Collections.Generic;
32

43
namespace Checkout.Payments.Contexts
@@ -23,12 +22,12 @@ public class PaymentContextsProcessing
2322

2423
public UserAction? UserAction { get; set; }
2524

26-
public PaymentContextsPartnerCustomerRiskData PartnerCustomerRiskData { get; set; }
25+
public PartnerCustomerRiskData PartnerCustomerRiskData { get; set; }
2726

2827
public IList<string> CustomPaymentMethodIds { get; set; }
2928

3029
public IList<PaymentContextsAirlineData> AirlineData { get; set; }
3130

32-
public IList<PaymentContextsAccommodationData> AccommodationData { get; set; }
31+
public IList<AccommodationData> AccommodationData { get; set; }
3332
}
3433
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
namespace Checkout.Payments.Contexts
1+
namespace Checkout.Payments
22
{
3-
public class PaymentContextsPartnerCustomerRiskData
3+
public class PartnerCustomerRiskData
44
{
55
public string Key { get; set; }
66

src/CheckoutSdk/Payments/ProcessingSettings.cs

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,77 @@ namespace Checkout.Payments
66
{
77
public class ProcessingSettings
88
{
9-
public string OrderId { get; set; }
10-
9+
public bool? Aft { get; set; }
10+
11+
public long? DiscountAmount { get; set; }
12+
13+
public long? ShippingAmount { get; set; }
14+
1115
public long? TaxAmount { get; set; }
16+
17+
public string InvoiceId { get; set; }
18+
19+
public string BrandName { get; set; }
1220

13-
public long? DiscountAmount { get; set; }
21+
public string Locale { get; set; }
22+
23+
24+
public PartnerCustomerRiskData PartnerCustomerRiskData { get; set; }
25+
26+
public IList<string> CustomPaymentMethodIds { get; set; }
27+
28+
public IList<AirlineData> AirlineData { get; set; }
29+
30+
public IList<AccommodationData> AccommodationData { get; set; }
31+
32+
public string OrderId { get; set; }
33+
34+
public long? SurchargeAmount { get; set; }
1435

1536
public long? DutyAmount { get; set; }
16-
17-
public long? ShippingAmount { get; set; }
18-
1937
public long? ShippingTaxAmount { get; set; }
2038

21-
public bool? Aft { get; set; }
22-
23-
public PreferredSchema? PreferredScheme { get; set; }
24-
39+
public CountryCode? PurchaseCountry { get; set; }
2540
public MerchantInitiatedReason? MerchantInitiatedReason { get; set; }
2641

2742
public long? CampaignId { get; set; }
43+
44+
public long? OriginalOrderAmount { get; set; }
45+
46+
public string ReceiptId { get; set; }
47+
48+
public string MerchantCallbackUrl { get; set; }
49+
50+
public string LineOfBusiness { get; set; }
51+
52+
public PanProcessedType? PanPreference { get; set; }
53+
54+
public bool? ProvisionNetworkToken { get; set; }
55+
56+
public PreferredSchema? PreferredScheme { get; set; }
2857

2958
public ProductType? ProductType { get; set; }
3059

3160
public string OpenId { get; set; }
3261

33-
public long? OriginalOrderAmount { get; set; }
34-
35-
public string ReceiptId { get; set; }
36-
3762
public TerminalType? TerminalType { get; set; }
3863

3964
public OsType? OsType { get; set; }
40-
41-
public string InvoiceId { get; set; }
42-
43-
public string BrandName { get; set; }
44-
45-
public string Locale { get; set; }
46-
65+
4766
public ShippingPreference? ShippingPreference { get; set; }
4867

4968
public UserAction? UserAction { get; set; }
5069

5170
public IList<IDictionary<string, string>> SetTransactionContext { get; set; }
5271

53-
public IList<AirlineData> AirlineData { get; set; }
54-
5572
public DLocalProcessingSettings Dlocal { get; set; }
5673

5774
public string OtpValue { get; set; }
5875

59-
public CountryCode? PurchaseCountry { get; set; }
60-
61-
public IList<string> CustomPaymentMethodIds { get; set; }
62-
63-
public string MerchantCallbackUrl { get; set; }
64-
65-
public string LineOfBusiness { get; set; }
66-
6776
public long? ShippingDelay { get; set; }
6877

6978
public IList<ShippingInfo> ShippingInfo { get; set; }
7079

71-
public PanProcessedType? PanPreference { get; set; }
72-
7380
[JsonProperty(PropertyName = "senderInformation")]
7481
public string SenderInformation { get; set; }
7582
}

src/CheckoutSdk/Payments/Response/GetPaymentResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class GetPaymentResponse : Resource
8888

8989
public bool? CkoNetworkTokenAvailable { get; set; }
9090

91-
public Request.PaymentInstruction Instruction { get; set; }
91+
public PaymentInstruction Instruction { get; set; }
9292

9393

9494
}

src/CheckoutSdk/Payments/Sessions/PaymentSessionsClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class PaymentSessionsClient : AbstractClient, IPaymentSessionsClient
88
private const string PaymentSessionsPath = "payment-sessions";
99

1010
public PaymentSessionsClient(IApiClient apiClient, CheckoutConfiguration configuration) : base(apiClient,
11-
configuration, SdkAuthorizationType.SecretKey)
11+
configuration, SdkAuthorizationType.SecretKeyOrOAuth)
1212
{
1313
}
1414

src/CheckoutSdk/Payments/Sessions/PaymentSessionsRequest.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ public class PaymentSessionsRequest
1414

1515
public Currency? Currency { get; set; }
1616

17+
public BillingInformation Billing { get; set; }
18+
19+
public string SuccessUrl { get; set; }
20+
21+
public string FailureUrl { get; set; }
22+
1723
public PaymentType? PaymentType { get; set; }
1824

19-
public BillingInformation Billing { get; set; }
2025

2126
public BillingDescriptor BillingDescriptor { get; set; }
2227

@@ -31,6 +36,8 @@ public class PaymentSessionsRequest
3136
public PaymentRecipient Recipient { get; set; }
3237

3338
public ProcessingSettings Processing { get; set; }
39+
40+
public PaymentInstruction Instruction { get; set; }
3441

3542
public string ProcessingChannelId { get; set; }
3643

@@ -52,13 +59,10 @@ public class PaymentSessionsRequest
5259

5360
public string DisplayName { get; set; }
5461

55-
public string SuccessUrl { get; set; }
56-
57-
public string FailureUrl { get; set; }
5862

5963
public IDictionary<string, object> Metadata { get; set; } = new Dictionary<string, object>();
6064

61-
public string Locale { get; set; }
65+
public LocaleType? Locale { get; set; }
6266

6367
[JsonProperty(PropertyName = "3ds")]
6468
public ThreeDsRequest ThreeDs { get; set; }

src/CheckoutSdk/Payments/Sessions/PaymentSessionsResponse.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ public class PaymentSessionsResponse : Resource
88
public string Id { get; set; }
99

1010
public string PaymentSessionToken { get; set; }
11+
12+
public string PaymentSessionSecret { get; set; }
13+
1114
}
1215
}

test/CheckoutSdkTest/Payments/Hosted/HostedPaymentsIntegrationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected static HostedPaymentRequest CreateHostedPaymentRequest()
158158
CaptureOn = DateTime.UtcNow,
159159
Instruction = new PaymentInstruction
160160
{
161-
Purpose = PaymentPurposeType.Donations
161+
Purpose = PaymentPurposeType.Donations,
162162
},
163163
PaymentMethodConfiguration = new PaymentMethodConfiguration
164164
{

test/CheckoutSdkTest/Payments/Sessions/PaymentSessionsClientTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class PaymentSessionsClientTest : UnitTestFixture
2222

2323
public PaymentSessionsClientTest()
2424
{
25-
_sdkCredentials.Setup(credentials => credentials.GetSdkAuthorization(SdkAuthorizationType.SecretKey))
25+
_sdkCredentials.Setup(credentials => credentials.GetSdkAuthorization(SdkAuthorizationType.SecretKeyOrOAuth))
2626
.Returns(_authorization);
2727

2828
_configuration = new Mock<CheckoutConfiguration>(_sdkCredentials.Object,
@@ -33,14 +33,14 @@ public PaymentSessionsClientTest()
3333
private async Task ShouldRequestAPaymentSessions()
3434
{
3535
PaymentSessionsRequest paymentSessionsRequest = new PaymentSessionsRequest();
36-
PaymentSessionsResponse paymentSessionsRequestResponse = new PaymentSessionsResponse();
36+
PaymentSessionsResponse paymentSessionsResponse = new PaymentSessionsResponse();
3737

3838
_apiClient.Setup(apiClient =>
3939
apiClient.Post<PaymentSessionsResponse>(PaymentSessions, _authorization,
4040
paymentSessionsRequest,
4141
CancellationToken.None,
4242
null))
43-
.ReturnsAsync(() => paymentSessionsRequestResponse);
43+
.ReturnsAsync(() => paymentSessionsResponse);
4444

4545
PaymentSessionsClient client = new PaymentSessionsClient(_apiClient.Object, _configuration.Object);
4646
PaymentSessionsResponse response =

0 commit comments

Comments
 (0)