@@ -28,7 +28,7 @@ use hyperswitch_domain_models::{
28
28
router_response_types:: { PaymentsResponseData , RefundsResponseData } ,
29
29
types:: {
30
30
PaymentsAuthorizeRouterData , PaymentsCancelRouterData , PaymentsCaptureRouterData ,
31
- PaymentsSyncRouterData , RefundSyncRouterData , RefundsRouterData ,
31
+ PaymentsSyncRouterData , RefundSyncRouterData , RefundsRouterData , SetupMandateRouterData ,
32
32
} ,
33
33
} ;
34
34
use hyperswitch_interfaces:: {
@@ -231,6 +231,79 @@ impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken>
231
231
impl ConnectorIntegration < SetupMandate , SetupMandateRequestData , PaymentsResponseData >
232
232
for Novalnet
233
233
{
234
+ fn get_headers (
235
+ & self ,
236
+ req : & SetupMandateRouterData ,
237
+ connectors : & Connectors ,
238
+ ) -> CustomResult < Vec < ( String , masking:: Maskable < String > ) > , errors:: ConnectorError > {
239
+ self . build_headers ( req, connectors)
240
+ }
241
+
242
+ fn get_content_type ( & self ) -> & ' static str {
243
+ self . common_get_content_type ( )
244
+ }
245
+
246
+ fn get_url (
247
+ & self ,
248
+ _req : & SetupMandateRouterData ,
249
+ connectors : & Connectors ,
250
+ ) -> CustomResult < String , errors:: ConnectorError > {
251
+ let endpoint = self . base_url ( connectors) ;
252
+ Ok ( format ! ( "{}/payment" , endpoint) )
253
+ }
254
+
255
+ fn get_request_body (
256
+ & self ,
257
+ req : & SetupMandateRouterData ,
258
+ _connectors : & Connectors ,
259
+ ) -> CustomResult < RequestContent , errors:: ConnectorError > {
260
+ let connector_req = novalnet:: NovalnetPaymentsRequest :: try_from ( req) ?;
261
+ Ok ( RequestContent :: Json ( Box :: new ( connector_req) ) )
262
+ }
263
+
264
+ fn build_request (
265
+ & self ,
266
+ req : & SetupMandateRouterData ,
267
+ connectors : & Connectors ,
268
+ ) -> CustomResult < Option < Request > , errors:: ConnectorError > {
269
+ Ok ( Some (
270
+ RequestBuilder :: new ( )
271
+ . method ( Method :: Post )
272
+ . url ( & types:: SetupMandateType :: get_url ( self , req, connectors) ?)
273
+ . attach_default_headers ( )
274
+ . headers ( types:: SetupMandateType :: get_headers ( self , req, connectors) ?)
275
+ . set_body ( types:: SetupMandateType :: get_request_body (
276
+ self , req, connectors,
277
+ ) ?)
278
+ . build ( ) ,
279
+ ) )
280
+ }
281
+
282
+ fn handle_response (
283
+ & self ,
284
+ data : & SetupMandateRouterData ,
285
+ event_builder : Option < & mut ConnectorEvent > ,
286
+ res : Response ,
287
+ ) -> CustomResult < SetupMandateRouterData , errors:: ConnectorError > {
288
+ let response: novalnet:: NovalnetPaymentsResponse = res
289
+ . response
290
+ . parse_struct ( "Novalnet PaymentsAuthorizeResponse" )
291
+ . change_context ( errors:: ConnectorError :: ResponseDeserializationFailed ) ?;
292
+ event_builder. map ( |i| i. set_response_body ( & response) ) ;
293
+ router_env:: logger:: info!( connector_response=?response) ;
294
+ RouterData :: try_from ( ResponseRouterData {
295
+ response,
296
+ data : data. clone ( ) ,
297
+ http_code : res. status_code ,
298
+ } )
299
+ }
300
+ fn get_error_response (
301
+ & self ,
302
+ res : Response ,
303
+ event_builder : Option < & mut ConnectorEvent > ,
304
+ ) -> CustomResult < ErrorResponse , errors:: ConnectorError > {
305
+ self . build_error_response ( res, event_builder)
306
+ }
234
307
}
235
308
236
309
impl ConnectorIntegration < Authorize , PaymentsAuthorizeData , PaymentsResponseData > for Novalnet {
0 commit comments