Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: separate DB queries and HTML creation for payout links #4967

Merged
merged 101 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
b23edb3
feat(collect_link): basic setup for collect_links - app structs / enu…
kashif-m Apr 18, 2024
cc48b06
wip: feat(collect_link): add render pm collect link flow
kashif-m Apr 21, 2024
dcfa4bb
feat(collect_link): add basic initiate + status + expiry templates
kashif-m Apr 22, 2024
58e5e78
feat(collect_link): store pm_collect_link_config in merchant account
kashif-m Apr 23, 2024
89277ce
refactor(collect_link): cargo hack fixes
kashif-m Apr 23, 2024
843c2c8
feat(collect_link): inject enabled_payment_methods
kashif-m Apr 30, 2024
a2daf17
Merge remote-tracking branch 'origin/main' into pm_collect_link
kashif-m Apr 30, 2024
97b40ed
refactor(collect_link): update styles
kashif-m May 2, 2024
7cc75ac
Merge remote-tracking branch 'origin/main' into pm_collect_link
kashif-m May 2, 2024
7057338
feat(collect_link): add widget options
kashif-m May 6, 2024
5bafcd1
feat(payment_methods): enable client secret auth for CREATE payment_m…
kashif-m May 8, 2024
e0f7fac
feat(collect_link): read enabled_payment_methods in /admin and collec…
kashif-m May 9, 2024
f02b526
Merge remote-tracking branch 'origin/main' into pm_collect_link
kashif-m May 23, 2024
6ce91c5
Merge remote-tracking branch 'origin/main' into pm_collect_link
kashif-m May 23, 2024
3913d46
add payout link support
srujanchikke Jun 3, 2024
84ab2d9
add confirm api
srujanchikke Jun 6, 2024
7411a56
remove comments
srujanchikke Jun 6, 2024
3bdffff
Merge remote-tracking branch 'origin/main' into pm_collect_link
kashif-m Jun 7, 2024
85da820
add slash to payout_link scope
Jun 10, 2024
51e7ad7
Merge branch 'pm_collect_link' of https://github.com/juspay/hyperswit…
srujanchikke Jun 10, 2024
acea448
Merge branch 'payout_link' of https://github.com/juspay/hyperswitch i…
srujanchikke Jun 10, 2024
ab5d140
resolve merge conflicts
srujanchikke Jun 11, 2024
8d1e34e
chore: run formatter
hyperswitch-bot[bot] Jun 11, 2024
f7a341a
Merge remote-tracking branch 'origin/main' into pm_collect_link
kashif-m Jun 11, 2024
26c9ecf
remove schema.rs
srujanchikke Jun 11, 2024
1dee131
Merge branch 'payout_link' of https://github.com/juspay/hyperswitch i…
srujanchikke Jun 11, 2024
38f94e8
resolve schema.rs file conflict
srujanchikke Jun 11, 2024
cf25247
refactor: add openapi changes
kashif-m Jun 11, 2024
7cec5c0
chore: run formatter
hyperswitch-bot[bot] Jun 11, 2024
f6cfde2
merge branch
srujanchikke Jun 11, 2024
3c9a3a2
clippy fix
srujanchikke Jun 11, 2024
6be0325
fix validate openapi spec
srujanchikke Jun 11, 2024
85e64dd
clippy fix
srujanchikke Jun 11, 2024
3791ebb
chore: run formatter
hyperswitch-bot[bot] Jun 11, 2024
cc0b09d
fix schema
srujanchikke Jun 12, 2024
762a24b
refactor: separate DB queries and HTML creation for payout links
kashif-m Jun 12, 2024
691082e
add enabled payout method in payout_link
srujanchikke Jun 13, 2024
52d8dd8
fix enabled payment methods
srujanchikke Jun 13, 2024
acbea09
make enabled payment methods optional for payout links
srujanchikke Jun 13, 2024
8b28952
chore: run formatter
hyperswitch-bot[bot] Jun 13, 2024
f7e52ea
open api check fix
srujanchikke Jun 13, 2024
9c9a3c6
open api fix
srujanchikke Jun 13, 2024
e5dc100
refactor: separate queries for payout links
kashif-m Jun 13, 2024
02c2763
openapi fix
srujanchikke Jun 13, 2024
f5b7cbf
ci check fix
srujanchikke Jun 13, 2024
dcb32db
chore: run formatter
hyperswitch-bot[bot] Jun 13, 2024
5d09e85
feat(payout_link): add expired and status pages
kashif-m Jun 13, 2024
073a5ce
Merge remote-tracking branch 'origin/main' into payout_link_ref
kashif-m Jun 13, 2024
d1507c7
ci check fix
srujanchikke Jun 14, 2024
ead64a9
Merge branch 'payout_link' of github.com:juspay/hyperswitch into payo…
srujanchikke Jun 14, 2024
6e0d116
chore: run formatter
hyperswitch-bot[bot] Jun 14, 2024
13e011b
minor refactor
srujanchikke Jun 14, 2024
b616451
Merge branch 'payout_link' of github.com:juspay/hyperswitch into payo…
srujanchikke Jun 14, 2024
cb10520
refactor: cargo fix
kashif-m Jun 14, 2024
eef38fa
Merge remote-tracking branch 'origin/payout_link' into payout_link_ref
kashif-m Jun 14, 2024
bc1dd6d
chore: run formatter
hyperswitch-bot[bot] Jun 14, 2024
571824b
refactor: re-generate openAPI spec
kashif-m Jun 14, 2024
3d9f1ad
Merge branch 'main' into pm_collect_link
kashif-m Jun 19, 2024
1d8af46
Merge branch 'pm_collect_link' into payout_link
kashif-m Jun 19, 2024
fd7c412
Merge remote-tracking branch 'origin/payout_link' into payout_link_ref
kashif-m Jun 19, 2024
4e06034
resolve comments
srujanchikke Jun 19, 2024
b218946
chore: run formatter
hyperswitch-bot[bot] Jun 19, 2024
0b0dfd1
refactor(generic_links): move payout_link_config to business_profile
kashif-m Jun 19, 2024
aabf12b
refactor: inject flow type for pm_collect_link
kashif-m Jun 19, 2024
d668130
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jun 19, 2024
4e5ac76
resolve comments
Jun 20, 2024
a41ee95
remove unnecessary logs
Jun 20, 2024
026ad06
chore: run formatter
hyperswitch-bot[bot] Jun 20, 2024
b9dcceb
clippy fix
Jun 20, 2024
00bc65e
refactor(payout_links): map domain name to the payout link and add a …
kashif-m Jun 21, 2024
2ee89eb
Merge remote-tracking branch 'origin/main' into payout_link_ref
kashif-m Jun 23, 2024
a939970
refactor: missing import
kashif-m Jun 23, 2024
b889d33
refactor: clippy fix
kashif-m Jun 23, 2024
9c7258e
update payouts in confirm
Jun 24, 2024
982d4b5
chore: run formatter
hyperswitch-bot[bot] Jun 24, 2024
0eb0136
update payout_type in PayoutUpdate
Jun 24, 2024
e958839
refactor: revert client_secret auth in POST /payment_methods
kashif-m Jun 24, 2024
de2434a
Merge remote-tracking branch 'origin/main' into pm_collect_link
kashif-m Jun 24, 2024
ba9880d
refactor: missing import
kashif-m Jun 24, 2024
f3f1bfc
Merge remote-tracking branch 'origin/pm_collect_link' into payout_link
kashif-m Jun 24, 2024
a285679
Merge remote-tracking branch 'origin/payout_link' into payout_link_ref
kashif-m Jun 24, 2024
2c62a96
refactor: clippy fixes
kashif-m Jun 24, 2024
4717b07
Merge remote-tracking branch 'origin/pm_collect_link' into payout_link
kashif-m Jun 24, 2024
8bc98ef
refactor: revert payouts insert query
kashif-m Jun 24, 2024
e3da8fc
refactor: add default env configs in docker_compose.toml and update m…
kashif-m Jun 24, 2024
ce0f155
feat: attach payout_id to Payout events
kashif-m Jun 24, 2024
4c5496b
Merge remote-tracking branch 'origin/main' into pm_collect_link
kashif-m Jun 24, 2024
1797a83
Merge remote-tracking branch 'origin/main' into payout_link_ref
kashif-m Jun 24, 2024
6a47a27
clippy fix
Jun 24, 2024
d0543e7
Merge branch 'pm_collect_link' into payout_link
srujanchikke Jun 24, 2024
d301039
refactor: resolve comments
kashif-m Jun 24, 2024
e62b354
Merge remote-tracking branch 'origin/payout_link' into payout_link_ref
kashif-m Jun 24, 2024
1602734
refactor: clippy fixes
kashif-m Jun 24, 2024
baca310
refactor: clippy fixes
kashif-m Jun 24, 2024
21ebf13
refactor: resolve comments
kashif-m Jun 25, 2024
5a65b3d
refactor: migration update
kashif-m Jun 25, 2024
6c35e7e
refactor: add comments
kashif-m Jun 25, 2024
cedb025
chore: missing validations
kashif-m Jun 25, 2024
91c269b
refactor: update generic link_status
kashif-m Jun 25, 2024
6a34bb7
chore: comments
kashif-m Jun 25, 2024
d99c3f7
chore: updated env configs
kashif-m Jun 25, 2024
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
Prev Previous commit
Next Next commit
resolve merge conflicts
  • Loading branch information
