diff --git a/src/main/java/com/checkout/payments/request/PaymentRequest.java b/src/main/java/com/checkout/payments/request/PaymentRequest.java index bf760841..0a998d73 100644 --- a/src/main/java/com/checkout/payments/request/PaymentRequest.java +++ b/src/main/java/com/checkout/payments/request/PaymentRequest.java @@ -97,7 +97,11 @@ public final class PaymentRequest { private List items; + private PaymentRetryRequest retry; + @Builder.Default private Map metadata = new HashMap<>(); + private PaymentSegment segment; + } diff --git a/src/main/java/com/checkout/payments/request/PaymentRetryRequest.java b/src/main/java/com/checkout/payments/request/PaymentRetryRequest.java new file mode 100644 index 00000000..9b9a05ee --- /dev/null +++ b/src/main/java/com/checkout/payments/request/PaymentRetryRequest.java @@ -0,0 +1,23 @@ +package com.checkout.payments.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public final class PaymentRetryRequest { + + private Boolean enabled; + + @SerializedName("max_attempts") + private Integer maxAttempts; + + @SerializedName("end_after_days") + private Integer endAfterDays; + +} diff --git a/src/main/java/com/checkout/payments/request/PaymentSegment.java b/src/main/java/com/checkout/payments/request/PaymentSegment.java new file mode 100644 index 00000000..9c55024b --- /dev/null +++ b/src/main/java/com/checkout/payments/request/PaymentSegment.java @@ -0,0 +1,22 @@ +package com.checkout.payments.request; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public final class PaymentSegment { + + private String brand; + + @SerializedName("business_category") + private String businessCategory; + + private String market; + +} diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestGiropaySource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestGiropaySource.java index 2e379fce..3378d909 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestGiropaySource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestGiropaySource.java @@ -1,5 +1,6 @@ package com.checkout.payments.request.source.apm; +import com.checkout.common.AccountHolder; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; import com.google.gson.annotations.SerializedName; @@ -33,12 +34,17 @@ public final class RequestGiropaySource extends AbstractRequestSource { @SerializedName("info_fields") private List infoFields; + @SerializedName("account_holder") + private AccountHolder accountHolder; + @Builder private RequestGiropaySource(final String purpose, - final List infoFields) { + final List infoFields, + final AccountHolder accountHolder) { super(PaymentSourceType.GIROPAY); this.purpose = purpose; this.infoFields = infoFields; + this.accountHolder = accountHolder; } public RequestGiropaySource() { @@ -54,4 +60,4 @@ public static class InfoFields { private String text; } -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/response/PaymentResponse.java b/src/main/java/com/checkout/payments/response/PaymentResponse.java index d590ce80..a2d94f9c 100644 --- a/src/main/java/com/checkout/payments/response/PaymentResponse.java +++ b/src/main/java/com/checkout/payments/response/PaymentResponse.java @@ -73,6 +73,8 @@ public final class PaymentResponse extends Resource implements Serializable { @SerializedName("scheme_id") private String schemeId; + private PaymentRetryResponse retry; + @SerializedName("payment_ip") private String paymentIp; diff --git a/src/main/java/com/checkout/payments/response/PaymentRetryResponse.java b/src/main/java/com/checkout/payments/response/PaymentRetryResponse.java new file mode 100644 index 00000000..56216f8f --- /dev/null +++ b/src/main/java/com/checkout/payments/response/PaymentRetryResponse.java @@ -0,0 +1,22 @@ +package com.checkout.payments.response; + +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.Data; + +import java.time.Instant; + +@Data +@Builder +public final class PaymentRetryResponse { + + @SerializedName("max_attempts") + private Integer maxAttempts; + + @SerializedName("ends_on") + private Instant endsOn; + + @SerializedName("next_attempt_on") + private Instant nextAttemptOn; + +} diff --git a/src/main/java/com/checkout/payments/response/source/CardResponseSource.java b/src/main/java/com/checkout/payments/response/source/CardResponseSource.java index a6eefb78..0472d170 100644 --- a/src/main/java/com/checkout/payments/response/source/CardResponseSource.java +++ b/src/main/java/com/checkout/payments/response/source/CardResponseSource.java @@ -75,4 +75,7 @@ public final class CardResponseSource extends AbstractResponseSource implements @SerializedName("payment_account_reference") private String paymentAccountReference; + @SerializedName("encrypted_card_number") + private String encryptedCardNumber; + } diff --git a/src/test/java/com/checkout/payments/RequestApmPaymentsIT.java b/src/test/java/com/checkout/payments/RequestApmPaymentsIT.java index 17788ad3..e8298364 100644 --- a/src/test/java/com/checkout/payments/RequestApmPaymentsIT.java +++ b/src/test/java/com/checkout/payments/RequestApmPaymentsIT.java @@ -311,11 +311,19 @@ void shouldMakeIllicadoPayment() { checkErrorItem(() -> paymentsClient.requestPayment(paymentRequest), PAYEE_NOT_ONBOARDED); } - @Disabled("unstable") @Test void shouldMakeGiropayPayment() { + final AccountHolder accountHolder = AccountHolder.builder() + .firstName("Firstname") + .lastName("Lastname") + .build(); + + final RequestGiropaySource giropay = RequestGiropaySource.builder() + .accountHolder(accountHolder) + .build(); + final PaymentRequest paymentRequest = PaymentRequest.builder() - .source(new RequestGiropaySource()) + .source(giropay) .currency(Currency.EUR) .amount(100L) .capture(true) @@ -327,11 +335,7 @@ void shouldMakeGiropayPayment() { .build()) .build(); - final PaymentResponse response = blocking(() -> checkoutApi.paymentsClient().requestPayment(paymentRequest)); - - assertNotNull(response); - assertNotNull(response.getId()); - assertEquals(PaymentStatus.PENDING, response.getStatus()); + checkErrorItem(() -> paymentsClient.requestPayment(paymentRequest), PAYEE_NOT_ONBOARDED); } @Test