-
Notifications
You must be signed in to change notification settings - Fork 29
/
AdyenCheckoutFacade.java
221 lines (183 loc) · 7.55 KB
/
AdyenCheckoutFacade.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Hybris Extension
*
* Copyright (c) 2017 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
package com.adyen.v6.facades;
import com.adyen.model.checkout.CheckoutPaymentMethod;
import com.adyen.model.checkout.PaymentCompletionDetails;
import com.adyen.model.checkout.PaymentDetailsRequest;
import com.adyen.model.checkout.PaymentDetailsResponse;
import com.adyen.model.checkout.PaymentRequest;
import com.adyen.model.checkout.PaymentResponse;
import com.adyen.service.exception.ApiException;
import com.adyen.v6.controllers.dtos.PaymentResultDTO;
import com.adyen.v6.dto.CheckoutConfigDTO;
import com.adyen.v6.forms.AdyenPaymentForm;
import de.hybris.platform.commercefacades.order.data.CartData;
import de.hybris.platform.commercefacades.order.data.OrderData;
import de.hybris.platform.commercefacades.product.data.ProductData;
import de.hybris.platform.commercefacades.user.data.AddressData;
import de.hybris.platform.commercewebservicescommons.dto.order.PaymentDetailsWsDTO;
import de.hybris.platform.core.model.order.CartModel;
import de.hybris.platform.core.model.order.payment.PaymentInfoModel;
import de.hybris.platform.order.InvalidCartException;
import de.hybris.platform.order.exceptions.CalculationException;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Errors;
import javax.servlet.http.HttpServletRequest;
import java.util.Set;
/**
* Adyen Checkout Facade for initiating payments using CC or APM
*/
public interface AdyenCheckoutFacade {
String getShopperLocale();
/**
* Retrieve the host of Secured Fields
*/
String getCheckoutShopperHost();
/**
* Retrieve the environment is running in test mode or live mode
*/
String getEnvironmentMode();
/**
* Removes cart from the session so that users can't update it while being in a payment page
*/
void lockSessionCart();
/**
* Restores the sessionCart that has been previously locked
*
* @return session cart
* @throws InvalidCartException if cart cannot be retrieved
*/
CartModel restoreSessionCart() throws InvalidCartException;
Set<String> getStoredCards();
boolean getHolderNameRequired();
/**
* Handles Adyen Redirect Response
* In case of authorized, it places an order from cart
*
* @param details consisting of parameters present in response query string
* @return PaymentsResponse
*/
PaymentDetailsResponse handleRedirectPayload(PaymentCompletionDetails details) throws Exception;
/**
* Authorizes a payment using Adyen API
* In case of authorized, it places an order from cart
*
* @param request HTTP Request info
* @param cartData cartData object
* @return OrderData
* @throws Exception In case order failed to be created
*/
OrderData authorisePayment(HttpServletRequest request, CartData cartData) throws Exception;
OrderData handleResultcomponentPayment(PaymentResultDTO paymentResultDTO) throws Exception;
/**
* Creates a payment coming from an Adyen Checkout Component
* No session handling
*
* @param request HTTP Request info
* @param cartData cartData object
* @return PaymentsResponse
* @throws Exception In case payment failed
*/
PaymentResponse componentPayment(HttpServletRequest request, CartData cartData, PaymentRequest paymentRequest) throws Exception;
/**
* Submit details from a payment made on an Adyen Checkout Component
* No session handling
*
* @param request HTTP Request info
* @param details details
* @param paymentData paymentData
* @return PaymentsResponse
* @throws Exception In case request failed
*/
PaymentDetailsResponse componentDetails(PaymentDetailsRequest detailsRequest) throws Exception;
/**
* Add payment details to cart
*/
PaymentDetailsWsDTO addPaymentDetails(PaymentDetailsWsDTO paymentDetails);
/**
* Handles an 3D response
* In case of authorized, it places an order from cart
*
* @param details HTTP Request object
* @return OrderData
* @throws Exception In case order failed to be created
*/
OrderData handle3DSResponse(PaymentDetailsRequest paymentDetailsRequest) throws Exception;
/**
* Retrieve available payment methods
*/
void initializeCheckoutData(Model model) throws ApiException;
void initializeSummaryData(Model model) throws ApiException;
void initializeApplePayExpressCartPageData(Model model) throws ApiException;
void initializeApplePayExpressPDPData(Model model, ProductData productData) throws ApiException;
/**
* Returns whether Boleto should be shown as an available payment method on the checkout page
* Relevant for Brasil
*/
boolean showBoleto();
boolean showComboCard();
/**
* Returns whether POS should be shown as an available payment method on the checkout page
*/
boolean showPos();
/**
* Returns whether CC can be stored depending on the recurring contract settings
*/
boolean showRememberDetails();
/**
* Returns whether Social Security Number should be shown on the checkout page
* Relevant for openinvoice methods
*/
boolean showSocialSecurityNumber();
/**
* Creates PaymentInfoModel based on cart and form data
*/
PaymentInfoModel createPaymentInfo(CartModel cartModel, AdyenPaymentForm adyenPaymentForm);
/**
* Handles payment form submission
* Validates the form and updates the cart based on form data
* Updates BindingResult
*/
void handlePaymentForm(AdyenPaymentForm adyenPaymentForm, Errors errors);
/**
* Initiate POS Payment using Adyen Terminal API
*/
OrderData initiatePosPayment(HttpServletRequest request, CartData cartData) throws Exception;
/**
* Check POS Payment status using Adyen Terminal API
*/
OrderData checkPosPaymentStatus(HttpServletRequest request, CartData cartData) throws Exception;
/**
* Returns whether payments have Immediate Capture or not
*/
boolean isImmediateCapture();
/**
* Handles payment result from component
* Validates the result and updates the cart based on it
*/
OrderData handleComponentResult(String resultCode, String merchantReference) throws Exception;
void restoreCartFromOrderCodeInSession() throws InvalidCartException, CalculationException;
void restoreCartFromOrderOCC(String orderCode) throws CalculationException, InvalidCartException;
String getClientKey();
CheckoutConfigDTO getCheckoutConfig() throws ApiException;
CheckoutConfigDTO getReactCheckoutConfig() throws ApiException;
}