mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat(router): add straight-through routing connector selection in payments (#153)
This commit is contained in:
@ -349,6 +349,7 @@ impl From<ApiErrorResponse> for ErrorCode {
|
||||
ApiErrorResponse::RefundFailed { data } => ErrorCode::RefundFailed, // Nothing at stripe to map
|
||||
|
||||
ApiErrorResponse::InternalServerError => ErrorCode::InternalServerError, // not a stripe code
|
||||
ApiErrorResponse::IncorrectConnectorNameGiven => ErrorCode::InternalServerError,
|
||||
ApiErrorResponse::MandateActive => ErrorCode::MandateActive, //not a stripe code
|
||||
ApiErrorResponse::CustomerRedacted => ErrorCode::CustomerRedacted, //not a stripe code
|
||||
ApiErrorResponse::DuplicateRefundRequest => ErrorCode::DuplicateRefundRequest,
|
||||
|
||||
@ -47,12 +47,14 @@ pub async fn payment_intents_create(
|
||||
&req,
|
||||
create_payment_req,
|
||||
|state, merchant_account, req| {
|
||||
let connector = req.connector;
|
||||
payments::payments_core::<Authorize, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
payments::PaymentCreate,
|
||||
req,
|
||||
api::AuthFlow::Merchant,
|
||||
connector,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
@ -101,6 +103,7 @@ pub async fn payment_intents_retrieve(
|
||||
payments::PaymentStatus,
|
||||
payload,
|
||||
auth_flow,
|
||||
None,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
@ -149,12 +152,14 @@ pub async fn payment_intents_update(
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
let connector = req.connector;
|
||||
payments::payments_core::<Authorize, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
payments::PaymentUpdate,
|
||||
req,
|
||||
auth_flow,
|
||||
connector,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
@ -204,12 +209,14 @@ pub async fn payment_intents_confirm(
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
let connector = req.connector;
|
||||
payments::payments_core::<Authorize, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
payments::PaymentConfirm,
|
||||
req,
|
||||
auth_flow,
|
||||
connector,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
@ -257,6 +264,7 @@ pub async fn payment_intents_capture(
|
||||
payments::PaymentCapture,
|
||||
payload,
|
||||
api::AuthFlow::Merchant,
|
||||
None,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
@ -310,6 +318,7 @@ pub async fn payment_intents_cancel(
|
||||
payments::PaymentCancel,
|
||||
req,
|
||||
auth_flow,
|
||||
None,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
|
||||
@ -114,6 +114,7 @@ impl From<Shipping> for Address {
|
||||
#[derive(Default, PartialEq, Eq, Deserialize, Clone)]
|
||||
pub(crate) struct StripePaymentIntentRequest {
|
||||
pub(crate) amount: Option<i64>, //amount in cents, hence passed as integer
|
||||
pub(crate) connector: Option<api_enums::Connector>,
|
||||
pub(crate) currency: Option<String>,
|
||||
#[serde(rename = "amount_to_capture")]
|
||||
pub(crate) amount_capturable: Option<i64>,
|
||||
@ -137,6 +138,7 @@ impl From<StripePaymentIntentRequest> for PaymentsRequest {
|
||||
fn from(item: StripePaymentIntentRequest) -> Self {
|
||||
PaymentsRequest {
|
||||
amount: item.amount.map(|amount| amount.into()),
|
||||
connector: item.connector,
|
||||
currency: item.currency.as_ref().map(|c| c.to_uppercase()),
|
||||
capture_method: item.capture_method,
|
||||
amount_to_capture: item.amount_capturable,
|
||||
|
||||
@ -43,12 +43,14 @@ pub async fn setup_intents_create(
|
||||
&req,
|
||||
create_payment_req,
|
||||
|state, merchant_account, req| {
|
||||
let connector = req.connector;
|
||||
payments::payments_core::<Verify, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
payments::PaymentCreate,
|
||||
req,
|
||||
api::AuthFlow::Merchant,
|
||||
connector,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
@ -97,6 +99,7 @@ pub async fn setup_intents_retrieve(
|
||||
payments::PaymentStatus,
|
||||
payload,
|
||||
auth_flow,
|
||||
None,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
@ -145,12 +148,14 @@ pub async fn setup_intents_update(
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
let connector = req.connector;
|
||||
payments::payments_core::<Verify, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
payments::PaymentUpdate,
|
||||
req,
|
||||
auth_flow,
|
||||
connector,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
@ -200,12 +205,14 @@ pub async fn setup_intents_confirm(
|
||||
&req,
|
||||
payload,
|
||||
|state, merchant_account, req| {
|
||||
let connector = req.connector;
|
||||
payments::payments_core::<Verify, api_types::PaymentsResponse, _, _, _>(
|
||||
state,
|
||||
merchant_account,
|
||||
payments::PaymentConfirm,
|
||||
req,
|
||||
auth_flow,
|
||||
connector,
|
||||
payments::CallConnectorAction::Trigger,
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user