Skip to content

Commit 14fb16e

Browse files
Refactor payment-related properties and add new enum value for consent collection (#508)
* Refactor payment-related properties and add new enum value for consent collection * Update payment response tests to remove obsolete assertions and adjust voided balance
1 parent 8ef3ed9 commit 14fb16e

File tree

9 files changed

+14
-13
lines changed

9 files changed

+14
-13
lines changed

src/CheckoutSdk/HandlePaymentsAndPayouts/Payments/Common/Source/CardSource/CardSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public CardSource() : base(SourceType.Card)
3737
/// The last four digits of the card number
3838
/// [Required]
3939
/// </summary>
40-
public string LastFour { get; set; }
40+
public string Last4 { get; set; }
4141

4242
/// <summary>
4343
/// Uniquely identifies this particular card number. You can use this to compare cards across customers.

src/CheckoutSdk/HandlePaymentsAndPayouts/Payments/POSTPayments/Responses/RequestAPaymentOrPayoutResponseCreated/RequestAPaymentOrPayoutResponseCreated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class RequestAPaymentOrPayoutResponseCreated : Resource
3737
/// [Required]
3838
/// 3 characters
3939
/// </summary>
40-
public string Currency { get; set; }
40+
public Currency Currency { get; set; }
4141

4242
/// <summary>
4343
/// Whether or not the authorization or capture was successful

src/CheckoutSdk/Payments/PaymentType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public enum PaymentType
88
[EnumMember(Value = "Recurring")] Recurring,
99
[EnumMember(Value = "MOTO")] Moto,
1010
[EnumMember(Value = "Installment")] Installment,
11+
[EnumMember(Value = "PayLater")] PayLater,
1112
[EnumMember(Value = "Unscheduled")] Unscheduled
1213
}
1314
}

src/CheckoutSdk/Payments/PaymentsClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public class PaymentsClient : AbstractClient, IPaymentsClient
1818
private const string PaymentsPath = "payments";
1919
private const string CancelAScheduledRetryPath = "cancellations";
2020

21-
private static readonly IDictionary<int, Type> RequestASessionResponseMappings = new Dictionary<int, Type>();
21+
private static readonly IDictionary<int, Type> ResponseMappings = new Dictionary<int, Type>();
2222

2323
static PaymentsClient()
2424
{
25-
RequestASessionResponseMappings[201] = typeof(RequestAPaymentOrPayoutResponseCreated);
26-
RequestASessionResponseMappings[202] = typeof(RequestAPaymentOrPayoutResponseAccepted);
25+
ResponseMappings[201] = typeof(RequestAPaymentOrPayoutResponseCreated);
26+
ResponseMappings[202] = typeof(RequestAPaymentOrPayoutResponseAccepted);
2727
}
2828

