feat(router): add support for payment_type field in payment intent (#2448)

This commit is contained in:
ItsMeShashank
2023-10-05 16:30:47 +05:30
committed by GitHub
parent db7f9fa801
commit f116728d1c
16 changed files with 126 additions and 2 deletions

View File

@ -632,6 +632,27 @@ pub fn validate_card_data(
Ok(())
}
pub fn infer_payment_type(
amount: &api::Amount,
mandate_type: Option<&api::MandateTransactionType>,
) -> api_enums::PaymentType {
match mandate_type {
Some(api::MandateTransactionType::NewMandateTransaction) => {
if let api::Amount::Value(_) = amount {
api_enums::PaymentType::NewMandate
} else {
api_enums::PaymentType::SetupMandate
}
}
Some(api::MandateTransactionType::RecurringMandateTransaction) => {
api_enums::PaymentType::RecurringMandate
}
None => api_enums::PaymentType::Normal,
}
}
pub fn validate_mandate(
req: impl Into<api::MandateValidationFields>,
is_confirm_operation: bool,
@ -2377,6 +2398,7 @@ mod tests {
profile_id: None,
merchant_decision: None,
payment_confirm_source: None,
payment_type: Some(api_enums::PaymentType::Normal),
};
let req_cs = Some("1".to_string());
let merchant_fulfillment_time = Some(900);
@ -2424,6 +2446,7 @@ mod tests {
profile_id: None,
merchant_decision: None,
payment_confirm_source: None,
payment_type: Some(api_enums::PaymentType::Normal),
};
let req_cs = Some("1".to_string());
let merchant_fulfillment_time = Some(10);
@ -2471,6 +2494,7 @@ mod tests {
profile_id: None,
merchant_decision: None,
payment_confirm_source: None,
payment_type: Some(api_enums::PaymentType::Normal),
};
let req_cs = Some("1".to_string());
let merchant_fulfillment_time = Some(10);