Skip to content

Commit

Permalink
fix(wasm): [Adyen] update connector account configs and integration b…
Browse files Browse the repository at this point in the history
…ugs (#3910)
  • Loading branch information
SamraatBansal committed Mar 1, 2024
1 parent ffbdc30 commit 6da1989
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 61 deletions.
2 changes: 2 additions & 0 deletions crates/connector_configs/src/common_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub struct ApiModelMetaData {
pub google_pay: Option<GoogleApiModelData>,
pub apple_pay: Option<ApplePayData>,
pub apple_pay_combined: Option<ApplePayData>,
pub endpoint_prefix: Option<String>,
}

#[serde_with::skip_serializing_none]
Expand Down Expand Up @@ -173,4 +174,5 @@ pub struct DashboardMetaData {
pub google_pay: Option<GooglePayData>,
pub apple_pay: Option<ApplePayData>,
pub apple_pay_combined: Option<ApplePayData>,
pub endpoint_prefix: Option<String>,
}
1 change: 1 addition & 0 deletions crates/connector_configs/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct ConfigMetadata {
pub google_pay: Option<GooglePayData>,
pub apple_pay: Option<ApplePayTomlConfig>,
pub merchant_id: Option<String>,
pub endpoint_prefix: Option<String>,
}

#[serde_with::skip_serializing_none]
Expand Down
5 changes: 5 additions & 0 deletions crates/connector_configs/src/response_modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ impl ConnectorApiIntegrationPayload {
Some(meta_data) => meta_data.terminal_id,
_ => None,
};
let endpoint_prefix = match response.metadata.clone() {
Some(meta_data) => meta_data.endpoint_prefix,
_ => None,
};
let apple_pay = match response.metadata.clone() {
Some(meta_data) => meta_data.apple_pay,
_ => None,
Expand All @@ -315,6 +319,7 @@ impl ConnectorApiIntegrationPayload {
account_name,
terminal_id,
merchant_id,
endpoint_prefix,
};

DashboardRequestPayload {
Expand Down
3 changes: 3 additions & 0 deletions crates/connector_configs/src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ impl DashboardRequestPayload {
merchant_account_id: None,
merchant_id: None,
merchant_config_currency: None,
endpoint_prefix: None,
};
let meta_data = match request.metadata {
Some(data) => data,
Expand All @@ -196,6 +197,7 @@ impl DashboardRequestPayload {
let merchant_account_id = meta_data.merchant_account_id.clone();
let merchant_id = meta_data.merchant_id.clone();
let terminal_id = meta_data.terminal_id.clone();
let endpoint_prefix = meta_data.endpoint_prefix.clone();
let apple_pay = meta_data.apple_pay;
let apple_pay_combined = meta_data.apple_pay_combined;
let merchant_config_currency = meta_data.merchant_config_currency;
Expand All @@ -208,6 +210,7 @@ impl DashboardRequestPayload {
merchant_id,
merchant_config_currency,
apple_pay_combined,
endpoint_prefix,
})
}

Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ pub enum BankNames {
TsbBank,
TescoBank,
UlsterBank,
Yoursafe,
N26,
NationaleNederlanden,
}

#[derive(
Expand Down
21 changes: 6 additions & 15 deletions crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,12 @@ fn build_env_specific_endpoint(
} else {
let adyen_connector_metadata_object =
transformers::AdyenConnectorMetadataObject::try_from(connector_metadata)?;
Ok(base_url.replace(
"{{merchant_endpoint_prefix}}",
&adyen_connector_metadata_object.endpoint_prefix,
))
let endpoint_prefix = adyen_connector_metadata_object.endpoint_prefix.ok_or(
errors::ConnectorError::InvalidConnectorConfig {
config: "metadata.endpoint_prefix",
},
)?;
Ok(base_url.replace("{{merchant_endpoint_prefix}}", &endpoint_prefix))
}
}

Expand Down Expand Up @@ -1556,17 +1558,6 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
impl services::ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponseData>
for Adyen
{
fn build_request(
&self,
_req: &types::RefundsRouterData<api::RSync>,
_connectors: &settings::Connectors,
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
Err(errors::ConnectorError::FlowNotSupported {
flow: "Rsync".to_owned(),
connector: "Adyen".to_owned(),
}
.into())
}
}

fn get_webhook_object_from_body(
Expand Down
40 changes: 25 additions & 15 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<T>
}
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct AdyenConnectorMetadataObject {
pub endpoint_prefix: String,
pub endpoint_prefix: Option<String>,
}

impl TryFrom<&Option<pii::SecretSerdeValue>> for AdyenConnectorMetadataObject {
Expand Down Expand Up @@ -106,7 +106,8 @@ pub enum AuthType {
#[serde(rename_all = "camelCase")]
pub struct AdditionalData {
authorisation_type: Option<AuthType>,
manual_capture: Option<bool>,
manual_capture: Option<String>,
execute_three_d: Option<String>,
pub recurring_processing_model: Option<AdyenRecurringModel>,
/// Enable recurring details in dashboard to receive this ID, https://docs.adyen.com/online-payments/tokenization/create-and-use-tokens#test-and-go-live
#[serde(rename = "recurring.recurringDetailReference")]
Expand Down Expand Up @@ -1641,19 +1642,28 @@ fn get_browser_info(
}

fn get_additional_data(item: &types::PaymentsAuthorizeRouterData) -> Option<AdditionalData> {
match item.request.capture_method {
let (authorisation_type, manual_capture) = match item.request.capture_method {
Some(diesel_models::enums::CaptureMethod::Manual)
| Some(diesel_models::enums::CaptureMethod::ManualMultiple) => Some(AdditionalData {
authorisation_type: Some(AuthType::PreAuth),
manual_capture: Some(true),
network_tx_reference: None,
recurring_detail_reference: None,
recurring_shopper_reference: None,
recurring_processing_model: Some(AdyenRecurringModel::UnscheduledCardOnFile),
..AdditionalData::default()
}),
_ => None,
}
| Some(diesel_models::enums::CaptureMethod::ManualMultiple) => {
(Some(AuthType::PreAuth), Some("true".to_string()))
}
_ => (None, None),
};
let execute_three_d = if matches!(item.auth_type, enums::AuthenticationType::ThreeDs) {
Some("true".to_string())
} else {
None
};
Some(AdditionalData {
authorisation_type,
manual_capture,
execute_three_d,
network_tx_reference: None,
recurring_detail_reference: None,
recurring_shopper_reference: None,
recurring_processing_model: None,
..AdditionalData::default()
})
}

fn get_channel_type(pm_type: &Option<storage_enums::PaymentMethodType>) -> Option<Channel> {
Expand Down Expand Up @@ -3809,7 +3819,7 @@ impl<F> TryFrom<types::RefundsResponseRouterData<F, AdyenRefundResponse>>
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(types::RefundsResponseData {
connector_refund_id: item.response.reference,
connector_refund_id: item.response.psp_reference,
// From the docs, the only value returned is "received", outcome of refund is available
// through refund notification webhook
// For more info: https://docs.adyen.com/online-payments/refund
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pm.test("[POST]::/payments/:id/cancel - Response has JSON Body", function () {
let jsonData = {};
try {
jsonData = pm.response.json();
} catch (e) {}
} catch (e) { }

// pm.collectionVariables - Set payment_id as variable for jsonData.payment_id
if (jsonData?.payment_id) {
Expand Down Expand Up @@ -53,9 +53,9 @@ if (jsonData?.client_secret) {
// Response body should have value "cancelled" for "status"
if (jsonData?.status) {
pm.test(
"[POST]::/payments/:id/cancel - Content check if value for 'status' matches 'cancelled'",
"[POST]::/payments/:id/cancel - Content check if value for 'status' matches 'processing'",
function () {
pm.expect(jsonData.status).to.eql("cancelled");
pm.expect(jsonData.status).to.eql("processing");
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pm.test("[GET]::/payments/:id - Response has JSON Body", function () {
let jsonData = {};
try {
jsonData = pm.response.json();
} catch (e) {}
} catch (e) { }

// pm.collectionVariables - Set payment_id as variable for jsonData.payment_id
if (jsonData?.payment_id) {
Expand Down Expand Up @@ -63,9 +63,9 @@ if (jsonData?.client_secret) {
// Response body should have value "cancelled" for "status"
if (jsonData?.status) {
pm.test(
"[POST]::/payments/:id - Content check if value for 'status' matches 'cancelled'",
"[POST]::/payments/:id - Content check if value for 'status' matches 'processing'",
function () {
pm.expect(jsonData.status).to.eql("cancelled");
pm.expect(jsonData.status).to.eql("processing");
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"key1": "{{connector_key1}}",
"api_secret": "{{connector_api_secret}}"
},
"test_mode": false,
"test_mode": true,
"disabled": false,
"business_country": "US",
"business_label": "default",
Expand All @@ -56,25 +56,35 @@
"payment_method_types": [
{
"payment_method_type": "credit",
"card_networks": ["AmericanExpress",
"Discover",
"Interac",
"JCB",
"Mastercard",
"Visa", "DinersClub","UnionPay","RuPay"],
"card_networks": [
"AmericanExpress",
"Discover",
"Interac",
"JCB",
"Mastercard",
"Visa",
"DinersClub",
"UnionPay",
"RuPay"
],
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
},
{
"payment_method_type": "debit",
"card_networks": ["AmericanExpress",
"Discover",
"Interac",
"JCB",
"Mastercard",
"Visa", "DinersClub","UnionPay","RuPay"],
"card_networks": [
"AmericanExpress",
"Discover",
"Interac",
"JCB",
"Mastercard",
"Visa",
"DinersClub",
"UnionPay",
"RuPay"
],
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
Expand Down Expand Up @@ -203,15 +213,15 @@
{
"payment_method": "gift_card",
"payment_method_types": [
{
"payment_method_type": "givex",
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
{
"payment_method_type": "givex",
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
},
},
{
"payment_method": "bank_redirect",
"payment_method_types": [
Expand Down Expand Up @@ -303,7 +313,10 @@
{
"type": "CARD",
"parameters": {
"allowed_auth_methods": ["PAN_ONLY", "CRYPTOGRAM_3DS"],
"allowed_auth_methods": [
"PAN_ONLY",
"CRYPTOGRAM_3DS"
],
"allowed_card_networks": [
"AMEX",
"DISCOVER",
Expand All @@ -327,8 +340,14 @@
},
"url": {
"raw": "{{baseUrl}}/account/:account_id/connectors",
"host": ["{{baseUrl}}"],
"path": ["account", ":account_id", "connectors"],
"host": [
"{{baseUrl}}"
],
"path": [
"account",
":account_id",
"connectors"
],
"variable": [
{
"key": "account_id",
Expand All @@ -338,4 +357,4 @@
]
},
"description": "Create a new Payment Connector for the merchant account. The connector could be a payment processor / facilitator / acquirer or specialised services like Fraud / Accounting etc."
}
}

0 comments on commit 6da1989

Please sign in to comment.