@@ -2,9 +2,11 @@ mod transformers;
2
2
3
3
use std:: fmt:: Debug ;
4
4
5
+ use api_models:: payments:: PaymentMethodData ;
5
6
use error_stack:: { IntoReport , ResultExt } ;
6
7
use transformers as dummyconnector;
7
8
9
+ use super :: utils:: { PaymentsAuthorizeRequestData , RefundsRequestData } ;
8
10
use crate :: {
9
11
configs:: settings,
10
12
core:: errors:: { self , CustomResult } ,
@@ -96,9 +98,9 @@ impl ConnectorCommon for DummyConnector {
96
98
97
99
Ok ( ErrorResponse {
98
100
status_code : res. status_code ,
99
- code : response. code ,
100
- message : response. message ,
101
- reason : response. reason ,
101
+ code : response. error . code ,
102
+ message : response. error . message ,
103
+ reason : response. error . reason ,
102
104
} )
103
105
}
104
106
}
@@ -136,10 +138,22 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
136
138
137
139
fn get_url (
138
140
& self ,
139
- _req : & types:: PaymentsAuthorizeRouterData ,
140
- _connectors : & settings:: Connectors ,
141
+ req : & types:: PaymentsAuthorizeRouterData ,
142
+ connectors : & settings:: Connectors ,
141
143
) -> CustomResult < String , errors:: ConnectorError > {
142
- Err ( errors:: ConnectorError :: NotImplemented ( "get_url method" . to_string ( ) ) . into ( ) )
144
+ let payment_method_data = req. request . payment_method_data . to_owned ( ) ;
145
+ let payment_method_type = req. request . get_payment_method_type ( ) ?;
146
+ match payment_method_data {
147
+ PaymentMethodData :: Card ( _) => Ok ( format ! ( "{}/payment" , self . base_url( connectors) ) ) ,
148
+ _ => Err ( error_stack:: report!( errors:: ConnectorError :: NotSupported {
149
+ message: format!(
150
+ "The payment method {} is not supported" ,
151
+ payment_method_type
152
+ ) ,
153
+ connector: "dummyconnector" ,
154
+ payment_experience: api:: enums:: PaymentExperience :: RedirectToUrl . to_string( ) ,
155
+ } ) ) ,
156
+ }
143
157
}
144
158
145
159
fn get_request_body (
@@ -180,7 +194,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
180
194
data : & types:: PaymentsAuthorizeRouterData ,
181
195
res : Response ,
182
196
) -> CustomResult < types:: PaymentsAuthorizeRouterData , errors:: ConnectorError > {
183
- let response: dummyconnector:: DummyConnectorPaymentsResponse = res
197
+ let response: dummyconnector:: PaymentsResponse = res
184
198
. response
185
199
. parse_struct ( "DummyConnector PaymentsAuthorizeResponse" )
186
200
. change_context ( errors:: ConnectorError :: ResponseDeserializationFailed ) ?;
@@ -217,10 +231,23 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
217
231
218
232
fn get_url (
219
233
& self ,
220
- _req : & types:: PaymentsSyncRouterData ,
221
- _connectors : & settings:: Connectors ,
234
+ req : & types:: PaymentsSyncRouterData ,
235
+ connectors : & settings:: Connectors ,
222
236
) -> CustomResult < String , errors:: ConnectorError > {
223
- Err ( errors:: ConnectorError :: NotImplemented ( "get_url method" . to_string ( ) ) . into ( ) )
237
+ match req
238
+ . request
239
+ . connector_transaction_id
240
+ . get_connector_transaction_id ( )
241
+ {
242
+ Ok ( transaction_id) => Ok ( format ! (
243
+ "{}/payments/{}" ,
244
+ self . base_url( connectors) ,
245
+ transaction_id
246
+ ) ) ,
247
+ Err ( _) => Err ( error_stack:: report!(
248
+ errors:: ConnectorError :: MissingConnectorTransactionID
249
+ ) ) ,
250
+ }
224
251
}
225
252
226
253
fn build_request (
@@ -243,7 +270,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
243
270
data : & types:: PaymentsSyncRouterData ,
244
271
res : Response ,
245
272
) -> CustomResult < types:: PaymentsSyncRouterData , errors:: ConnectorError > {
246
- let response: dummyconnector:: DummyConnectorPaymentsResponse = res
273
+ let response: dummyconnector:: PaymentsResponse = res
247
274
. response
248
275
. parse_struct ( "dummyconnector PaymentsSyncResponse" )
249
276
. change_context ( errors:: ConnectorError :: ResponseDeserializationFailed ) ?;
@@ -315,7 +342,7 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
315
342
data : & types:: PaymentsCaptureRouterData ,
316
343
res : Response ,
317
344
) -> CustomResult < types:: PaymentsCaptureRouterData , errors:: ConnectorError > {
318
- let response: dummyconnector:: DummyConnectorPaymentsResponse = res
345
+ let response: dummyconnector:: PaymentsResponse = res
319
346
. response
320
347
. parse_struct ( "DummyConnector PaymentsCaptureResponse" )
321
348
. change_context ( errors:: ConnectorError :: ResponseDeserializationFailed ) ?;
@@ -357,10 +384,14 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
357
384
358
385
fn get_url (
359
386
& self ,
360
- _req : & types:: RefundsRouterData < api:: Execute > ,
361
- _connectors : & settings:: Connectors ,
387
+ req : & types:: RefundsRouterData < api:: Execute > ,
388
+ connectors : & settings:: Connectors ,
362
389
) -> CustomResult < String , errors:: ConnectorError > {
363
- Err ( errors:: ConnectorError :: NotImplemented ( "get_url method" . to_string ( ) ) . into ( ) )
390
+ Ok ( format ! (
391
+ "{}/{}/refund" ,
392
+ self . base_url( connectors) ,
393
+ req. request. connector_transaction_id
394
+ ) )
364
395
}
365
396
366
397
fn get_request_body (
@@ -435,10 +466,15 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
435
466
436
467
fn get_url (
437
468
& self ,
438
- _req : & types:: RefundSyncRouterData ,
439
- _connectors : & settings:: Connectors ,
469
+ req : & types:: RefundSyncRouterData ,
470
+ connectors : & settings:: Connectors ,
440
471
) -> CustomResult < String , errors:: ConnectorError > {
441
- Err ( errors:: ConnectorError :: NotImplemented ( "get_url method" . to_string ( ) ) . into ( ) )
472
+ let refund_id = req. request . get_connector_refund_id ( ) ?;
473
+ Ok ( format ! (
474
+ "{}/refunds/{}" ,
475
+ self . base_url( connectors) ,
476
+ refund_id
477
+ ) )
442
478
}
443
479
444
480
fn build_request (
0 commit comments