feat(connector): [Iatapay] add upi qr support (#4728)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: SamraatBansal <55536657+SamraatBansal@users.noreply.github.com>
This commit is contained in:
AkshayaFoiger
2024-05-28 13:06:53 +05:30
committed by GitHub
parent d15cb31814
commit c9fa94febe
22 changed files with 257 additions and 65 deletions

View File

@ -1009,6 +1009,7 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
api_models::payments::NextActionData::DisplayBankTransferInformation { .. } => None,
api_models::payments::NextActionData::ThirdPartySdkSessionToken { .. } => None,
api_models::payments::NextActionData::QrCodeInformation{..} => None,
api_models::payments::NextActionData::FetchQrCodeInformation{..} => None,
api_models::payments::NextActionData::DisplayVoucherInformation{ .. } => None,
api_models::payments::NextActionData::WaitScreenInformation{..} => None,
api_models::payments::NextActionData::ThreeDsInvoke{..} => None,

View File

@ -2338,7 +2338,7 @@ pub fn validate_payment_method_type_against_payment_method(
),
api_enums::PaymentMethod::Upi => matches!(
payment_method_type,
api_enums::PaymentMethodType::UpiCollect
api_enums::PaymentMethodType::UpiCollect | api_enums::PaymentMethodType::UpiIntent
),
api_enums::PaymentMethod::Voucher => matches!(
payment_method_type,
@ -4252,9 +4252,9 @@ pub fn get_key_params_for_surcharge_details(
)),
api_models::payments::PaymentMethodData::MandatePayment => None,
api_models::payments::PaymentMethodData::Reward => None,
api_models::payments::PaymentMethodData::Upi(_) => Some((
api_models::payments::PaymentMethodData::Upi(upi_data) => Some((
common_enums::PaymentMethod::Upi,
common_enums::PaymentMethodType::UpiCollect,
upi_data.get_payment_method_type(),
None,
)),
api_models::payments::PaymentMethodData::Voucher(voucher) => Some((

View File

@ -541,6 +541,9 @@ where
let papal_sdk_next_action = paypal_sdk_next_steps_check(payment_attempt.clone())?;
let next_action_containing_fetch_qr_code_url =
fetch_qr_code_url_next_steps_check(payment_attempt.clone())?;
let next_action_containing_wait_screen =
wait_screen_next_steps_check(payment_attempt.clone())?;
@ -550,6 +553,7 @@ where
|| next_action_containing_qr_code_url.is_some()
|| next_action_containing_wait_screen.is_some()
|| papal_sdk_next_action.is_some()
|| next_action_containing_fetch_qr_code_url.is_some()
|| payment_data.authentication.is_some()
{
next_action_response = bank_transfer_next_steps
@ -566,6 +570,11 @@ where
.or(next_action_containing_qr_code_url.map(|qr_code_data| {
api_models::payments::NextActionData::foreign_from(qr_code_data)
}))
.or(next_action_containing_fetch_qr_code_url.map(|fetch_qr_code_data| {
api_models::payments::NextActionData::FetchQrCodeInformation {
qr_code_fetch_url: fetch_qr_code_data.qr_code_fetch_url
}
}))
.or(papal_sdk_next_action.map(|paypal_next_action_data| {
api_models::payments::NextActionData::InvokeSdkClient{
next_action_data: paypal_next_action_data
@ -899,6 +908,18 @@ pub fn paypal_sdk_next_steps_check(
Ok(paypal_next_steps)
}
pub fn fetch_qr_code_url_next_steps_check(
payment_attempt: storage::PaymentAttempt,
) -> RouterResult<Option<api_models::payments::FetchQrCodeInformation>> {
let qr_code_steps: Option<Result<api_models::payments::FetchQrCodeInformation, _>> =
payment_attempt
.connector_metadata
.map(|metadata| metadata.parse_value("FetchQrCodeInformation"));
let qr_code_fetch_url = qr_code_steps.transpose().ok().flatten();
Ok(qr_code_fetch_url)
}
pub fn wait_screen_next_steps_check(
payment_attempt: storage::PaymentAttempt,
) -> RouterResult<Option<api_models::payments::WaitScreenInstructions>> {
@ -1108,8 +1129,8 @@ impl ForeignFrom<api_models::payments::QrCodeInformation> for api_models::paymen
display_to_timestamp,
} => Self::QrCodeInformation {
qr_code_url: Some(qr_code_url),
display_to_timestamp,
image_data_url: None,
display_to_timestamp,
},
}
}