refactor: separate DB queries and HTML creation for payout links (#4967)

Signed-off-by: Chikke Srujan <chikke.srujan@Chikke-Srujan-C02FC60MMD6M.local>
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Signed-off-by: Chikke Srujan <chikke.srujan@Chikke-Srujan-G961M60MK7.local>
Co-authored-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Co-authored-by: Chikke Srujan <chikke.srujan@Chikke-Srujan-C02FC60MMD6M.local>
Co-authored-by: Srujan chikke <chikke.srujan@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Chikke Srujan <chikke.srujan@Chikke-Srujan-G961M60MK7.local>
This commit is contained in:
Kashif
2024-06-25 19:37:10 +05:30
committed by GitHub
parent 7c639bf878
commit 9e4b2d1c11
92 changed files with 4442 additions and 199 deletions

View File

@ -7,7 +7,10 @@ use time::PrimitiveDateTime;
use super::app::{AppState, SessionState};
use crate::{
core::{api_locking, errors, payment_methods::cards},
core::{
api_locking, errors,
payment_methods::{self as payment_methods_routes, cards},
},
services::{api, authentication as auth, authorization::permissions::Permission},
types::{
api::payment_methods::{self, PaymentMethodId},
@ -223,6 +226,65 @@ pub async fn list_customer_payment_method_api_client(
.await
}
/// Generate a form link for collecting payment methods for a customer
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodCollectLink))]
pub async fn initiate_pm_collect_link_flow(
state: web::Data<AppState>,
req: HttpRequest,
json_payload: web::Json<payment_methods::PaymentMethodCollectLinkRequest>,
) -> HttpResponse {
let flow = Flow::PaymentMethodCollectLink;
Box::pin(api::server_wrap(
flow,
state,
&req,
json_payload.into_inner(),
|state, auth, req, _| {
payment_methods_routes::initiate_pm_collect_link(
state,
auth.merchant_account,
auth.key_store,
req,
)
},
&auth::ApiKeyAuth,
api_locking::LockAction::NotApplicable,
))
.await
}
/// Generate a form link for collecting payment methods for a customer
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodCollectLink))]
pub async fn render_pm_collect_link(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<(String, String)>,
) -> HttpResponse {
let flow = Flow::PaymentMethodCollectLink;
let (merchant_id, pm_collect_link_id) = path.into_inner();
let payload = payment_methods::PaymentMethodCollectLinkRenderRequest {
merchant_id: merchant_id.clone(),
pm_collect_link_id,
};
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
|state, auth, req, _| {
payment_methods_routes::render_pm_collect_link(
state,
auth.merchant_account,
auth.key_store,
req,
)
},
&auth::MerchantIdAuth(merchant_id),
api_locking::LockAction::NotApplicable,
))
.await
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsRetrieve))]
pub async fn payment_method_retrieve_api(
state: web::Data<AppState>,