Skip to content

Commit

Permalink
Updated giropay api (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Jan 31, 2024
1 parent 19dbcaf commit d643d98
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public final class PaymentRequest {

private List<Product> items;

private PaymentRetryRequest retry;

@Builder.Default
private Map<String, Object> metadata = new HashMap<>();

private PaymentSegment segment;

}
Original file line number Diff line number Diff line change
@@ -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;

}
22 changes: 22 additions & 0 deletions src/main/java/com/checkout/payments/request/PaymentSegment.java
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -33,12 +34,17 @@ public final class RequestGiropaySource extends AbstractRequestSource {
@SerializedName("info_fields")
private List<InfoFields> infoFields;

@SerializedName("account_holder")
private AccountHolder accountHolder;

@Builder
private RequestGiropaySource(final String purpose,
final List<InfoFields> infoFields) {
final List<InfoFields> infoFields,
final AccountHolder accountHolder) {
super(PaymentSourceType.GIROPAY);
this.purpose = purpose;
this.infoFields = infoFields;
this.accountHolder = accountHolder;
}

public RequestGiropaySource() {
Expand All @@ -54,4 +60,4 @@ public static class InfoFields {
private String text;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
18 changes: 11 additions & 7 deletions src/test/java/com/checkout/payments/RequestApmPaymentsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit d643d98

Please sign in to comment.