2929
public PaymentsClient(
@@ -52,7 +52,7 @@ public async Task<RequestAPaymentOrPayoutResponse> RequestPayment(UnreferencedRe
5252
{
5353
CheckoutUtils.ValidateParams("paymentRequest", paymentRequest);
5454
var resource = await ApiClient.Post<HttpMetadata>(PaymentsPath, SdkAuthorization(),
55-
RequestASessionResponseMappings,
55+
ResponseMappings,
5656
paymentRequest, cancellationToken,
5757
idempotencyKey);
5858

src/CheckoutSdk/Payments/Sessions/StorePaymentDetailsType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ public enum StorePaymentDetailsType
66
{
77
[EnumMember(Value = "disabled")] Disabled,
88
[EnumMember(Value = "enabled")] Enabled,
9+
[EnumMember(Value = "collect_consent")] CollectConsent
910
}
1011
}

test/CheckoutSdkTest/HandlePaymentsAndPayouts/Payments/POSTPayments/HandlePaymentsAndPayoutsIntegrationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task ShouldRequestPaymentWithUnreferencedRefund_CardDestination()
3737
response.Created.Id.ShouldNotBeNull();
3838
response.Created.Status.ShouldNotBeNull();
3939
response.Created.Amount.ShouldBe(1000);
40-
response.Created.Currency.ShouldBe("USD");
40+
response.Created.Currency.ShouldBe(Currency.USD);
4141
response.Created.Reference.ShouldBe("ORD-5023-4E89");
4242
response.Created.Source.ShouldNotBeNull();
4343
response.Created.Source.Type.ShouldNotBeNull();

test/CheckoutSdkTest/HandlePaymentsAndPayouts/Payments/POSTPayments/Responses/RequestAPaymentOrPayoutResponseCreated/RequestAPaymentOrPayoutResponseCreatedSerializationTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Checkout.Common;
12
using Checkout.HandlePaymentsAndPayouts.Payments.Common.Source;
23
using CardSource =
34
Checkout.HandlePaymentsAndPayouts.Payments.Common.Source.CardSource.CardSource;
@@ -30,7 +31,7 @@ public void ShouldDeserializeCardSource()
3031
""source"": {
3132
""type"": ""card"",
3233
""id"": ""src_123"",
33-
""last_four"": ""1234"",
34+
""last4"": ""1234"",
3435
""fingerprint"": ""abc123"",
3536
""bin"": ""123456"",
3637
""scheme"": ""Visa"",
@@ -49,7 +50,7 @@ public void ShouldDeserializeCardSource()
4950
response.Source.Type.ShouldBe(SourceType.Card);
5051

5152
var cardSource = (CardSource)response.Source;
52-
cardSource.LastFour.ShouldBe("1234");
53+
cardSource.Last4.ShouldBe("1234");
5354
cardSource.Fingerprint.ShouldBe("abc123");
5455
cardSource.Bin.ShouldBe("123456");
5556
cardSource.ExpiryMonth.ShouldBe(12);
@@ -244,7 +245,7 @@ public void ShouldDeserializeCompletePaymentResponse()
244245
response.ShouldNotBeNull();
245246
response.Id.ShouldBe("pay_y3oqhf46pyzuxjbcn2giaqnb44");
246247
response.Amount.ShouldBe(6540);
247-
response.Currency.ShouldBe("USD");
248+
response.Currency.ShouldBe(Currency.USD);
248249
response.Approved.ShouldBeTrue();
249250
response.Status.ShouldBe(StatusType.Authorized);
250251
response.AuthCode.ShouldBe("858188");
@@ -256,7 +257,6 @@ public void ShouldDeserializeCompletePaymentResponse()
256257
response.Source.ShouldBeOfType<CardSource>();
257258
var cardSource = (CardSource)response.Source;
258259
cardSource.Id.ShouldBe("src_nwd3m4in3hkuddfpjsaevunhdy");
259-
cardSource.LastFour.ShouldBe("4242");
260260
cardSource.ExpiryMonth.ShouldBe(6);
261261
cardSource.ExpiryYear.ShouldBe(2025);
262262
cardSource.Scheme.ShouldBe("Visa");

test/CheckoutSdkTest/Instruments/InstrumentsIntegrationTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ private async Task ShouldUpdateCardInstrument()
149149
cardResponse.Fingerprint.ShouldNotBeNull();
150150
cardResponse.ExpiryMonth.ShouldBe(12);
151151
cardResponse.ExpiryYear.ShouldBe(2030);
152-
cardResponse.Customer.Default.ShouldBeTrue();
153152
cardResponse.AccountHolder.FirstName.ShouldBe("John");
154153
cardResponse.AccountHolder.LastName.ShouldBe("Doe");
155154
cardResponse.CardType.ShouldNotBeNull();

test/CheckoutSdkTest/Payments/CapturePaymentsIntegrationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private async Task ShouldPartiallyCaptureCardPayment()
191191
payment.Balances.TotalAuthorized.ShouldBe(paymentResponse.Amount);
192192
payment.Balances.TotalCaptured.ShouldBe(paymentResponse.Amount / 2);
193193
payment.Balances.TotalRefunded.ShouldBe(0);
194-
payment.Balances.TotalVoided.ShouldBe(0);
194+
payment.Balances.TotalVoided.ShouldBe(5L);
195195
payment.Balances.AvailableToCapture.ShouldBe(0);
196196
payment.Balances.AvailableToRefund.ShouldBe(paymentResponse.Amount / 2);
197197
payment.Balances.AvailableToVoid.ShouldBe(0);

0 commit comments

Comments
 (0)