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
4 changes: 3 additions & 1 deletion src/main/java/com/checkout/common/PaymentMethodType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public enum PaymentMethodType {
BENEFIT,
@SerializedName("bizum")
BIZUM,
@SerializedName("blik")
BLIK,
@SerializedName("boost")
BOOST,
@SerializedName("bpi")
Expand Down Expand Up @@ -134,7 +136,7 @@ public enum PaymentMethodType {
VISA,
@SerializedName("wechatpay")
WECHATPAY,

// Payment method categories
@SerializedName("card_scheme")
CARD_SCHEME,
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/com/checkout/GsonSerializerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.checkout;

import com.checkout.common.PaymentMethodType;
import com.checkout.common.PaymentSourceType;
import com.checkout.financial.FinancialActionsQueryResponse;
import com.checkout.issuing.cardholders.CardholderCardsResponse;
Expand Down Expand Up @@ -202,6 +203,21 @@ void shouldDeserializeProductWithUnknownEnumValue() {
assertNull(productResponse.getTypeAsEnum());
}

@Test
void shouldSerializePaymentMethodTypeBlikCorrectly() {
// Test that BLIK payment method type serializes to "blik"
String json = serializer.toJson(PaymentMethodType.BLIK);
assertEquals("\"blik\"", json);
}

@Test
void shouldDeserializePaymentMethodTypeBlikCorrectly() {
// Test that "blik" string deserializes to PaymentMethodType.BLIK
String json = "\"blik\"";
PaymentMethodType paymentMethodType = serializer.fromJson(json, PaymentMethodType.class);
assertEquals(PaymentMethodType.BLIK, paymentMethodType);
}

@Test
void shouldDeserializeProductWithNullType() {
String json = "{ \"Type\": null, \"name\": \"Product Name\" }";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,40 @@ private PaymentSessionCreateRequest createPaymentSessionCreateRequest() {
.build();
}

@Test
void shouldCreatePaymentSessionWithBlikInDisabledMethods() {
// Test BLIK in disabled payment methods list
final PaymentSessionCreateRequest request = PaymentSessionCreateRequest.builder()
.amount(1000L)
.currency(Currency.EUR)
.paymentType(PaymentType.REGULAR)
.reference("ORD-NO-BLIK-456")
.description("Payment without BLIK")
.displayName("No BLIK Test")
.processingChannelId(System.getenv("CHECKOUT_PROCESSING_CHANNEL_ID"))
.successUrl("https://example.com/payments/success")
.failureUrl("https://example.com/payments/failure")
.billing(createBillingInformation())
.billingDescriptor(createBillingDescriptor())
.risk(createRiskRequest())
.threeDS(createThreeDSRequest())
.capture(true)
.locale(LocaleType.EN_GB)
.enabledPaymentMethods(Collections.singletonList(PaymentMethodType.CARD))
.disabledPaymentMethods(Collections.singletonList(PaymentMethodType.BLIK))
.paymentMethodConfiguration(createPaymentMethodConfiguration())
.build();

final CompletableFuture<PaymentSessionResponse> future =
checkoutApi.flowClient().requestPaymentSession(request);
final PaymentSessionResponse response = future.join();

assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getPaymentSessionToken());
assertNotNull(response.getPaymentSessionSecret());
}

private PaymentSessionSubmitRequest createPaymentSessionSubmitRequest() {
return PaymentSessionSubmitRequest.builder()
.sessionData("encrypted_session_data")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,64 @@ void shouldDeserializePaymentSessionCreateRequestWithCustomerSummary() {
}, "Should deserialize PaymentSessionCreateRequest with Customer.CustomerSummary without GSON reflection errors");
}

@Test
void shouldSerializePaymentSessionCreateRequestWithBlikPaymentMethod() {
Customer customer = Customer.builder()
.email("blik@example.com")
.name("BLIK Customer")
.id("cust_blik_123")
.build();

PaymentSessionCreateRequest request = PaymentSessionCreateRequest.builder()
.amount(2000L)
.currency(Currency.EUR)
.reference("blik-ref-456")
.paymentType(PaymentType.REGULAR)
.description("Test BLIK payment")
.customer(customer)
.locale(LocaleType.EN_GB)
.enabledPaymentMethods(Collections.singletonList(PaymentMethodType.BLIK))
.capture(true)
.build();

assertDoesNotThrow(() -> {
String json = serializer.toJson(request);
assertNotNull(json);
assertTrue(json.contains("\"blik\""), "Should contain serialized BLIK payment method");
assertTrue(json.contains("blik@example.com"), "Should contain customer email");
assertTrue(json.contains("BLIK Customer"), "Should contain customer name");
}, "Should serialize PaymentSessionCreateRequest with BLIK payment method without errors");
}

@Test
void shouldDeserializePaymentSessionCreateRequestWithBlikPaymentMethod() {
String json = "{"
+ "\"amount\":2000,"
+ "\"currency\":\"EUR\","
+ "\"reference\":\"blik-ref-456\","
+ "\"payment_type\":\"Regular\","
+ "\"description\":\"Test BLIK payment\","
+ "\"customer\":{"
+ " \"email\":\"blik@example.com\","
+ " \"name\":\"BLIK Customer\","
+ " \"id\":\"cust_blik_123\""
+ "},"
+ "\"locale\":\"en-GB\","
+ "\"enabled_payment_methods\":[\"blik\"],"
+ "\"capture\":true"
+ "}";

assertDoesNotThrow(() -> {
PaymentSessionCreateRequest request = serializer.fromJson(json, PaymentSessionCreateRequest.class);
assertNotNull(request);
assertNotNull(request.getEnabledPaymentMethods());
assertEquals(1, request.getEnabledPaymentMethods().size());
assertEquals(PaymentMethodType.BLIK, request.getEnabledPaymentMethods().get(0));
assertEquals("blik@example.com", request.getCustomer().getEmail());
assertEquals("BLIK Customer", request.getCustomer().getName());
}, "Should deserialize PaymentSessionCreateRequest with BLIK payment method without errors");
}

@Test
void shouldRoundTripSerializePaymentSessionCreateRequestWithCustomer() {
Customer.CustomerSummary summary = Customer.CustomerSummary.builder()
Expand Down
Loading