Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(connector): [NMI] Include customer_vault_id for card 3ds transaction request #3779

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions crates/router/src/connector/nmi/transformers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use api_models::webhooks;
use cards::CardNumber;
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 @@ -241,12 +245,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 @@ -261,6 +266,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 @@ -285,16 +291,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 @@ -1869,11 +1869,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
Loading