WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions api-reference/v1/openapi_spec_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -27903,14 +27903,6 @@
"description": "Allowed Payment Method Types for a given PaymentIntent",
"nullable": true
},
"ephemeral_key": {
"allOf": [
{
"$ref": "#/components/schemas/EphemeralKeyCreateResponse"
}
],
"nullable": true
},
"manual_retry_allowed": {
"type": "boolean",
"description": "If true the payment can be retried with same or different payment method which means the confirm call can be made again.",
Expand Down Expand Up @@ -29496,14 +29488,6 @@
"description": "Allowed Payment Method Types for a given PaymentIntent",
"nullable": true
},
"ephemeral_key": {
"allOf": [
{
"$ref": "#/components/schemas/EphemeralKeyCreateResponse"
}
],
"nullable": true
},
"manual_retry_allowed": {
"type": "boolean",
"description": "If true the payment can be retried with same or different payment method which means the confirm call can be made again.",
Expand Down
6 changes: 1 addition & 5 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ use crate::{
},
};
#[cfg(feature = "v1")]
use crate::{disputes, ephemeral_key::EphemeralKeyCreateResponse, refunds, ValidateFieldAndGet};
use crate::{disputes, refunds, ValidateFieldAndGet};

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum PaymentOp {
Expand Down Expand Up @@ -7122,10 +7122,6 @@ pub struct PaymentsResponse {
#[smithy(value_type = "Option<Vec<PaymentMethodType>>")]
pub allowed_payment_method_types: Option<serde_json::Value>,

/// ephemeral_key for the customer_id mentioned
#[smithy(value_type = "Option<EphemeralKeyCreateResponse>")]
pub ephemeral_key: Option<EphemeralKeyCreateResponse>,

/// If true the payment can be retried with same or different payment method which means the confirm call can be made again.
#[smithy(value_type = "Option<bool>")]
pub manual_retry_allowed: Option<bool>,
Expand Down
23 changes: 16 additions & 7 deletions crates/router/src/core/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,12 +975,23 @@ impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {

// This supports changing the business profile by passing in the profile_id
let business_profile_id_update = if let Some(ref profile_id) = self.default_profile {
let merchant_account = db
.find_merchant_account_by_merchant_id(merchant_id, key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;

let platform = domain::Platform::new(
merchant_account.clone(),
key_store.clone(),
merchant_account,
key_store.clone(),
);

// Validate whether profile_id passed in request is valid and is linked to the merchant
core_utils::validate_and_get_business_profile(
state.store.as_ref(),
key_store,
platform.get_processor(),
Some(profile_id),
merchant_id,
)
.await?
.map(|business_profile| Some(business_profile.get_id().to_owned()))
Expand Down Expand Up @@ -2169,9 +2180,8 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {

let business_profile = core_utils::validate_and_get_business_profile(
db,
platform.get_processor().get_key_store(),
platform.get_processor(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
)
.await?
.get_required_value("Profile")
Expand Down Expand Up @@ -2380,9 +2390,8 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {

let business_profile = core_utils::validate_and_get_business_profile(
db,
platform.get_processor().get_key_store(),
platform.get_processor(),
Some(&profile_id),
platform.get_processor().get_account().get_id(),
)
.await?
.get_required_value("Profile")
Expand Down Expand Up @@ -2447,7 +2456,7 @@ pub async fn create_connector(
helpers::validate_business_details(
req.business_country,
req.business_label.as_ref(),
&platform,
platform.get_processor(),
)?;

let business_profile = req
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub async fn construct_fulfillment_router_data<'a>(
payment_method_balance: None,
connector_request_reference_id: core_utils::get_connector_request_reference_id(
&state.conf,
platform.get_processor().get_account().get_id(),
platform.get_processor(),
payment_intent,
payment_attempt,
&connector_id,
Expand Down
8 changes: 7 additions & 1 deletion crates/router/src/core/payment_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,16 @@ pub fn extract_payment_link_config(
pub fn get_payment_link_config_based_on_priority(
payment_create_link_config: Option<api_models::payments::PaymentCreatePaymentLinkConfig>,
business_link_config: Option<diesel_models::business_profile::BusinessPaymentLinkConfig>,
merchant_name: String,
processor: &domain::Processor,
default_domain_name: String,
payment_link_config_id: Option<String>,
) -> Result<(PaymentLinkConfig, String), error_stack::Report<errors::ApiErrorResponse>> {
let merchant_name = processor
.get_account()
.merchant_name
.clone()
.map(|name| name.into_inner().peek().to_owned())
.unwrap_or_default();
let (domain_name, business_theme_configs, allowed_domains, branding_visibility) =
if let Some(ref business_config) = business_link_config {
(
Expand Down
114 changes: 108 additions & 6 deletions crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4281,9 +4281,8 @@ pub async fn list_customer_payment_method(

let business_profile = core_utils::validate_and_get_business_profile(
db,
platform.get_processor().get_key_store(),
platform.get_processor(),
profile_id.as_ref(),
platform.get_processor().get_account().get_id(),
)
.await?;

Expand Down Expand Up @@ -4721,7 +4720,7 @@ pub async fn get_lookup_key_from_locker(
state: &routes::SessionState,
payment_token: &str,
pm: &domain::PaymentMethod,
merchant_key_store: &domain::MerchantKeyStore,
provider: &domain::Provider,
) -> errors::RouterResult<api::CardDetailFromLocker> {
let card_detail = get_card_details_from_locker(state, pm).await?;
let card = card_detail.clone();
Expand All @@ -4731,7 +4730,29 @@ pub async fn get_lookup_key_from_locker(
payment_token,
card,
pm,
merchant_key_store,
provider,
)
.await?;
Ok(resp)
}

#[cfg(feature = "v1")]
// Mandates are not supported for platform flows, this function is only for processor-level handling.
pub async fn get_lookup_key_from_locker_for_mandate(
state: &routes::SessionState,
payment_token: &str,
pm: &domain::PaymentMethod,
processor: &domain::Processor,
) -> errors::RouterResult<api::CardDetailFromLocker> {
let card_detail = get_card_details_from_locker(state, pm).await?;
let card = card_detail.clone();

let resp = TempLockerCardSupport::create_payment_method_data_in_temp_locker_for_mandate(
state,
payment_token,
card,
pm,
processor,
)
.await?;
Ok(resp)
Expand Down Expand Up @@ -4929,7 +4950,88 @@ impl TempLockerCardSupport {
payment_token: &str,
card: api::CardDetailFromLocker,
pm: &domain::PaymentMethod,
merchant_key_store: &domain::MerchantKeyStore,
provider: &domain::Provider,
) -> errors::RouterResult<api::CardDetailFromLocker> {
let card_number = card.card_number.clone().get_required_value("card_number")?;
let card_exp_month = card
.expiry_month
.clone()
.expose_option()
.get_required_value("expiry_month")?;
let card_exp_year = card
.expiry_year
.clone()
.expose_option()
.get_required_value("expiry_year")?;
let card_holder_name = card
.card_holder_name
.clone()
.expose_option()
.unwrap_or_default();
let card_network = card.card_network.clone();
let value1 = payment_methods::mk_card_value1(
card_number,
card_exp_year,
card_exp_month,
Some(card_holder_name),
None,
None,
None,
card_network,
)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error getting Value1 for locker")?;
let value2 = payment_methods::mk_card_value2(
None,
None,
None,
Some(pm.customer_id.clone()),
Some(pm.get_id().to_string()),
)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error getting Value2 for locker")?;

let value1 = vault::VaultPaymentMethod::Card(value1);
let value2 = vault::VaultPaymentMethod::Card(value2);

let value1 = value1
.encode_to_string_of_json()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Wrapped value1 construction failed when saving card to locker")?;

let value2 = value2
.encode_to_string_of_json()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Wrapped value2 construction failed when saving card to locker")?;

let lookup_key = vault::create_tokenize(
state,
value1,
Some(value2),
payment_token.to_string(),
provider.get_key_store().key.get_inner(),
)
.await?;
vault::add_delete_tokenized_data_task(
&*state.store,
&lookup_key,
enums::PaymentMethod::Card,
)
.await?;
metrics::TOKENIZED_DATA_COUNT.add(1, &[]);
metrics::TASKS_ADDED_COUNT.add(
1,
router_env::metric_attributes!(("flow", "DeleteTokenizeData")),
);
Ok(card)
}

async fn create_payment_method_data_in_temp_locker_for_mandate(
state: &routes::SessionState,
payment_token: &str,
card: api::CardDetailFromLocker,
pm: &domain::PaymentMethod,
processor: &domain::Processor,
) -> errors::RouterResult<api::CardDetailFromLocker> {
let card_number = card.card_number.clone().get_required_value("card_number")?;
let card_exp_month = card
Expand Down Expand Up @@ -4988,7 +5090,7 @@ impl TempLockerCardSupport {
value1,
Some(value2),
payment_token.to_string(),
merchant_key_store.key.get_inner(),
processor.get_key_store().key.get_inner(),
)
.await?;
vault::add_delete_tokenized_data_task(
Expand Down
32 changes: 1 addition & 31 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use common_utils::{
id_type, pii,
types::{AmountConvertor, MinorUnit, Surcharge},
};
use diesel_models::{ephemeral_key, fraud_check::FraudCheck, refund as diesel_refund};
use diesel_models::{fraud_check::FraudCheck, refund as diesel_refund};
use error_stack::{report, ResultExt};
use events::EventInfo;
use futures::future::join_all;
Expand Down Expand Up @@ -7974,7 +7974,6 @@ where
pub connector_customer_id: Option<String>,
pub recurring_mandate_payment_data:
Option<hyperswitch_domain_models::router_data::RecurringMandatePaymentData>,
pub ephemeral_key: Option<ephemeral_key::EphemeralKey>,
pub redirect_response: Option<api_models::payments::RedirectResponse>,
pub surcharge_details: Option<types::SurchargeDetails>,
pub frm_message: Option<FraudCheck>,
Expand Down Expand Up @@ -11500,7 +11499,6 @@ pub trait OperationSessionGetters<F> {
fn get_token(&self) -> Option<&str>;
fn get_multiple_capture_data(&self) -> Option<&types::MultipleCaptureData>;
fn get_payment_link_data(&self) -> Option<api_models::payments::PaymentLinkResponse>;
fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey>;
fn get_setup_mandate(&self) -> Option<&MandateData>;
fn get_poll_config(&self) -> Option<router_types::PollConfig>;
fn get_authentication(
Expand Down Expand Up @@ -11682,10 +11680,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {
self.payment_link_data.clone()
}

fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
self.ephemeral_key.clone()
}

fn get_setup_mandate(&self) -> Option<&MandateData> {
self.setup_mandate.as_ref()
}
Expand Down Expand Up @@ -12035,10 +12029,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentIntentData<F> {
todo!()
}

fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}

fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
Expand Down Expand Up @@ -12347,10 +12337,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentConfirmData<F> {
todo!()
}

fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}

fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
Expand Down Expand Up @@ -12658,10 +12644,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {
todo!()
}

fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}

fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
Expand Down Expand Up @@ -12965,10 +12947,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentCaptureData<F> {
todo!()
}

fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}

fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
Expand Down Expand Up @@ -13268,10 +13246,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentAttemptListData<F> {
todo!()
}

fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}

fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
Expand Down Expand Up @@ -13439,10 +13413,6 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentCancelData<F> {
todo!()
}

fn get_ephemeral_key(&self) -> Option<ephemeral_key::EphemeralKey> {
todo!()
}

fn get_setup_mandate(&self) -> Option<&MandateData> {
todo!()
}
Expand Down
Loading
Loading