Skip to content

Commit

Permalink
refactor(connector): [NMI] Include customer_vault_id for card 3ds tra…
Browse files Browse the repository at this point in the history
…nsaction request (#3777)
  • Loading branch information
Sakilmostak authored Feb 22, 2024
1 parent bbb3d3d commit 2e7d30a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
24 changes: 17 additions & 7 deletions crates/router/src/connector/nmi/transformers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use api_models::webhooks;
use cards::CardNumber;
use common_enums::CountryAlpha2;
use common_utils::{errors::CustomResult, ext_traits::XmlExt, pii};
use common_utils::{
errors::CustomResult,
ext_traits::XmlExt,
pii::{self, Email},
};
use error_stack::{IntoReport, Report, ResultExt};
use masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -254,12 +258,13 @@ pub struct NmiCompleteRequest {
transaction_type: TransactionType,
security_key: Secret<String>,
orderid: Option<String>,
ccnumber: CardNumber,
ccexp: Secret<String>,
customer_vault_id: String,
email: Option<Email>,
cardholder_auth: Option<String>,
cavv: Option<String>,
xid: Option<String>,
eci: Option<String>,
cvv: Secret<String>,
three_ds_version: Option<String>,
directory_server_id: Option<String>,
}
Expand All @@ -274,6 +279,7 @@ pub struct NmiRedirectResponseData {
three_ds_version: Option<String>,
order_id: Option<String>,
directory_server_id: Option<String>,
customer_vault_id: Option<String>,
}

impl TryFrom<&NmiRouterData<&types::PaymentsCompleteAuthorizeRouterData>> for NmiCompleteRequest {
Expand All @@ -298,16 +304,20 @@ impl TryFrom<&NmiRouterData<&types::PaymentsCompleteAuthorizeRouterData>> for Nm
field_name: "three_ds_data",
})?;

let (ccnumber, ccexp, ..) =
get_card_details(item.router_data.request.payment_method_data.clone())?;
let (_, _, cvv) = get_card_details(item.router_data.request.payment_method_data.clone())?;

Ok(Self {
amount: item.amount,
transaction_type,
security_key: auth_type.api_key,
orderid: three_ds_data.order_id,
ccnumber,
ccexp,
customer_vault_id: three_ds_data.customer_vault_id.ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "customer_vault_id",
},
)?,
email: item.router_data.request.email.clone(),
cvv,
cardholder_auth: three_ds_data.card_holder_auth,
cavv: three_ds_data.cavv,
xid: three_ds_data.xid,
Expand Down
12 changes: 9 additions & 3 deletions crates/router/src/services/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1870,11 +1870,17 @@ pub fn build_redirection_form(
responseForm.appendChild(item4);
var item5=document.createElement('input');
item4.type='hidden';
item4.name='orderId';
item4.value='{order_id}';
item5.type='hidden';
item5.name='orderId';
item5.value='{order_id}';
responseForm.appendChild(item5);
var item6=document.createElement('input');
item6.type='hidden';
item6.name='customerVaultId';
item6.value='{customer_vault_id}';
responseForm.appendChild(item6);
document.body.appendChild(responseForm);
responseForm.submit();
}});
Expand Down

0 comments on commit 2e7d30a

Please sign in to comment.