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:
Kartikeya Hegde
2023-06-22 14:40:28 +05:30
committed by GitHub
parent 957d5e0f62
commit d321aa1f72
65 changed files with 979 additions and 498 deletions

View File

@ -35,8 +35,8 @@ pub async fn create_payment_method_api(
state.get_ref(),
&req,
json_payload.into_inner(),
|state, merchant_account, req| async move {
cards::add_payment_method(state, req, &merchant_account).await
|state, auth, req| async move {
cards::add_payment_method(state, req, &auth.merchant_account).await
},
&auth::ApiKeyAuth,
)
@ -85,7 +85,9 @@ pub async fn list_payment_method_api(
state.get_ref(),
&req,
payload,
cards::list_payment_methods,
|state, auth, req| {
cards::list_payment_methods(state, auth.merchant_account, auth.key_store, req)
},
&*auth,
)
.await
@ -136,8 +138,13 @@ pub async fn list_customer_payment_method_api(
state.get_ref(),
&req,
json_payload.into_inner(),
|state, merchant_account, _| {
cards::list_customer_payment_method(state, merchant_account, &customer_id)
|state, auth, _| {
cards::list_customer_payment_method(
state,
auth.merchant_account,
auth.key_store,
&customer_id,
)
},
&*auth_type,
)
@ -178,7 +185,7 @@ pub async fn payment_method_retrieve_api(
state.get_ref(),
&req,
payload,
|state, merchant_account, pm| cards::retrieve_payment_method(state, pm, merchant_account),
|state, auth, pm| cards::retrieve_payment_method(state, pm, auth.merchant_account),
&auth::ApiKeyAuth,
)
.await
@ -217,10 +224,10 @@ pub async fn payment_method_update_api(
state.get_ref(),
&req,
json_payload.into_inner(),
|state, merchant_account, payload| {
|state, auth, payload| {
cards::update_customer_payment_method(
state,
merchant_account,
auth.merchant_account,
payload,
&payment_method_id,
)
@ -262,7 +269,7 @@ pub async fn payment_method_delete_api(
state.get_ref(),
&req,
pm,
cards::delete_payment_method,
|state, auth, req| cards::delete_payment_method(state, auth.merchant_account, req),
&auth::ApiKeyAuth,
)
.await