feat(core): accept gateway credentials in the request body in payments and refunds (#766)

This commit is contained in:
Abhishek
2023-03-21 14:37:41 +05:30
committed by GitHub
parent d302b286b8
commit cb188f92a6
35 changed files with 748 additions and 130 deletions

View File

@ -3,7 +3,7 @@ use std::marker::PhantomData;
use error_stack::ResultExt;
use router_env::{instrument, tracing};
use super::payments::PaymentAddress;
use super::payments::{helpers, PaymentAddress};
use crate::{
consts,
core::errors::{self, RouterResult},
@ -25,18 +25,19 @@ pub async fn construct_refund_router_data<'a, F>(
payment_intent: &'a storage::PaymentIntent,
payment_attempt: &storage::PaymentAttempt,
refund: &'a storage::Refund,
creds_identifier: Option<String>,
) -> RouterResult<types::RefundsRouterData<F>> {
let db = &*state.store;
let merchant_connector_account = db
.find_merchant_connector_account_by_merchant_id_connector(
&merchant_account.merchant_id,
connector_id,
)
.await
.change_context(errors::ApiErrorResponse::MerchantAccountNotFound)?;
let merchant_connector_account = helpers::get_merchant_connector_account(
db,
merchant_account.merchant_id.as_str(),
connector_id,
creds_identifier,
)
.await?;
let auth_type: types::ConnectorAuthType = merchant_connector_account
.connector_account_details
.get_connector_account_details()
.parse_value("ConnectorAuthType")
.change_context(errors::ApiErrorResponse::InternalServerError)?;
@ -51,7 +52,7 @@ pub async fn construct_refund_router_data<'a, F>(
let router_data = types::RouterData {
flow: PhantomData,
merchant_id: merchant_account.merchant_id.clone(),
connector: merchant_connector_account.connector_name,
connector: connector_id.to_string(),
payment_id: payment_attempt.payment_id.clone(),
attempt_id: payment_attempt.attempt_id.clone(),
status,
@ -65,7 +66,7 @@ pub async fn construct_refund_router_data<'a, F>(
// Does refund need shipping/billing address ?
address: PaymentAddress::default(),
auth_type: payment_attempt.authentication_type.unwrap_or_default(),
connector_meta_data: merchant_connector_account.metadata,
connector_meta_data: merchant_connector_account.get_metadata(),
amount_captured: payment_intent.amount_captured,
request: types::RefundsData {
refund_id: refund.refund_id.clone(),