srujanchikke committed Jun 11, 2024
commit ab5d14013e6f9ebc9a9cd793fea70bc920471a56
3 changes: 1 addition & 2 deletions crates/api_models/src/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use masking::Secret;
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use utoipa::ToSchema;

use crate::{enums as api_enums, payments};

#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
Expand Down Expand Up @@ -712,7 +711,7 @@ pub struct PayoutLinkDetails {
pub pub_key: Secret<String>,
pub client_secret: Secret<String>,
pub payout_link_id: String,
pub customer_id: String,
pub customer_id: id_type::CustomerId,
#[serde(with = "common_utils::custom_serde::iso8601")]
pub session_expiry: PrimitiveDateTime,
pub return_url: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Expand Down
10 changes: 5 additions & 5 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,11 +813,11 @@ diesel::table! {
#[max_length = 64]
payment_method_billing_address_id -> Nullable<Varchar>,
#[max_length = 64]
charge_id -> Nullable<Varchar>,
#[max_length = 64]
client_source -> Nullable<Varchar>,
#[max_length = 64]
client_version -> Nullable<Varchar>,
#[max_length = 64]
charge_id -> Nullable<Varchar>,
}
}

Expand Down Expand Up @@ -886,8 +886,8 @@ diesel::table! {
#[max_length = 64]
fingerprint_id -> Nullable<Varchar>,
request_external_three_ds_authentication -> Nullable<Bool>,
charges -> Nullable<Jsonb>,
frm_metadata -> Nullable<Jsonb>,
charges -> Nullable<Jsonb>,
}
}

