1
1
pub mod transformers;
2
2
3
- use std:: collections:: HashMap ;
3
+ use std:: collections:: { HashMap , HashSet } ;
4
4
5
5
use common_enums:: { CaptureMethod , PaymentMethodType } ;
6
6
use common_utils:: {
@@ -12,6 +12,7 @@ use common_utils::{
12
12
} ;
13
13
use error_stack:: ResultExt ;
14
14
use hyperswitch_domain_models:: {
15
+ payment_method_data:: PaymentMethodData ,
15
16
router_data:: { AccessToken , ErrorResponse , RouterData } ,
16
17
router_flow_types:: {
17
18
access_token_auth:: AccessTokenAuth ,
@@ -43,7 +44,11 @@ use serde::{Deserialize, Serialize};
43
44
use serde_json:: Value ;
44
45
use transformers:: { self as fiuu, FiuuWebhooksResponse } ;
45
46
46
- use crate :: { constants:: headers, types:: ResponseRouterData , utils} ;
47
+ use crate :: {
48
+ constants:: headers,
49
+ types:: ResponseRouterData ,
50
+ utils:: { self , PaymentMethodDataType } ,
51
+ } ;
47
52
48
53
fn parse_response < T > ( data : & [ u8 ] ) -> Result < T , errors:: ConnectorError >
49
54
where
@@ -210,6 +215,15 @@ impl ConnectorValidation for Fiuu {
210
215
) ,
211
216
}
212
217
}
218
+ fn validate_mandate_payment (
219
+ & self ,
220
+ pm_type : Option < PaymentMethodType > ,
221
+ pm_data : PaymentMethodData ,
222
+ ) -> CustomResult < ( ) , errors:: ConnectorError > {
223
+ let mandate_supported_pmd: HashSet < PaymentMethodDataType > =
224
+ HashSet :: from ( [ PaymentMethodDataType :: Card ] ) ;
225
+ utils:: is_mandate_supported ( pm_data, pm_type, mandate_supported_pmd, self . id ( ) )
226
+ }
213
227
}
214
228
215
229
impl ConnectorIntegration < Session , PaymentsSessionData , PaymentsResponseData > for Fiuu {
@@ -231,13 +245,21 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
231
245
232
246
fn get_url (
233
247
& self ,
234
- _req : & PaymentsAuthorizeRouterData ,
248
+ req : & PaymentsAuthorizeRouterData ,
235
249
connectors : & Connectors ,
236
250
) -> CustomResult < String , errors:: ConnectorError > {
237
- Ok ( format ! (
238
- "{}RMS/API/Direct/1.4.0/index.php" ,
239
- self . base_url( connectors)
240
- ) )
251
+ let url = if req. request . off_session == Some ( true ) {
252
+ format ! (
253
+ "{}/RMS/API/Recurring/input_v7.php" ,
254
+ self . base_url( connectors)
255
+ )
256
+ } else {
257
+ format ! (
258
+ "{}RMS/API/Direct/1.4.0/index.php" ,
259
+ self . base_url( connectors)
260
+ )
261
+ } ;
262
+ Ok ( url)
241
263
}
242
264
243
265
fn get_request_body (
@@ -252,9 +274,15 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
252
274
) ?;
253
275
254
276
let connector_router_data = fiuu:: FiuuRouterData :: from ( ( amount, req) ) ;
255
- let payment_request = fiuu:: FiuuPaymentRequest :: try_from ( & connector_router_data) ?;
256
- let connector_req = build_form_from_struct ( payment_request)
257
- . change_context ( errors:: ConnectorError :: ParsingFailed ) ?;
277
+ let connector_req = if req. request . off_session == Some ( true ) {
278
+ let recurring_request = fiuu:: FiuuMandateRequest :: try_from ( & connector_router_data) ?;
279
+ build_form_from_struct ( recurring_request)
280
+ . change_context ( errors:: ConnectorError :: ParsingFailed ) ?
281
+ } else {
282
+ let payment_request = fiuu:: FiuuPaymentRequest :: try_from ( & connector_router_data) ?;
283
+ build_form_from_struct ( payment_request)
284
+ . change_context ( errors:: ConnectorError :: ParsingFailed ) ?
285
+ } ;
258
286
Ok ( RequestContent :: FormData ( connector_req) )
259
287
}
260
288
0 commit comments