mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
feat: fetch merchant key store only once per session (#1400)
Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
This commit is contained in:
@ -44,8 +44,8 @@ pub async fn customer_create(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
create_cust_req,
|
||||
|state, merchant_account, req| {
|
||||
customers::create_customer(&*state.store, merchant_account, req)
|
||||
|state, auth, req| {
|
||||
customers::create_customer(&*state.store, auth.merchant_account, auth.key_store, req)
|
||||
},
|
||||
&auth::ApiKeyAuth,
|
||||
)
|
||||
@ -78,8 +78,8 @@ pub async fn customer_retrieve(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
customers::retrieve_customer(&*state.store, merchant_account, req)
|
||||
|state, auth, req| {
|
||||
customers::retrieve_customer(&*state.store, auth.merchant_account, auth.key_store, req)
|
||||
},
|
||||
&auth::ApiKeyAuth,
|
||||
)
|
||||
@ -121,8 +121,8 @@ pub async fn customer_update(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
cust_update_req,
|
||||
|state, merchant_account, req| {
|
||||
customers::update_customer(&*state.store, merchant_account, req)
|
||||
|state, auth, req| {
|
||||
customers::update_customer(&*state.store, auth.merchant_account, req, auth.key_store)
|
||||
},
|
||||
&auth::ApiKeyAuth,
|
||||
)
|
||||
@ -155,7 +155,9 @@ pub async fn customer_delete(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
customers::delete_customer,
|
||||
|state, auth, req| {
|
||||
customers::delete_customer(state, auth.merchant_account, req, auth.key_store)
|
||||
},
|
||||
&auth::ApiKeyAuth,
|
||||
)
|
||||
.await
|
||||
@ -185,7 +187,9 @@ pub async fn list_customer_payment_method_api(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
customer_id.as_ref(),
|
||||
cards::list_customer_payment_method,
|
||||
|state, auth, req| {
|
||||
cards::list_customer_payment_method(state, auth.merchant_account, auth.key_store, req)
|
||||
},
|
||||
&auth::ApiKeyAuth,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -49,10 +49,11 @@ pub async fn payment_intents_create(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
create_payment_req,
|
||||
|state, merchant_account, req| {
|
||||
|state, auth, req| {
|
||||
payments::payments_core::<api_types::Authorize, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentCreate,
|
||||
req,
|
||||
api::AuthFlow::Merchant,
|
||||
@ -100,10 +101,11 @@ pub async fn payment_intents_retrieve(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, payload| {
|
||||
|state, auth, payload| {
|
||||
payments::payments_core::<api_types::PSync, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentStatus,
|
||||
payload,
|
||||
auth_flow,
|
||||
@ -160,10 +162,11 @@ pub async fn payment_intents_retrieve_with_gateway_creds(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
|state, auth, req| {
|
||||
payments::payments_core::<api_types::PSync, payment_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentStatus,
|
||||
req,
|
||||
api::AuthFlow::Merchant,
|
||||
@ -221,10 +224,11 @@ pub async fn payment_intents_update(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
|state, auth, req| {
|
||||
payments::payments_core::<api_types::Authorize, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentUpdate,
|
||||
req,
|
||||
auth_flow,
|
||||
@ -284,10 +288,11 @@ pub async fn payment_intents_confirm(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
|state, auth, req| {
|
||||
payments::payments_core::<api_types::Authorize, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentConfirm,
|
||||
req,
|
||||
auth_flow,
|
||||
@ -337,10 +342,11 @@ pub async fn payment_intents_capture(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
capture_payload,
|
||||
|state, merchant_account, payload| {
|
||||
|state, auth, payload| {
|
||||
payments::payments_core::<api_types::Capture, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentCapture,
|
||||
payload,
|
||||
api::AuthFlow::Merchant,
|
||||
@ -394,10 +400,11 @@ pub async fn payment_intents_cancel(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
|state, auth, req| {
|
||||
payments::payments_core::<api_types::Void, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentCancel,
|
||||
req,
|
||||
auth_flow,
|
||||
@ -437,9 +444,7 @@ pub async fn payment_intent_list(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
payments::list_payments(&*state.store, merchant_account, req)
|
||||
},
|
||||
|state, auth, req| payments::list_payments(&*state.store, auth.merchant_account, req),
|
||||
&auth::ApiKeyAuth,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -45,7 +45,9 @@ pub async fn refund_create(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
create_refund_req,
|
||||
refunds::refund_create_core,
|
||||
|state, auth, req| {
|
||||
refunds::refund_create_core(state, auth.merchant_account, auth.key_store, req)
|
||||
},
|
||||
&auth::ApiKeyAuth,
|
||||
)
|
||||
.await
|
||||
@ -82,10 +84,11 @@ pub async fn refund_retrieve_with_gateway_creds(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
refund_request,
|
||||
|state, merchant_account, refund_request| {
|
||||
|state, auth, refund_request| {
|
||||
refunds::refund_response_wrapper(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
refund_request,
|
||||
refunds::refund_retrieve_core,
|
||||
)
|
||||
@ -123,10 +126,11 @@ pub async fn refund_retrieve(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
refund_request,
|
||||
|state, merchant_account, refund_request| {
|
||||
|state, auth, refund_request| {
|
||||
refunds::refund_response_wrapper(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
refund_request,
|
||||
refunds::refund_retrieve_core,
|
||||
)
|
||||
@ -162,8 +166,8 @@ pub async fn refund_update(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
create_refund_update_req,
|
||||
|state, merchant_account, req| {
|
||||
refunds::refund_update_core(&*state.store, merchant_account, &refund_id, req)
|
||||
|state, auth, req| {
|
||||
refunds::refund_update_core(&*state.store, auth.merchant_account, &refund_id, req)
|
||||
},
|
||||
&auth::ApiKeyAuth,
|
||||
)
|
||||
|
||||
@ -50,10 +50,11 @@ pub async fn setup_intents_create(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
create_payment_req,
|
||||
|state, merchant_account, req| {
|
||||
|state, auth, req| {
|
||||
payments::payments_core::<api_types::Verify, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentCreate,
|
||||
req,
|
||||
api::AuthFlow::Merchant,
|
||||
@ -101,10 +102,11 @@ pub async fn setup_intents_retrieve(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, payload| {
|
||||
|state, auth, payload| {
|
||||
payments::payments_core::<api_types::PSync, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentStatus,
|
||||
payload,
|
||||
auth_flow,
|
||||
@ -163,10 +165,11 @@ pub async fn setup_intents_update(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
|state, auth, req| {
|
||||
payments::payments_core::<api_types::Verify, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentUpdate,
|
||||
req,
|
||||
auth_flow,
|
||||
@ -226,10 +229,11 @@ pub async fn setup_intents_confirm(
|
||||
state.get_ref(),
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
|state, auth, req| {
|
||||
payments::payments_core::<api_types::Verify, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
auth.merchant_account,
|
||||
auth.key_store,
|
||||
payments::PaymentConfirm,
|
||||
req,
|
||||
auth_flow,
|
||||
|
||||
Reference in New Issue
Block a user