@@ -42,6 +42,7 @@ pub async fn perform_authentication(
42
42
psd2_sca_exemption_type : Option < common_enums:: ScaExemptionType > ,
43
43
payment_id : common_utils:: id_type:: PaymentId ,
44
44
force_3ds_challenge : bool ,
45
+ merchant_key_store : & hyperswitch_domain_models:: merchant_key_store:: MerchantKeyStore ,
45
46
) -> CustomResult < api:: authentication:: AuthenticationResponse , ApiErrorResponse > {
46
47
let router_data = transformers:: construct_authentication_router_data (
47
48
state,
@@ -74,8 +75,14 @@ pub async fn perform_authentication(
74
75
router_data,
75
76
) )
76
77
. await ?;
77
- let authentication =
78
- utils:: update_trackers ( state, response. clone ( ) , authentication_data, None ) . await ?;
78
+ let authentication = utils:: update_trackers (
79
+ state,
80
+ response. clone ( ) ,
81
+ authentication_data,
82
+ None ,
83
+ merchant_key_store,
84
+ )
85
+ . await ?;
79
86
response
80
87
. response
81
88
. map_err ( |err| ApiErrorResponse :: ExternalConnectorError {
@@ -94,7 +101,10 @@ pub async fn perform_post_authentication(
94
101
business_profile : domain:: Profile ,
95
102
authentication_id : String ,
96
103
payment_id : & common_utils:: id_type:: PaymentId ,
97
- ) -> CustomResult < storage:: Authentication , ApiErrorResponse > {
104
+ ) -> CustomResult <
105
+ hyperswitch_domain_models:: router_request_types:: authentication:: AuthenticationStore ,
106
+ ApiErrorResponse ,
107
+ > {
98
108
let ( authentication_connector, three_ds_connector_account) =
99
109
utils:: get_authentication_connector_data ( state, key_store, & business_profile) . await ?;
100
110
let is_pull_mechanism_enabled =
@@ -112,7 +122,11 @@ pub async fn perform_post_authentication(
112
122
. await
113
123
. to_not_found_response ( ApiErrorResponse :: InternalServerError )
114
124
. attach_printable_lazy ( || format ! ( "Error while fetching authentication record with authentication_id {authentication_id}" ) ) ?;
115
- if !authentication. authentication_status . is_terminal_status ( ) && is_pull_mechanism_enabled {
125
+
126
+ let authentication_update = if !authentication. authentication_status . is_terminal_status ( )
127
+ && is_pull_mechanism_enabled
128
+ {
129
+ // trigger in case of authenticate flow
116
130
let router_data = transformers:: construct_post_authentication_router_data (
117
131
state,
118
132
authentication_connector. to_string ( ) ,
@@ -124,10 +138,28 @@ pub async fn perform_post_authentication(
124
138
let router_data =
125
139
utils:: do_auth_connector_call ( state, authentication_connector. to_string ( ) , router_data)
126
140
. await ?;
127
- utils:: update_trackers ( state, router_data, authentication, None ) . await
141
+ utils:: update_trackers ( state, router_data, authentication, None , key_store ) . await ?
128
142
} else {
129
- Ok ( authentication)
130
- }
143
+ // trigger in case of webhook flow
144
+ authentication
145
+ } ;
146
+
147
+ // getting authentication value from temp locker before moving ahead with authrisation
148
+ let tokenized_data = crate :: core:: payment_methods:: vault:: get_tokenized_data (
149
+ state,
150
+ & authentication_id,
151
+ false ,
152
+ key_store. key . get_inner ( ) ,
153
+ )
154
+ . await ?;
155
+
156
+ let authentication_store =
157
+ hyperswitch_domain_models:: router_request_types:: authentication:: AuthenticationStore {
158
+ cavv : Some ( tokenized_data. value1 ) ,
159
+ authentication : authentication_update,
160
+ } ;
161
+
162
+ Ok ( authentication_store)
131
163
}
132
164
133
165
#[ allow( clippy:: too_many_arguments) ]
@@ -140,7 +172,10 @@ pub async fn perform_pre_authentication(
140
172
acquirer_details : Option < types:: AcquirerDetails > ,
141
173
payment_id : common_utils:: id_type:: PaymentId ,
142
174
organization_id : common_utils:: id_type:: OrganizationId ,
143
- ) -> CustomResult < storage:: Authentication , ApiErrorResponse > {
175
+ ) -> CustomResult <
176
+ hyperswitch_domain_models:: router_request_types:: authentication:: AuthenticationStore ,
177
+ ApiErrorResponse ,
178
+ > {
144
179
let ( authentication_connector, three_ds_connector_account) =
145
180
utils:: get_authentication_connector_data ( state, key_store, business_profile) . await ?;
146
181
let authentication_connector_name = authentication_connector. to_string ( ) ;
@@ -176,13 +211,21 @@ pub async fn perform_pre_authentication(
176
211
)
177
212
. await ?;
178
213
179
- let updated_authentication =
180
- utils:: update_trackers ( state, router_data, authentication, acquirer_details. clone ( ) )
181
- . await ?;
214
+ let updated_authentication = utils:: update_trackers (
215
+ state,
216
+ router_data,
217
+ authentication,
218
+ acquirer_details. clone ( ) ,
219
+ key_store,
220
+ )
221
+ . await ?;
182
222
// from version call response, we will get to know the maximum supported 3ds version.
183
223
// If the version is not greater than or equal to 3DS 2.0, We should not do the successive pre authentication call.
184
224
if !updated_authentication. is_separate_authn_required ( ) {
185
- return Ok ( updated_authentication) ;
225
+ return Ok ( hyperswitch_domain_models:: router_request_types:: authentication:: AuthenticationStore {
226
+ authentication : updated_authentication,
227
+ cavv : None , // since cavv wont be present in pre_authentication step
228
+ } ) ;
186
229
}
187
230
updated_authentication
188
231
} else {
@@ -201,5 +244,19 @@ pub async fn perform_pre_authentication(
201
244
let router_data =
202
245
utils:: do_auth_connector_call ( state, authentication_connector_name, router_data) . await ?;
203
246
204
- utils:: update_trackers ( state, router_data, authentication, acquirer_details) . await
247
+ let authentication_update = utils:: update_trackers (
248
+ state,
249
+ router_data,
250
+ authentication,
251
+ acquirer_details,
252
+ key_store,
253
+ )
254
+ . await ?;
255
+
256
+ Ok (
257
+ hyperswitch_domain_models:: router_request_types:: authentication:: AuthenticationStore {
258
+ authentication : authentication_update,
259
+ cavv : None , // since cavv wont be present in pre_authentication step
260
+ } ,
261
+ )
205
262
}
0 commit comments