feat: PG Agnostic mandate using network_txns_id (Adyen, Authorizedotnet, Stripe) (#855)

Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
Manoj Ghorela
2023-05-03 15:48:51 +05:30
committed by GitHub
parent 9240e16ae4
commit ed99655ebc
72 changed files with 1129 additions and 101 deletions

View File

@ -104,10 +104,19 @@ where
)
.await?;
let (payment_data, tokenization_action) =
let (mut payment_data, tokenization_action) =
get_connector_tokenization_action(state, &operation, payment_data, &validate_result)
.await?;
let updated_customer = call_create_connector_customer(
state,
&connector,
&customer,
&merchant_account,
&mut payment_data,
)
.await?;
let (operation, mut payment_data) = operation
.to_update_tracker()?
.update_trackers(
@ -116,6 +125,7 @@ where
payment_data,
customer.clone(),
validate_result.storage_scheme,
updated_customer,
)
.await?;
@ -469,7 +479,7 @@ where
let stime_connector = Instant::now();
let mut router_data = payment_data
.construct_router_data(state, connector.connector.id(), merchant_account)
.construct_router_data(state, connector.connector.id(), merchant_account, customer)
.await?;
let add_access_token_result = router_data
@ -539,7 +549,7 @@ where
for connector in connectors.iter() {
let connector_id = connector.connector.id();
let router_data = payment_data
.construct_router_data(state, connector_id, merchant_account)
.construct_router_data(state, connector_id, merchant_account, customer)
.await?;
let res = router_data.decide_flows(
@ -583,6 +593,50 @@ where
Ok(payment_data)
}
pub async fn call_create_connector_customer<F, Req>(
state: &AppState,
connector: &Option<api::ConnectorCallType>,
customer: &Option<storage::Customer>,
merchant_account: &storage::MerchantAccount,
payment_data: &mut PaymentData<F>,
) -> RouterResult<Option<storage::CustomerUpdate>>
where
F: Send + Clone + Sync,
Req: Send + Sync,
// To create connector flow specific interface data
PaymentData<F>: ConstructFlowSpecificData<F, Req, types::PaymentsResponseData>,
types::RouterData<F, Req, types::PaymentsResponseData>: Feature<F, Req> + Send,
// To construct connector flow specific api
dyn api::Connector: services::api::ConnectorIntegration<F, Req, types::PaymentsResponseData>,
// To perform router related operation for PaymentResponse
PaymentResponse: Operation<F, Req>,
{
match connector {
Some(connector_details) => match connector_details {
api::ConnectorCallType::Single(connector) => {
let router_data = payment_data
.construct_router_data(
state,
connector.connector.id(),
merchant_account,
customer,
)
.await?;
let (connector_customer, customer_update) = router_data
.create_connector_customer(state, connector, customer)
.await?;
payment_data.connector_customer_id = connector_customer;
Ok(customer_update)
}
api::ConnectorCallType::Multiple(_) => Ok(None),
},
None => Ok(None),
}
}
fn is_payment_method_tokenization_enabled_for_connector(
state: &AppState,
connector_name: &str,
@ -766,6 +820,7 @@ where
pub email: Option<masking::Secret<String, pii::Email>>,
pub creds_identifier: Option<String>,
pub pm_token: Option<String>,
pub connector_customer_id: Option<String>,
}
#[derive(Debug, Default)]