Skip to content

Commit

Permalink
Update Payment Components
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko committed Apr 17, 2024
1 parent 3cb3417 commit 27db809
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 5 deletions.
18 changes: 18 additions & 0 deletions src/main/java/com/checkout/payments/sessions/Card.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.checkout.payments.sessions;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public final class Card {

@SerializedName("store_payment_details")
private StorePaymentDetailsType storePaymentDetails;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.checkout.payments.sessions;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public final class PaymentMethodConfiguration {

private Card card;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.checkout.payments.sessions;

import com.google.gson.annotations.SerializedName;

public enum PaymentMethodsType {

@SerializedName("applepay")
APPLEPAY,

@SerializedName("bancontact")
BANCONTACT,

@SerializedName("card")
CARD,

@SerializedName("eps")
EPS,

@SerializedName("giropay")
GIROPAY,

@SerializedName("googlepay")
GOOGLEPAY,

@SerializedName("ideal")
IDEAL,

@SerializedName("knet")
KNET,

@SerializedName("multibanco")
MULTIBANCO,

@SerializedName("p24")
P24,

@SerializedName("paypal")
PAYPAL,

@SerializedName("sofort")
SOFORT,

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
package com.checkout.payments.sessions;

import com.checkout.common.AmountAllocations;
import com.checkout.common.Currency;
import com.checkout.common.CustomerRequest;
import com.checkout.payments.BillingDescriptor;
import com.checkout.payments.BillingInformation;
import com.checkout.payments.PaymentRecipient;
import com.checkout.payments.PaymentType;
import com.checkout.payments.ProcessingSettings;
import com.checkout.payments.Product;
import com.checkout.payments.RiskRequest;
import com.checkout.payments.ShippingDetails;
import com.checkout.payments.ThreeDSRequest;
import com.checkout.payments.request.PaymentCustomerRequest;
import com.checkout.payments.request.PaymentRetryRequest;
import com.checkout.payments.sender.PaymentSender;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.Instant;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
@Builder
Expand All @@ -18,16 +34,76 @@ public final class PaymentSessionsRequest {

private Currency currency;

@SerializedName("payment_type")
private PaymentType paymentType;

private BillingInformation billing;

@SerializedName("billing_descriptor")
private BillingDescriptor billingDescriptor;

private String reference;

private Billing billing;
private String description;

private PaymentCustomerRequest customer;

private ShippingDetails shipping;

private PaymentRecipient recipient;

private ProcessingSettings processing;

@SerializedName("processing_channel_id")
private String processingChannelId;

@SerializedName("expires_on")
private Instant expiresOn;

@SerializedName("payment_method_configuration")
private PaymentMethodConfiguration paymentMethodConfiguration;

@SerializedName("enabled_payment_methods")
private List<PaymentMethodsType> enabledPaymentMethods;

@SerializedName("disabled_payment_methods")
private List<PaymentMethodsType> disabledPaymentMethods;

private CustomerRequest customer;
private List<Product> items;

@SerializedName("amount_allocations")
private List<AmountAllocations> amountAllocations;

private RiskRequest risk;

@SerializedName("customer_retry")
private PaymentRetryRequest customerRetry;

@SerializedName("display_name")
private String displayName;

@SerializedName("success_url")
private String successUrl;

@SerializedName("failure_url")
private String failureUrl;

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

private String locale;

@SerializedName("3ds")
private ThreeDSRequest threeDS;

private PaymentSender sender;

private Boolean capture;

@SerializedName("ip_address")
private String ipAddress;

@SerializedName("tax_amount")
private Integer taxAmount;

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public final class PaymentSessionsResponse extends Resource {

private String id;

private String paymentSessionToken;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.checkout.payments.sessions;

import com.google.gson.annotations.SerializedName;

public enum StorePaymentDetailsType {

@SerializedName("disabled")
DISABLED,

@SerializedName("enabled")
ENABLED,

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.checkout.PlatformType;
import com.checkout.SandboxTestFixture;
import com.checkout.common.Currency;
import com.checkout.payments.BillingInformation;
import org.junit.jupiter.api.Test;

import static com.checkout.TestHelper.createAddress;
Expand All @@ -19,7 +20,7 @@ class PaymentSessionsTestIT extends SandboxTestFixture {
@Test
void shouldMakeAPaymentSessionsRequest() {

final Billing billing = Billing.builder()
final BillingInformation billing = BillingInformation.builder()
.address(createAddress())
.build();

Expand All @@ -28,7 +29,6 @@ void shouldMakeAPaymentSessionsRequest() {
.currency(Currency.GBP)
.reference("ORD-123A")
.billing(billing)
.customer(createCustomer())
.successUrl("https://example.com/payments/success")
.failureUrl("https://example.com/payments/failure")
.build();
Expand All @@ -37,6 +37,7 @@ void shouldMakeAPaymentSessionsRequest() {

assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getPaymentSessionToken());
assertNotNull(response.getLinks());

}
Expand Down

0 comments on commit 27db809

Please sign in to comment.