Expand Down Expand Up @@ -1049,12 +1049,12 @@ diesel::table! {
profile_id -> Varchar,
status -> PayoutStatus,
confirm -> Nullable<Bool>,
#[max_length = 32]
priority -> Nullable<Varchar>,
#[max_length = 255]
payout_link_id -> Nullable<Varchar>,
#[max_length = 128]
client_secret -> Nullable<Varchar>,
#[max_length = 32]
priority -> Nullable<Varchar>,
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/router/src/compatibility/stripe/webhooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ impl From<common_enums::PayoutStatus> for StripePayoutStatus {
| common_enums::PayoutStatus::RequiresCreation
| common_enums::PayoutStatus::RequiresFulfillment
| common_enums::PayoutStatus::RequiresPayoutMethodData
| common_enums::PayoutStatus::RequiresVendorAccountCreation => Self::PayoutProcessing,
| common_enums::PayoutStatus::RequiresVendorAccountCreation
| common_enums::PayoutStatus::RequiresConfirmation => Self::PayoutProcessing,
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions crates/router/src/core/payout_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ use diesel_models::enums;

use crate::{
errors,
routes::{app::StorageInterface, AppState},
routes::{app::StorageInterface, SessionState},
services::{self, GenericLinks},
types::domain,
};
use error_stack::ResultExt;
use common_utils::id_type::CustomerId;

use super::errors::{RouterResponse, StorageErrorExt};

pub async fn initiate_payout_link(
state: AppState,
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: api_models::payouts::PayoutLinkInitiateRequest,
Expand Down Expand Up @@ -61,10 +62,15 @@ pub async fn initiate_payout_link(

// else, send back form link
} else {
let customer_id =
CustomerId::from(payout_link.primary_reference.clone().into())
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "customer_id",
})?;
// Fetch customer
let customer = db
.find_customer_by_customer_id_merchant_id(
&payout_link.primary_reference,
&customer_id,
&req.merchant_id,
&key_store,
merchant_account.storage_scheme,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ pub async fn payouts_create_core(

#[instrument(skip_all)]
pub async fn payouts_confirm_core(
state: AppState,
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
req: payouts::PayoutCreateRequest,
Expand Down
9 changes: 5 additions & 4 deletions crates/router/src/core/payouts/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use api_models::admin;
#[cfg(feature = "olap")]
use common_utils::errors::CustomResult;
use common_utils::ext_traits::ValueExt;
use common_utils::id_type::CustomerId;
use diesel_models::{enums::CollectLinkConfig, generic_link::PaymentMethodCollectLinkData};
use error_stack::{report, ResultExt};
pub use hyperswitch_domain_models::errors::StorageError;
Expand Down Expand Up @@ -185,10 +186,10 @@ pub(super) fn validate_payout_list_request_for_joins(
}

pub async fn create_payout_link(
state: &AppState,
state: &SessionState,
merchant_account: &domain::MerchantAccount,
req: &api_models::payouts::PayoutCreatePayoutLinkConfig,
customer_id: &String,
customer_id: &CustomerId,
return_url: Option<String>,
payout_id: &String,
) -> RouterResult<Option<PaymentMethodCollectLinkData>> {
Expand Down Expand Up @@ -231,7 +232,7 @@ pub async fn create_payout_link(
let domain = merchant_config
.clone()
.and_then(|c| c.domain_name.clone())
.unwrap_or_else(|| state.conf.server.base_url.clone());
.unwrap_or_else(|| state.base_url.clone());

let (collector_name, logo, theme) = match ui_config {
Some(config) => (
Expand Down Expand Up @@ -267,7 +268,7 @@ pub async fn create_payout_link(

let data = PaymentMethodCollectLinkData {
pm_collect_link_id: payout_link_id.clone(),
customer_id: customer_id.to_string(),
customer_id: customer_id.clone(),
link,
sdk_host,
client_secret: Secret::new(client_secret),
Expand Down
3 changes: 2 additions & 1 deletion crates/router/src/types/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ impl ForeignFrom<storage_enums::PayoutStatus> for Option<storage_enums::EventTyp
| storage_enums::PayoutStatus::RequiresCreation
| storage_enums::PayoutStatus::RequiresFulfillment
| storage_enums::PayoutStatus::RequiresPayoutMethodData
| storage_enums::PayoutStatus::RequiresVendorAccountCreation => None,
| storage_enums::PayoutStatus::RequiresVendorAccountCreation
| storage_enums::PayoutStatus::RequiresConfirmation => None,
}
}
}
Expand Down
Loading