Skip to content

Commit 3547eac

Browse files
Anurag-05-progAnurag Singhhyperswitch-bot[bot]
authored
fix(connector): Change Refund Reason Type in Adyen (#8849)
Co-authored-by: Anurag Singh <[email protected]> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 8bbb768 commit 3547eac

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

crates/connector_configs/toml/production.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ payment_method_type = "apple_pay"
114114
payment_method_type = "google_pay"
115115
[[adyen.wallet]]
116116
payment_method_type = "paypal"
117+
[[adyen.voucher]]
118+
payment_method_type = "boleto"
117119
[adyen.connector_auth.BodyKey]
118120
api_key = "Adyen API Key"
119121
key1 = "Adyen Account Id"

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

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::str::FromStr;
2+
13
#[cfg(feature = "payouts")]
24
use api_models::payouts::{self, PayoutMethodData};
35
use api_models::{
@@ -1390,12 +1392,37 @@ pub struct DokuBankData {
13901392
pub struct AdyenRefundRequest {
13911393
merchant_account: Secret<String>,
13921394
amount: Amount,
1393-
merchant_refund_reason: Option<String>,
1395+
merchant_refund_reason: Option<AdyenRefundRequestReason>,
13941396
reference: String,
13951397
splits: Option<Vec<AdyenSplitData>>,
13961398
store: Option<String>,
13971399
}
13981400

1401+
#[derive(Debug, Serialize, Deserialize)]
1402+
pub enum AdyenRefundRequestReason {
1403+
FRAUD,
1404+
#[serde(rename = "CUSTOMER REQUEST")]
1405+
CUSTOMERREQUEST,
1406+
RETURN,
1407+
DUPLICATE,
1408+
OTHER,
1409+
}
1410+
1411+
impl FromStr for AdyenRefundRequestReason {
1412+
type Err = error_stack::Report<errors::ConnectorError>;
1413+
1414+
fn from_str(s: &str) -> Result<Self, Self::Err> {
1415+
match s.to_uppercase().as_str() {
1416+
"FRAUD" => Ok(Self::FRAUD),
1417+
"CUSTOMER REQUEST" => Ok(Self::CUSTOMERREQUEST),
1418+
"RETURN" => Ok(Self::RETURN),
1419+
"DUPLICATE" => Ok(Self::DUPLICATE),
1420+
"OTHER" => Ok(Self::OTHER),
1421+
_ => Ok(Self::OTHER),
1422+
}
1423+
}
1424+
}
1425+
13991426
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
14001427
#[serde(rename_all = "camelCase")]
14011428
pub struct AdyenRefundResponse {
@@ -4709,7 +4736,13 @@ impl<F> TryFrom<&AdyenRouterData<&RefundsRouterData<F>>> for AdyenRefundRequest
47094736
currency: item.router_data.request.currency,
47104737
value: item.amount,
47114738
},
4712-
merchant_refund_reason: item.router_data.request.reason.clone(),
4739+
merchant_refund_reason: item
4740+
.router_data
4741+
.request
4742+
.reason
4743+
.as_ref()
4744+
.map(|reason| AdyenRefundRequestReason::from_str(reason))
4745+
.transpose()?,
47134746
reference: item.router_data.request.refund_id.clone(),
47144747
store,
47154748
splits,

0 commit comments

Comments
 (0)