feat(list_pm): allow client secret authentication for list payment method api (#126)

This commit is contained in:
Nishant Joshi
2022-12-13 14:03:33 +05:30
committed by GitHub
parent 3acde2603b
commit 6bf9904867
9 changed files with 268 additions and 121 deletions

View File

@ -586,10 +586,13 @@ pub async fn authenticate_connector<'a>(
}
}
pub(crate) fn get_auth_type_and_check_client_secret(
pub(crate) fn get_auth_type_and_check_client_secret<P>(
req: &actix_web::HttpRequest,
payload: types::api::PaymentsRequest,
) -> RouterResult<(types::api::PaymentsRequest, MerchantAuthentication)> {
payload: P,
) -> RouterResult<(P, MerchantAuthentication)>
where
P: Authenticate,
{
let auth_type = get_auth_type(req)?;
Ok((
payments::helpers::client_secret_auth(payload, &auth_type)?,
@ -701,6 +704,22 @@ pub trait ConnectorRedirectResponse {
}
}
pub trait Authenticate {
fn get_client_secret(&self) -> Option<&String>;
}
impl Authenticate for api_models::payments::PaymentsRequest {
fn get_client_secret(&self) -> Option<&String> {
self.client_secret.as_ref()
}
}
impl Authenticate for api_models::payment_methods::ListPaymentMethodRequest {
fn get_client_secret(&self) -> Option<&String> {
self.client_secret.as_ref()
}
}
pub fn build_redirection_form(form: &RedirectForm) -> maud::Markup {
use maud::PreEscaped;