Skip to content

Commit 22072fd

Browse files
authored
feat(connector): [Deutschebank] Add Access Token Error struct (#7127)
1 parent 7ea630d commit 22072fd

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

config/config.example.toml

+3
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@ paypal = { country = "AD,AE,AL,AM,AR,AT,AU,AZ,BA,BB,BD,BE,BG,BH,BI,BM,BN,BO,BR,B
585585
[pm_filters.mifinity]
586586
mifinity = { country = "BR,CN,SG,MY,DE,CH,DK,GB,ES,AD,GI,FI,FR,GR,HR,IT,JP,MX,AR,CO,CL,PE,VE,UY,PY,BO,EC,GT,HN,SV,NI,CR,PA,DO,CU,PR,NL,NO,PL,PT,SE,RU,TR,TW,HK,MO,AX,AL,DZ,AS,AO,AI,AG,AM,AW,AU,AT,AZ,BS,BH,BD,BB,BE,BZ,BJ,BM,BT,BQ,BA,BW,IO,BN,BG,BF,BI,KH,CM,CA,CV,KY,CF,TD,CX,CC,KM,CG,CK,CI,CW,CY,CZ,DJ,DM,EG,GQ,ER,EE,ET,FK,FO,FJ,GF,PF,TF,GA,GM,GE,GH,GL,GD,GP,GU,GG,GN,GW,GY,HT,HM,VA,IS,IN,ID,IE,IM,IL,JE,JO,KZ,KE,KI,KW,KG,LA,LV,LB,LS,LI,LT,LU,MK,MG,MW,MV,ML,MT,MH,MQ,MR,MU,YT,FM,MD,MC,MN,ME,MS,MA,MZ,NA,NR,NP,NC,NZ,NE,NG,NU,NF,MP,OM,PK,PW,PS,PG,PH,PN,QA,RE,RO,RW,BL,SH,KN,LC,MF,PM,VC,WS,SM,ST,SA,SN,RS,SC,SL,SX,SK,SI,SB,SO,ZA,GS,KR,LK,SR,SJ,SZ,TH,TL,TG,TK,TO,TT,TN,TM,TC,TV,UG,UA,AE,UZ,VU,VN,VG,VI,WF,EH,ZM", currency = "AUD,CAD,CHF,CNY,CZK,DKK,EUR,GBP,INR,JPY,NOK,NZD,PLN,RUB,SEK,ZAR,USD,EGP,UYU,UZS" }
587587

588+
[pm_filters.fiuu]
589+
duit_now = { country = "MY", currency = "MYR" }
590+
588591
[connector_customer]
589592
connector_list = "gocardless,stax,stripe"
590593
payout_connector_list = "stripe,wise"

config/docker_compose.toml

+3
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ credit = { country = "AF,DZ,AW,AU,AZ,BS,BH,BD,BB,BZ,BM,BT,BO,BA,BW,BR,BN,BG,BI,K
508508
google_pay = { country = "AL,DZ,AS,AO,AG,AR,AU,AT,AZ,BH,BY,BE,BR,BG,CA,CL,CO,HR,CZ,DK,DO,EG,EE,FI,FR,DE,GR,HK,HU,IN,ID,IE,IL,IT,JP,JO,KZ,KE,KW,LV,LB,LT,LU,MY,MX,NL,NZ,NO,OM,PK,PA,PE,PH,PL,PT,QA,RO,RU,SA,SG,SK,ZA,ES,LK,SE,CH,TW,TH,TR,UA,AE,GB,US,UY,VN" }
509509
apple_pay = { country = "AU,CN,HK,JP,MO,MY,NZ,SG,TW,AM,AT,AZ,BY,BE,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GR,GL,GG,HU,IS,IE,IM,IT,KZ,JE,LV,LI,LT,LU,MT,MD,MC,ME,NL,NO,PL,PT,RO,SM,RS,SK,SI,ES,SE,CH,UA,GB,AR,CO,CR,BR,MX,PE,BH,IL,JO,KW,PS,QA,SA,AE,CA,UM,US" }
510510

511+
[pm_filters.fiuu]
512+
duit_now = { country = "MY", currency = "MYR" }
513+
511514
[bank_config.online_banking_fpx]
512515
adyen.banks = "affin_bank,agro_bank,alliance_bank,am_bank,bank_islam,bank_muamalat,bank_rakyat,bank_simpanan_nasional,cimb_bank,hong_leong_bank,hsbc_bank,kuwait_finance_house,maybank,ocbc_bank,public_bank,rhb_bank,standard_chartered_bank,uob_bank"
513516
fiuu.banks = "affin_bank,agro_bank,alliance_bank,am_bank,bank_of_china,bank_islam,bank_muamalat,bank_rakyat,bank_simpanan_nasional,cimb_bank,hong_leong_bank,hsbc_bank,kuwait_finance_house,maybank,ocbc_bank,public_bank,rhb_bank,standard_chartered_bank,uob_bank"

crates/hyperswitch_connectors/src/connectors/deutschebank.rs

+29-6
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ impl ConnectorCommon for Deutschebank {
159159
res: Response,
160160
event_builder: Option<&mut ConnectorEvent>,
161161
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
162-
let response: deutschebank::DeutschebankErrorResponse = res
162+
let response: deutschebank::PaymentsErrorResponse = res
163163
.response
164-
.parse_struct("DeutschebankErrorResponse")
164+
.parse_struct("PaymentsErrorResponse")
165165
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
166166

167167
event_builder.map(|i| i.set_response_body(&response));
@@ -289,7 +289,33 @@ impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken>
289289
res: Response,
290290
event_builder: Option<&mut ConnectorEvent>,
291291
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
292-
self.build_error_response(res, event_builder)
292+
let response: deutschebank::DeutschebankError = res
293+
.response
294+
.parse_struct("DeutschebankError")
295+
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
296+
297+
event_builder.map(|i| i.set_response_body(&response));
298+
router_env::logger::info!(connector_response=?response);
299+
match response {
300+
deutschebank::DeutschebankError::PaymentsErrorResponse(response) => Ok(ErrorResponse {
301+
status_code: res.status_code,
302+
code: response.rc,
303+
message: response.message.clone(),
304+
reason: Some(response.message),
305+
attempt_status: None,
306+
connector_transaction_id: None,
307+
}),
308+
deutschebank::DeutschebankError::AccessTokenErrorResponse(response) => {
309+
Ok(ErrorResponse {
310+
status_code: res.status_code,
311+
code: response.cause.clone(),
312+
message: response.cause.clone(),
313+
reason: Some(response.description),
314+
attempt_status: None,
315+
connector_transaction_id: None,
316+
})
317+
}
318+
}
293319
}
294320
}
295321

@@ -912,9 +938,6 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Deutscheb
912938
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
913939
.attach_default_headers()
914940
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
915-
.set_body(types::RefundSyncType::get_request_body(
916-
self, req, connectors,
917-
)?)
918941
.build(),
919942
))
920943
}

crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,21 @@ impl TryFrom<RefundsResponseRouterData<RSync, DeutschebankPaymentsResponse>>
12241224
}
12251225
}
12261226

1227-
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
1228-
pub struct DeutschebankErrorResponse {
1227+
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone)]
1228+
pub struct PaymentsErrorResponse {
12291229
pub rc: String,
12301230
pub message: String,
12311231
}
1232+
1233+
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone)]
1234+
pub struct AccessTokenErrorResponse {
1235+
pub cause: String,
1236+
pub description: String,
1237+
}
1238+
1239+
#[derive(Debug, Serialize, Deserialize, Clone)]
1240+
#[serde(untagged)]
1241+
pub enum DeutschebankError {
1242+
PaymentsErrorResponse(PaymentsErrorResponse),
1243+
AccessTokenErrorResponse(AccessTokenErrorResponse),
1244+
}

0 commit comments

Comments
 (0)