From ec9b8c44f7f61008f5a8fb3b575cb63908ce68f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Rodr=C3=ADguez?= <127134616+armando-rodriguez-cko@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:28:30 +0100 Subject: [PATCH] Improve deserialization --- .../java/com/checkout/GsonSerializer.java | 29 ++- .../com/checkout/payments/AirlineData.java | 2 +- .../contexts/PaymentContextsAirlineData.java | 2 +- .../java/com/checkout/GsonSerializerTest.java | 34 ++++ .../com/checkout/payments/CaptureTestIT.java | 29 --- ...yment_context_klarna_details_response.json | 149 +++++++++++++++ ...yment_context_paypal_details_response.json | 173 ++++++++++++++---- .../response/get_payment_klarna_response.json | 92 ++++++++++ 8 files changed, 438 insertions(+), 72 deletions(-) create mode 100644 src/test/resources/mocks/payments/response/contexts/payment_context_klarna_details_response.json create mode 100644 src/test/resources/mocks/payments/response/get_payment_klarna_response.json diff --git a/src/main/java/com/checkout/GsonSerializer.java b/src/main/java/com/checkout/GsonSerializer.java index 9ce88e2b..ae498b8f 100644 --- a/src/main/java/com/checkout/GsonSerializer.java +++ b/src/main/java/com/checkout/GsonSerializer.java @@ -273,27 +273,48 @@ private static JsonDeserializer getScheduleResponseDeserial private static JsonDeserializer getInstantJsonDeserializer() { return (json, typeOfT, context) -> { - final String dateString = json.getAsString(); + String dateString; + + // Check if the JSON is a number or a string + if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isNumber()) { + dateString = String.valueOf(json.getAsLong()); // Convert numeric value to string + } else { + dateString = json.getAsString(); // Use the string value directly + } + try { + // Try parsing the string as an ISO-8601 Instant return Instant.parse(dateString); } catch (final DateTimeParseException ex) { - if (dateString.length() == 8) { + if (dateString.matches("\\d{8}")) { // Handle numeric format yyyyMMdd try { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); LocalDateTime dateTime = LocalDate.parse(dateString, formatter).atStartOfDay(); return dateTime.toInstant(ZoneOffset.UTC); } catch (final DateTimeParseException e) { - throw new JsonParseException("Failed to parse date in format yyyyMMdd: " + dateString, e); + throw new JsonParseException("Failed to parse numeric date in format yyyyMMdd: " + dateString, e); + } + } + // Explicitly handle the yyyy-MM-dd format + if (dateString.length() == 10) { // Handle format yyyy-MM-dd + try { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate date = LocalDate.parse(dateString, formatter); + return date.atStartOfDay().toInstant(ZoneOffset.UTC); + } catch (final DateTimeParseException e) { + throw new JsonParseException("Failed to parse date in format yyyy-MM-dd: " + dateString, e); } } + // Attempt parsing with the DEFAULT_FORMATTERS for (final DateTimeFormatter formatter : DEFAULT_FORMATTERS) { try { final LocalDateTime dateTime = LocalDateTime.parse(dateString, formatter); return dateTime.toInstant(ZoneOffset.UTC); } catch (final DateTimeParseException ignored) { - // continue to next formatter + // Continue with the next formatter } } + // Rethrow the original exception if no format matches throw ex; } }; diff --git a/src/main/java/com/checkout/payments/AirlineData.java b/src/main/java/com/checkout/payments/AirlineData.java index 7cb7018a..eb962e2a 100644 --- a/src/main/java/com/checkout/payments/AirlineData.java +++ b/src/main/java/com/checkout/payments/AirlineData.java @@ -16,7 +16,7 @@ public final class AirlineData { private Ticket ticket; - private Passenger passenger; + private List passenger; @SerializedName("flight_leg_details") private List flightLegDetails; diff --git a/src/main/java/com/checkout/payments/contexts/PaymentContextsAirlineData.java b/src/main/java/com/checkout/payments/contexts/PaymentContextsAirlineData.java index bacf34be..6de5609e 100644 --- a/src/main/java/com/checkout/payments/contexts/PaymentContextsAirlineData.java +++ b/src/main/java/com/checkout/payments/contexts/PaymentContextsAirlineData.java @@ -14,7 +14,7 @@ @AllArgsConstructor public final class PaymentContextsAirlineData { - private List ticket; + private PaymentContextsTicket ticket; private List passenger; diff --git a/src/test/java/com/checkout/GsonSerializerTest.java b/src/test/java/com/checkout/GsonSerializerTest.java index 3cad9ad7..86230b2f 100644 --- a/src/test/java/com/checkout/GsonSerializerTest.java +++ b/src/test/java/com/checkout/GsonSerializerTest.java @@ -10,6 +10,8 @@ import com.checkout.payments.previous.response.PaymentResponse; import com.checkout.payments.previous.response.destination.PaymentResponseAlternativeDestination; import com.checkout.payments.previous.response.destination.PaymentResponseCardDestination; +import com.checkout.payments.response.source.AlternativePaymentSourceResponse; +import com.checkout.payments.response.source.contexts.PaymentContextsKlarnaResponseSource; import com.checkout.payments.response.source.contexts.PaymentContextsPayPalResponseSource; import com.checkout.payments.sender.PaymentCorporateSender; import com.checkout.payments.sender.ResponseAlternativeSender; @@ -121,6 +123,16 @@ void shouldGetFinancial() { assertNotNull(actionsQueryResponse.getData().get(0).getRequestedOn()); } + @Test + void shouldSerializePaymentKlarnaDetailsResponseFromJson() { + + final com.checkout.payments.response.GetPaymentResponse paymentKlarnaResponseSource = serializer.fromJson(getMock("/mocks/payments/response/get_payment_klarna_response.json"), com.checkout.payments.response.GetPaymentResponse.class); + + assertNotNull(paymentKlarnaResponseSource); + assertTrue(paymentKlarnaResponseSource.getSource() instanceof AlternativePaymentSourceResponse); + assertEquals(PaymentSourceType.KLARNA, paymentKlarnaResponseSource.getSource().getType()); + } + @Test void shouldSerializePaymentContextsPayPalDetailsResponseFromJson() { @@ -131,6 +143,16 @@ void shouldSerializePaymentContextsPayPalDetailsResponseFromJson() { assertEquals(PaymentSourceType.PAYPAL, paymentContextsPayPalResponseSource.getPaymentRequest().getSource().getType()); } + @Test + void shouldSerializePaymentContextsKlarnaDetailsResponseFromJson() { + + final PaymentContextDetailsResponse paymentKlarnaResponseSource = serializer.fromJson(getMock("/mocks/payments/response/contexts/payment_context_klarna_details_response.json"), PaymentContextDetailsResponse.class); + + assertNotNull(paymentKlarnaResponseSource); + assertTrue(paymentKlarnaResponseSource.getPaymentRequest().getSource() instanceof PaymentContextsKlarnaResponseSource); + assertEquals(PaymentSourceType.KLARNA, paymentKlarnaResponseSource.getPaymentRequest().getSource().getType()); + } + @Test void shouldSerializePaymentContextsResponseFromJson() { @@ -160,6 +182,18 @@ void shouldDeserializeMultipleDateFormats() { assertNotNull(paymentResponse.getProcessedOn()); assertEquals(instant, paymentResponse.getProcessedOn()); + // Test format yyyyMMdd number + paymentResponse = serializer.fromJson("{\"processed_on\":20210608}", PaymentResponse.class); + assertNotNull(paymentResponse); + assertNotNull(paymentResponse.getProcessedOn()); + assertEquals(instant, paymentResponse.getProcessedOn()); + + // Test format yyyy-MM-dd + paymentResponse = serializer.fromJson("{\"processed_on\":\"2021-06-08\"}", PaymentResponse.class); + assertNotNull(paymentResponse); + assertNotNull(paymentResponse.getProcessedOn()); + assertEquals(instant, paymentResponse.getProcessedOn()); + // Test other valid formats paymentResponse = serializer.fromJson("{\"processed_on\":\"2021-06-08T12:25:01.000Z\"}", PaymentResponse.class); assertNotNull(paymentResponse); diff --git a/src/test/java/com/checkout/payments/CaptureTestIT.java b/src/test/java/com/checkout/payments/CaptureTestIT.java index 20a5dd0f..6262902f 100644 --- a/src/test/java/com/checkout/payments/CaptureTestIT.java +++ b/src/test/java/com/checkout/payments/CaptureTestIT.java @@ -1,7 +1,6 @@ package com.checkout.payments; import com.checkout.TestHelper; -import com.checkout.common.CountryCode; import com.checkout.payments.request.PaymentCustomerRequest; import com.checkout.payments.response.PaymentResponse; import org.junit.jupiter.api.Test; @@ -81,34 +80,6 @@ void shouldCaptureCardPayment() { .locale("en-US") .shippingPreference(ShippingPreference.SET_PROVIDED_ADDRESS) .userAction(UserAction.PAY_NOW) - .airlineData(Collections.singletonList(AirlineData.builder() - .ticket(Ticket.builder() - .number("123654") - .issueDate("stringstri") - .issuingCarrierCode("st") - .travelAgencyName("agency") - .travelAgencyCode("code") - .build()) - .passenger(Passenger.builder() - .name(PassengerName.builder() - .fullName("a passenger") - .build()) - .dateOfBirth("birth") - .countryCode(CountryCode.ES) - .build()) - .flightLegDetails(Collections.singletonList(FlightLegDetails.builder() - .flightNumber(0L) - .carrierCode("carrier") - .serviceClass("service") - .departureDate("date") - .departureTime("time") - .departureAirport("airport") - .arrivalAirport("arrival") - .stopoverCode("stopover") - .fareBasisCode("fare") - .build())) - - .build())) .lineOfBusiness("Flights") .build()) .metadata(metadata) diff --git a/src/test/resources/mocks/payments/response/contexts/payment_context_klarna_details_response.json b/src/test/resources/mocks/payments/response/contexts/payment_context_klarna_details_response.json new file mode 100644 index 00000000..a578bd26 --- /dev/null +++ b/src/test/resources/mocks/payments/response/contexts/payment_context_klarna_details_response.json @@ -0,0 +1,149 @@ +{ + "status": "Approved", + "payment_request": { + "source": { + "type": "klarna" + }, + "amount": 6540, + "currency": "USD", + "payment_type": "Recurring", + "capture": true, + "customer": { + "email": "johnsmith@example.com", + "name": "John Smith" + }, + "shipping": { + "first_name": "John", + "last_name": "Smith", + "email": "john.smith@example.com", + "address": { + "address_line1": "123 High St.", + "address_line2": "Flat 456", + "city": "London", + "state": "str", + "zip": "SW1A 1AA", + "country": "GB" + }, + "phone": { + "country_code": "+1", + "number": "415 555 2671" + }, + "from_address_zip": "123456", + "timeframe": "SameDay", + "method": "BillingAddress", + "delay": 5 + }, + "processing": { + "plan": { + "type": "MERCHANT_INITIATED_BILLING", + "skip_shipping_address": true, + "immutable_shipping_address": true + }, + "discount_amount": 5, + "shipping_amount": 300, + "tax_amount": 3000, + "invoice_id": "string", + "brand_name": "Acme Corporation", + "locale": "en-US", + "shipping_preference": "set_provided_address", + "user_action": "pay_now", + "partner_customer_risk_data": { + "key": "string", + "value": "string" + }, + "custom_payment_method_ids": [ + "string" + ], + "airline_data": [ + { + "ticket": { + "number": "045-21351455613", + "issue_date": "2023-05-20", + "issuing_carrier_code": "AI", + "travel_package_indicator": "B", + "travel_agency_name": "World Tours", + "travel_agency_code": "01" + }, + "passenger": [ + { + "first_name": "John", + "last_name": "White", + "date_of_birth": "1990-05-26", + "address": { + "country": null + } + } + ], + "flight_leg_details": [ + { + "flight_number": "101", + "carrier_code": "BA", + "class_of_travelling": "J", + "departure_airport": "LHR", + "departure_date": "2023-06-19", + "departure_time": "15:30", + "arrival_airport": "LAX", + "stop_over_code": "x", + "fare_basis_code": "SPRSVR" + } + ] + } + ], + "accommodation_data": [ + { + "name": "The Sea View Hotel", + "booking_reference": "HOTEL123", + "check_in_date": "2023-06-20", + "check_out_date": "2023-06-23", + "address": { + "address_line1": "123 Beach Road", + "zip": 10001 + }, + "state": "FL", + "country": "USA", + "city": "Los Angeles", + "number_of_rooms": 2, + "guests": [ + { + "first_name": "Jane", + "last_name": "Doe", + "date_of_birth": "1985-07-14" + } + ], + "room": [ + { + "rate": "70", + "number_of_nights_at_room_rate": "3" + } + ] + } + ] + }, + "processing_channel_id": "pc_q4dbxom5jbgudnjzjpz7j2z6uq", + "reference": "ORD-5023-4E89", + "description": "Set of 3 masks", + "success_url": "https://example.com/payments/success", + "failure_url": "https://example.com/payments/fail", + "items": [ + { + "type": "string", + "name": "Test item", + "quantity": 2, + "unit_price": 50, + "reference": "858818ac", + "total_amount": 29000, + "tax_rate": 2000, + "tax_amount": 1000, + "discount_amount": 1000, + "url": "string", + "image_url": "string" + } + ] + }, + "partner_metadata": { + "order_id": "test_order_123", + "customer_id": "cus_123", + "session_id": "feb0096d-8486-400d-89fa-2fa716b4521f", + "client_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjgyMzA1ZWJjLWI4MTEtMzYzNy1hYTRjLTY2ZWNhMTg3NGYzZCJ9.eyJzZXNzaW9uX2lkIjoiY2RiNDI0MGQtMTdkYy01MjJkLWJlYjEtYjAyYjRlMzllYTdhIiwiYmFzZV91cmwiOiJodHRwczovL2pzLnBsYXlncm91bmQua2xhcm5hLmNvbS9ldS9rcCIsImRlc2lnbiI6ImtsYXJuYSIsImxhbmd1YWdlIjoiZW4iLCJwdXJjaGFzZV9jb3VudHJ5IjoiREUiLCJlbnZpcm9ubWVudCI6InBsYXlncm91bmQiLCJtZXJjaGFudF9uYW1lIjoiQ2hlY2tvdXQuY29tIiwic2Vzc2lvbl90eXBlIjoiUEFZTUVOVFMiLCJjbGllbnRfZXZlbnRfYmFzZV91cmwiOiJodHRwczovL2V1LnBsYXlncm91bmQua2xhcm5hZXZ0LmNvbSIsInNjaGVtZSI6dHJ1ZSwiZXhwZXJpbWVudHMiOlt7Im5hbWUiOiJrcC1jbGllbnQtb25lLXB1cmNoYXNlLWZsb3ciLCJ2YXJpYXRlIjoidmFyaWF0ZS0xIn0seyJuYW1lIjoia3AtY2xpZW50LXV0b3BpYS1mbG93IiwidmFyaWF0ZSI6InZhcmlhdGUtMSJ9LHsibmFtZSI6ImtwYy0xay1zZXJ2aWNlIiwidmFyaWF0ZSI6InZhcmlhdGUtMSJ9LHsibmFtZSI6ImtwLWNsaWVudC11dG9waWEtc3RhdGljLXdpZGdldCIsInZhcmlhdGUiOiJpbmRleCIsInBhcmFtZXRlcnMiOnsiZHluYW1pYyI6InRydWUifX0seyJuYW1lIjoiaW4tYXBwLXNkay1uZXctaW50ZXJuYWwtYnJvd3NlciIsInBhcmFtZXRlcnMiOnsidmFyaWF0ZV9pZCI6Im5ldy1pbnRlcm5hbC1icm93c2VyLWVuYWJsZSJ9fSx7Im5hbWUiOiJrcC1jbGllbnQtdXRvcGlhLXNkay1mbG93IiwidmFyaWF0ZSI6InZhcmlhdGUtMSJ9LHsibmFtZSI6ImtwLWNsaWVudC11dG9waWEtd2Vidmlldy1mbG93IiwidmFyaWF0ZSI6InZhcmlhdGUtMSJ9LHsibmFtZSI6ImluLWFwcC1zZGstY2FyZC1zY2FubmluZyIsInBhcmFtZXRlcnMiOnsidmFyaWF0ZV9pZCI6ImNhcmQtc2Nhbm5pbmctZW5hYmxlIn19XSwicmVnaW9uIjoiZXUiLCJvcmRlcl9hbW91bnQiOjIwMDAsIm9mZmVyaW5nX29wdHMiOjAsIm9vIjoiY3ciLCJ2ZXJzaW9uIjoidjEuMTAuMC0xNTkwLWczZWJjMzkwNyJ9.ZxThQVo5e0Fck1vwOQ-WWAr7Zw-dsiEhjd3CW-E5p8atUhnBhrzIs6WCBeOOv3ci2VvpykVnDw2qycCTA-7TpTq1wn_kPxxixDQnYJYJzrZMoUhPLZo5pfy2a1S_t2owEQks0THRzu2wRlZwCN4ewDnVqsut60X4r3B92cJENIDtEC4Fs55CjFEmYUtsLXSspNLKvpZe2zg4O_M5yjH7XsBs5YJalZLexf4545G5vJrmVHgiA322mbgWC7BH0IU1A-ql5sFvs190_cjGaLsAvrkh9CVczUPy3X-jr3A5z1YRVfywPpvwKFWL8GZtgrdUZmgiU5_8ZZLkEPzrSucHrQ" + } +} \ No newline at end of file diff --git a/src/test/resources/mocks/payments/response/contexts/payment_context_paypal_details_response.json b/src/test/resources/mocks/payments/response/contexts/payment_context_paypal_details_response.json index b0375fe0..082d3337 100644 --- a/src/test/resources/mocks/payments/response/contexts/payment_context_paypal_details_response.json +++ b/src/test/resources/mocks/payments/response/contexts/payment_context_paypal_details_response.json @@ -1,50 +1,149 @@ { - "partner_metadata": { - "customer_id": "EWR4HCRWOEIW4", - "order_id": "NF89G5J9E5G905E90" - }, + "status": "Approved", "payment_request": { - "amount": 2500, - "authorization_type": "Final", + "source": { + "type": "paypal" + }, + "amount": 6540, + "currency": "USD", + "payment_type": "Recurring", "capture": true, - "currency": "GBP", - "failure_url": "https://url/payment-failed", - "items": [ - { - "discount_amount": 0, - "name": "£25.00 Voucher", - "quantity": 1, - "tax_amount": 0, - "total_amount": 2500, - "unit_price": 2500 - } - ], - "payment_type": "Regular", - "processing": { - "shipping_amount": 0, - "user_action": "PAY_NOW" + "customer": { + "email": "johnsmith@example.com", + "name": "John Smith" }, - "processing_channel_id": "pc_strugfrty47ellyymdfg6fzhc4i", - "reference": "543454", "shipping": { + "first_name": "John", + "last_name": "Smith", + "email": "john.smith@example.com", "address": { - "address_line1": "Main Address", - "address_line2": "Flor 1", + "address_line1": "123 High St.", + "address_line2": "Flat 456", "city": "London", - "country": "GB", - "state": "State", - "zip": "ZIP" + "state": "str", + "zip": "SW1A 1AA", + "country": "GB" }, - "first_name": "Andrey Young" + "phone": { + "country_code": "+1", + "number": "415 555 2671" + }, + "from_address_zip": "123456", + "timeframe": "SameDay", + "method": "BillingAddress", + "delay": 5 }, - "source": { - "account_holder": { - "email": "ayoung@fakedomain.com", - "full_name": "Andrey Young" + "processing": { + "plan": { + "type": "MERCHANT_INITIATED_BILLING", + "skip_shipping_address": true, + "immutable_shipping_address": true }, - "type": "paypal" + "discount_amount": 5, + "shipping_amount": 300, + "tax_amount": 3000, + "invoice_id": "string", + "brand_name": "Acme Corporation", + "locale": "en-US", + "shipping_preference": "set_provided_address", + "user_action": "pay_now", + "partner_customer_risk_data": { + "key": "string", + "value": "string" + }, + "custom_payment_method_ids": [ + "string" + ], + "airline_data": [ + { + "ticket": { + "number": "045-21351455613", + "issue_date": "2023-05-20", + "issuing_carrier_code": "AI", + "travel_package_indicator": "B", + "travel_agency_name": "World Tours", + "travel_agency_code": "01" + }, + "passenger": [ + { + "first_name": "John", + "last_name": "White", + "date_of_birth": "1990-05-26", + "address": { + "country": null + } + } + ], + "flight_leg_details": [ + { + "flight_number": "101", + "carrier_code": "BA", + "class_of_travelling": "J", + "departure_airport": "LHR", + "departure_date": "2023-06-19", + "departure_time": "15:30", + "arrival_airport": "LAX", + "stop_over_code": "x", + "fare_basis_code": "SPRSVR" + } + ] + } + ], + "accommodation_data": [ + { + "name": "The Sea View Hotel", + "booking_reference": "HOTEL123", + "check_in_date": "2023-06-20", + "check_out_date": "2023-06-23", + "address": { + "address_line1": "123 Beach Road", + "zip": 10001 + }, + "state": "FL", + "country": "USA", + "city": "Los Angeles", + "number_of_rooms": 2, + "guests": [ + { + "first_name": "Jane", + "last_name": "Doe", + "date_of_birth": "1985-07-14" + } + ], + "room": [ + { + "rate": "70", + "number_of_nights_at_room_rate": "3" + } + ] + } + ] }, - "success_url": "https://url/payment-successful" + "processing_channel_id": "pc_q4dbxom5jbgudnjzjpz7j2z6uq", + "reference": "ORD-5023-4E89", + "description": "Set of 3 masks", + "success_url": "https://example.com/payments/success", + "failure_url": "https://example.com/payments/fail", + "items": [ + { + "type": "string", + "name": "Test item", + "quantity": 2, + "unit_price": 50, + "reference": "858818ac", + "total_amount": 29000, + "tax_rate": 2000, + "tax_amount": 1000, + "discount_amount": 1000, + "url": "string", + "image_url": "string" + } + ] }, - "status": "Created" + "partner_metadata": { + "order_id": "test_order_123", + "customer_id": "cus_123", + "session_id": "feb0096d-8486-400d-89fa-2fa716b4521f", + "client_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjgyMzA1ZWJjLWI4MTEtMzYzNy1hYTRjLTY2ZWNhMTg3NGYzZCJ9.eyJzZXNzaW9uX2lkIjoiY2RiNDI0MGQtMTdkYy01MjJkLWJlYjEtYjAyYjRlMzllYTdhIiwiYmFzZV91cmwiOiJodHRwczovL2pzLnBsYXlncm91bmQua2xhcm5hLmNvbS9ldS9rcCIsImRlc2lnbiI6ImtsYXJuYSIsImxhbmd1YWdlIjoiZW4iLCJwdXJjaGFzZV9jb3VudHJ5IjoiREUiLCJlbnZpcm9ubWVudCI6InBsYXlncm91bmQiLCJtZXJjaGFudF9uYW1lIjoiQ2hlY2tvdXQuY29tIiwic2Vzc2lvbl90eXBlIjoiUEFZTUVOVFMiLCJjbGllbnRfZXZlbnRfYmFzZV91cmwiOiJodHRwczovL2V1LnBsYXlncm91bmQua2xhcm5hZXZ0LmNvbSIsInNjaGVtZSI6dHJ1ZSwiZXhwZXJpbWVudHMiOlt7Im5hbWUiOiJrcC1jbGllbnQtb25lLXB1cmNoYXNlLWZsb3ciLCJ2YXJpYXRlIjoidmFyaWF0ZS0xIn0seyJuYW1lIjoia3AtY2xpZW50LXV0b3BpYS1mbG93IiwidmFyaWF0ZSI6InZhcmlhdGUtMSJ9LHsibmFtZSI6ImtwYy0xay1zZXJ2aWNlIiwidmFyaWF0ZSI6InZhcmlhdGUtMSJ9LHsibmFtZSI6ImtwLWNsaWVudC11dG9waWEtc3RhdGljLXdpZGdldCIsInZhcmlhdGUiOiJpbmRleCIsInBhcmFtZXRlcnMiOnsiZHluYW1pYyI6InRydWUifX0seyJuYW1lIjoiaW4tYXBwLXNkay1uZXctaW50ZXJuYWwtYnJvd3NlciIsInBhcmFtZXRlcnMiOnsidmFyaWF0ZV9pZCI6Im5ldy1pbnRlcm5hbC1icm93c2VyLWVuYWJsZSJ9fSx7Im5hbWUiOiJrcC1jbGllbnQtdXRvcGlhLXNkay1mbG93IiwidmFyaWF0ZSI6InZhcmlhdGUtMSJ9LHsibmFtZSI6ImtwLWNsaWVudC11dG9waWEtd2Vidmlldy1mbG93IiwidmFyaWF0ZSI6InZhcmlhdGUtMSJ9LHsibmFtZSI6ImluLWFwcC1zZGstY2FyZC1zY2FubmluZyIsInBhcmFtZXRlcnMiOnsidmFyaWF0ZV9pZCI6ImNhcmQtc2Nhbm5pbmctZW5hYmxlIn19XSwicmVnaW9uIjoiZXUiLCJvcmRlcl9hbW91bnQiOjIwMDAsIm9mZmVyaW5nX29wdHMiOjAsIm9vIjoiY3ciLCJ2ZXJzaW9uIjoidjEuMTAuMC0xNTkwLWczZWJjMzkwNyJ9.ZxThQVo5e0Fck1vwOQ-WWAr7Zw-dsiEhjd3CW-E5p8atUhnBhrzIs6WCBeOOv3ci2VvpykVnDw2qycCTA-7TpTq1wn_kPxxixDQnYJYJzrZMoUhPLZo5pfy2a1S_t2owEQks0THRzu2wRlZwCN4ewDnVqsut60X4r3B92cJENIDtEC4Fs55CjFEmYUtsLXSspNLKvpZe2zg4O_M5yjH7XsBs5YJalZLexf4545G5vJrmVHgiA322mbgWC7BH0IU1A-ql5sFvs190_cjGaLsAvrkh9CVczUPy3X-jr3A5z1YRVfywPpvwKFWL8GZtgrdUZmgiU5_8ZZLkEPzrSucHrQ" + } } \ No newline at end of file diff --git a/src/test/resources/mocks/payments/response/get_payment_klarna_response.json b/src/test/resources/mocks/payments/response/get_payment_klarna_response.json new file mode 100644 index 00000000..38011e8c --- /dev/null +++ b/src/test/resources/mocks/payments/response/get_payment_klarna_response.json @@ -0,0 +1,92 @@ +{ + "id": "pay_mnnf6wnp7fdupa2jechtgg5cr4", + "requested_on": "2024-08-13T15:14:28.1308176Z", + "source": { + "type": "klarna", + "account_holder": { + "first_name": "Eve", + "last_name": "Test", + "billing_address": { + "address_line1": "Bodestr. 1-3", + "city": "Berlin", + "zip": "10178", + "country": "DE", + "state": "" + }, + "email": "generated_email_de+1698763875860@example.com", + "date_of_birth": "1992-01-01", + "phone": { + "number": "+4915257607960" + }, + "identification": {} + } + }, + "payment_type": "Installment", + "payment_plan": { + "financing": true + }, + "items": [ + { + "name": "OTR-AC Elite 90 Capsules", + "quantity": 1, + "unit_price": 4998, + "total_amount": 4998, + "tax_amount": 0, + "discount_amount": 0 + }, + { + "name": "Discount", + "quantity": 1, + "unit_price": 1000, + "total_amount": 1000, + "discount_amount": 0 + } + ], + "amount": 3998, + "currency": "EUR", + "status": "Captured", + "approved": true, + "balances": { + "total_authorized": 3998, + "total_voided": 0, + "available_to_void": 0, + "total_captured": 3998, + "available_to_capture": 0, + "total_refunded": 0, + "available_to_refund": 3998 + }, + "shipping": { + "first_name": "Samuel", + "last_name": "Rudd", + "email": "srudd@email.com", + "address": { + "address_line1": "Rotherstraße 19", + "city": "Berlin", + "state": "", + "zip": "10245", + "country": "DE" + }, + "phone": { + "number": "+4930774615846" + } + }, + "processing": { + "partner_session_id": "43c4421b-605a-47c2-88bb-d5dd9025222b", + "partner_order_id": "dc3b8712-123a-45ef-bc3d-b356a158b31b", + "fraud_status": "ACCEPTED", + "locale": "en-GB", + "tax_amount": 0, + "shipping_amount": 0 + }, + "_links": { + "self": { + "href": "https://api.sandbox.checkout.com/payments/pay_mnnf6wnp7fdupa2jechtgg5cr4" + }, + "actions": { + "href": "https://api.sandbox.checkout.com/payments/pay_mnnf6wnp7fdupa2jechtgg5cr4/actions" + }, + "refund": { + "href": "https://api.sandbox.checkout.com/payments/pay_mnnf6wnp7fdupa2jechtgg5cr4/refunds" + } + } +} \ No newline at end of file