diff --git a/defs/api/accounts/POST/Payload.schema.json b/defs/api/accounts/POST/Payload.schema.json index d1015321..303133c3 100644 --- a/defs/api/accounts/POST/Payload.schema.json +++ b/defs/api/accounts/POST/Payload.schema.json @@ -2,7 +2,6 @@ "type": "object", "required": [ "name", - "payment_method_id", "plan_id" ], "properties": { @@ -27,9 +26,6 @@ "type": "object", "additionalProperties": true, "nullable": true - }, - "payment_method_id": { - "type": "string" } }, "additionalProperties": false diff --git a/defs/api/accounts/POST/Payload.ts b/defs/api/accounts/POST/Payload.ts index 33774c2f..3bd0e703 100644 --- a/defs/api/accounts/POST/Payload.ts +++ b/defs/api/accounts/POST/Payload.ts @@ -7,5 +7,4 @@ export type Payload = { user_id?: string; user_metadata?: Metadata; system_metadata?: Metadata; - payment_method_id: string; }; diff --git a/defs/api/auth/user/register/POST/Payload.schema.json b/defs/api/auth/user/register/POST/Payload.schema.json index fd155476..c1ab8e34 100644 --- a/defs/api/auth/user/register/POST/Payload.schema.json +++ b/defs/api/auth/user/register/POST/Payload.schema.json @@ -8,7 +8,6 @@ "first_name", "last_name", "password", - "payment_method_nonce", "plan_id" ], "properties": { @@ -75,13 +74,6 @@ }, "device_id": { "type": "string" - }, - "payment_method_nonce": { - "type": "string" - }, - "payment_device_data": { - "type": "string", - "nullable": true } }, "additionalProperties": false diff --git a/defs/api/auth/user/register/POST/Payload.ts b/defs/api/auth/user/register/POST/Payload.ts index 3ebea7d4..7809efe5 100644 --- a/defs/api/auth/user/register/POST/Payload.ts +++ b/defs/api/auth/user/register/POST/Payload.ts @@ -16,6 +16,4 @@ export type Payload = { account_system_metadata?: Metadata; email_verification_code: string; device_id: string; - payment_method_nonce: string; - payment_device_data: string | null; }; diff --git a/front/app/src/routes/(root)/(online)/(app)/accounts/create-account/plan/[plan]/+page.svelte b/front/app/src/routes/(root)/(online)/(app)/accounts/create-account/plan/[plan]/+page.svelte index 0850638c..83612cff 100644 --- a/front/app/src/routes/(root)/(online)/(app)/accounts/create-account/plan/[plan]/+page.svelte +++ b/front/app/src/routes/(root)/(online)/(app)/accounts/create-account/plan/[plan]/+page.svelte @@ -15,59 +15,74 @@ import { invalidate_siblings } from "$lib/invalidate"; import { lang, locale } from "$lib/locale"; import { logical_fly } from "$share/transition"; - import PaymentMethodSelector from "$share/braintree/PaymentMethodSelector.svelte"; + // TODO: payments + // import PaymentMethodSelector from "$share/braintree/PaymentMethodSelector.svelte"; import { display_fly_enter } from "$share/display_transitions"; import { VALIDATE_ACCOUNT_NAME_MAX_LEN } from "$server/defs/constants"; let account_name = ""; // let sending_data = false; - let selector: PaymentMethodSelector; - let payment_method_id: string | null = null; + // TODO: payments + // let selector: PaymentMethodSelector; + // let payment_method_id: string | null = null; + // let payment_nonce: string | null = null; // let payment_device_data: string | null = null; // let dropin: Dropin; - let view: "data" | "pay" = "data"; - + // TODO: payments + // let view: "data" | "pay" = "data"; + let view = "data"; + + // TODO: payments + // const send_data = action(async () => { + // view = "pay"; + // }) + // const back_to_data = () => { + // view = "data"; + // } + // let sending_pay = false; + let sending_data = false; + + // TODO: payments + // const send_pay = action(async () => { const send_data = action(async () => { - view = "pay"; - }) - - const back_to_data = () => { - view = "data"; - } - - let sending_pay = false; - - const send_pay = action(async () => { - - if (sending_pay) return; - sending_pay = true; + // TODO: payments + // if (sending_pay) return; + // sending_pay = true; + if (sending_data) return; + sending_data = true; try { - try { - payment_method_id = await selector.requestMethodId(); - } catch(e) { - sending_pay = false; - // we dont log a notifier message here as it automatically shows the error in the UI - return; - } + // TODO: payments + // try { + // payment_method_id = await selector.requestMethodId(); + // } catch(e) { + // sending_pay = false; + // // we dont log a notifier message here as it automatically shows the error in the UI + // return; + // } const payload: import("$api/accounts/POST/Payload").Payload = { plan_id: data.plan._id, - payment_method_id, + // TODO: payments + // payment_method_id, name: account_name, }; const { account } = await _post("/api/accounts", payload); - sending_pay = false; + // TODO: payments + // sending_pay = false; + sending_data = false; goto(`/accounts/${account._id}`, { invalidateAll: true }); invalidate_siblings(); } catch (e) { - sending_pay = false; + // TODO: payments + // sending_pay = false; + sending_data = false; throw e; } }) @@ -116,9 +131,11 @@ padding: 0 1.5rem; } + /* TODO: payments .view-pay h2 { margin-bottom: 1rem; } + */ .org-explain { color: #999; @@ -184,6 +201,7 @@ background: rgba(0,0,0,0.05); } + /* TODO: payments .back-to { margin-top: 1rem; font-size: 0.9rem; @@ -198,7 +216,7 @@ min-height: 10rem; padding: 0 2.5rem; width: 100%; - } + } */ @@ -290,7 +308,8 @@ - + + <-- -> - + --> \ No newline at end of file diff --git a/front/app/src/routes/(root)/(online)/(app)/accounts/create-account/plan/[plan]/page-with-payments.svelte.txt b/front/app/src/routes/(root)/(online)/(app)/accounts/create-account/plan/[plan]/page-with-payments.svelte.txt new file mode 100644 index 00000000..0850638c --- /dev/null +++ b/front/app/src/routes/(root)/(online)/(app)/accounts/create-account/plan/[plan]/page-with-payments.svelte.txt @@ -0,0 +1,324 @@ + + + + + + {$locale.pages["accounts/create_account/plan"].head.title} + + +
+ +
\ No newline at end of file diff --git a/front/app/src/routes/(root)/(online)/(login)/register/plan/[plan]/+page.svelte b/front/app/src/routes/(root)/(online)/(login)/register/plan/[plan]/+page.svelte index a140fd08..e157af01 100644 --- a/front/app/src/routes/(root)/(online)/(login)/register/plan/[plan]/+page.svelte +++ b/front/app/src/routes/(root)/(online)/(login)/register/plan/[plan]/+page.svelte @@ -1,17 +1,17 @@ + + + + + {$locale.pages.register.head.title} + + + diff --git a/openapi.json b/openapi.json index e7f15c2b..7268759a 100644 --- a/openapi.json +++ b/openapi.json @@ -415,7 +415,6 @@ "type": "object", "required": [ "name", - "payment_method_id", "plan_id" ], "properties": { @@ -440,9 +439,6 @@ "type": "object", "additionalProperties": true, "nullable": true - }, - "payment_method_id": { - "type": "string" } }, "additionalProperties": false @@ -6212,7 +6208,6 @@ "first_name", "last_name", "password", - "payment_method_nonce", "plan_id" ], "properties": { @@ -6279,13 +6274,6 @@ }, "device_id": { "type": "string" - }, - "payment_method_nonce": { - "type": "string" - }, - "payment_device_data": { - "type": "string", - "nullable": true } }, "additionalProperties": false diff --git a/openstream-screenshot.png b/openstream-screenshot.png index 4af90a53..33f841a6 100644 Binary files a/openstream-screenshot.png and b/openstream-screenshot.png differ diff --git a/rs/packages/api/src/routes/accounts/mod.rs b/rs/packages/api/src/routes/accounts/mod.rs index d69fa454..8370cf9a 100644 --- a/rs/packages/api/src/routes/accounts/mod.rs +++ b/rs/packages/api/src/routes/accounts/mod.rs @@ -160,10 +160,12 @@ pub mod post { use constants::validate::*; use db::account::{Limit, Limits}; use db::models::user_account_relation::UserAccountRelationKind; - use db::payment_method::PaymentMethod; + // TODO: payments + // use db::payment_method::PaymentMethod; + // use db::current_filter_doc; use db::plan::Plan; + use db::run_transaction; use db::user::User; - use db::{current_filter_doc, run_transaction}; use modify::Modify; use schemars::JsonSchema; use serde_util::DateTime; @@ -194,7 +196,8 @@ pub mod post { pub user_metadata: Option, #[serde(skip_serializing_if = "Option::is_none")] pub system_metadata: Option, - pub payment_method_id: String, + // TODO: payments + // pub payment_method_id: String, } #[derive(Debug, Clone)] @@ -294,7 +297,8 @@ pub mod post { user_id, user_metadata, system_metadata, - payment_method_id, + // TODO: payments + // payment_method_id, } = payload; let name = name.trim().to_string(); @@ -357,7 +361,9 @@ pub mod post { let account = Account { id: Account::uid(), plan_id, - payment_method_id: Some(payment_method_id.clone()), + // TODO: payments + // payment_method_id: Some(payment_method_id.clone()), + payment_method_id: None, name, limits, system_metadata, @@ -380,13 +386,14 @@ pub mod post { if !tx_try!(User::exists_with_session(filter, &mut session).await) { return Err(HandleError::UserNotFound(user_id.clone())); } - { - let filter = current_filter_doc!{ PaymentMethod::KEY_ID: &payment_method_id, PaymentMethod::KEY_USER_ID: &user_id }; - let exists = tx_try!(PaymentMethod::exists_with_session(filter, &mut session).await); - if !exists { - return Err(HandleError::PaymentMethodNotFound(payment_method_id.clone())); - } - } + // TODO: payments + // { + // let filter = current_filter_doc!{ PaymentMethod::KEY_ID: &payment_method_id, PaymentMethod::KEY_USER_ID: &user_id }; + // let exists = tx_try!(PaymentMethod::exists_with_session(filter, &mut session).await); + // if !exists { + // return Err(HandleError::PaymentMethodNotFound(payment_method_id.clone())); + // } + // } tx_try!(Account::insert_with_session(&account, &mut session).await); tx_try!(UserAccountRelation::insert_with_session(&relation, &mut session).await); diff --git a/rs/packages/api/src/routes/auth/user/register.rs b/rs/packages/api/src/routes/auth/user/register.rs index d4e6d2b9..efdee4a2 100644 --- a/rs/packages/api/src/routes/auth/user/register.rs +++ b/rs/packages/api/src/routes/auth/user/register.rs @@ -7,14 +7,15 @@ pub mod post { use db::account::{Account, Limit, Limits, PublicAccount}; use db::email_verification_code::EmailVerificationCode; use db::metadata::Metadata; - use db::payment_method::{PaymentMethod, PaymentMethodKind}; + // TODO: payments + // use db::payment_method::{PaymentMethod, PaymentMethodKind}; + // use payments::query::save_payment_method::SavePaymentMethodResponse; use db::plan::Plan; use db::user::{PublicUser, User}; use db::user_account_relation::{UserAccountRelation, UserAccountRelationKind}; use db::{run_transaction, Model}; use modify::Modify; use mongodb::bson::doc; - use payments::query::save_payment_method::SavePaymentMethodResponse; use prex::{request::ReadBodyJsonError, Request}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -250,10 +251,9 @@ pub mod post { email_verification_code: String, device_id: String, - - payment_method_nonce: String, - - payment_device_data: Option, + // TODO: payments + // payment_method_nonce: String, + // payment_device_data: Option, } #[derive(Debug, Clone)] @@ -322,8 +322,9 @@ pub mod post { user_system_metadata, email_verification_code, device_id, - payment_method_nonce, - payment_device_data, + // TODO: payments + // payment_method_nonce, + // payment_device_data, } = payload; if !AccessToken::is_device_id_valid(&device_id) { @@ -451,42 +452,41 @@ pub mod post { let user_id = User::uid(); - let customer_id = { - let query = payments::query::ensure_customer::EnsureCustomer { - customer_id: user_id.clone(), - first_name: first_name.clone(), - last_name: last_name.clone(), - email: email.clone(), - }; - - let res = self - .payments_client - .perform(query) - .await - .map_err(HandleError::PaymentsEnsureCustomer)?; - - res.customer_id - }; - - let payment_method_response = { - let query = payments::query::save_payment_method::SavePaymentMethod { - customer_id, - payment_method_nonce, - device_data: payment_device_data, - }; - - let payment_method_response = self - .payments_client - .perform(query) - .await - .map_err(HandleError::PaymentSavePaymentMethod)?; - - #[allow(clippy::let_and_return)] - payment_method_response - }; - - let payment_method_id = PaymentMethod::uid(); - // log::info!("payment method created: {payment_method:?}"); + // TODO: payments + // let customer_id = { + // let query = payments::query::ensure_customer::EnsureCustomer { + // customer_id: user_id.clone(), + // first_name: first_name.clone(), + // last_name: last_name.clone(), + // email: email.clone(), + // }; + + // let res = self + // .payments_client + // .perform(query) + // .await + // .map_err(HandleError::PaymentsEnsureCustomer)?; + + // res.customer_id + // }; + + // let payment_method_response = { + // let query = payments::query::save_payment_method::SavePaymentMethod { + // customer_id, + // payment_method_nonce, + // device_data: payment_device_data, + // }; + + // let payment_method_response = self + // .payments_client + // .perform(query) + // .await + // .map_err(HandleError::PaymentSavePaymentMethod)?; + + // #[allow(clippy::let_and_return)] + // payment_method_response + // }; + // let payment_method_id = PaymentMethod::uid(); let password = crypt::hash(password); @@ -529,7 +529,9 @@ pub mod post { let account = Account { id: Account::uid(), plan_id, - payment_method_id: Some(payment_method_id.clone()), + // TODO: payments + // payment_method_id: Some(payment_method_id.clone()), + payment_method_id: None, limits, name: account_name, user_metadata: account_user_metadata, @@ -568,30 +570,31 @@ pub mod post { deleted_at: None, }; - let payment_method = { - let SavePaymentMethodResponse { - payment_method_token, - card_type, - last_4, - expiration_month, - expiration_year, - } = payment_method_response; - - PaymentMethod { - id: payment_method_id, - user_id, - kind: PaymentMethodKind::Card { - token: payment_method_token, - card_type, - last_4, - expiration_month, - expiration_year, - }, - created_at: now, - updated_at: now, - deleted_at: None, - } - }; + // TODO: payments + // let payment_method = { + // let SavePaymentMethodResponse { + // payment_method_token, + // card_type, + // last_4, + // expiration_month, + // expiration_year, + // } = payment_method_response; + + // PaymentMethod { + // id: payment_method_id, + // user_id, + // kind: PaymentMethodKind::Card { + // token: payment_method_token, + // card_type, + // last_4, + // expiration_month, + // expiration_year, + // }, + // created_at: now, + // updated_at: now, + // deleted_at: None, + // } + // }; run_transaction!(session => { let email_exists = tx_try!(User::email_exists_with_session(user.email.as_str(), &mut session).await); @@ -603,7 +606,8 @@ pub mod post { tx_try!(Account::insert_with_session(&account, &mut session).await); tx_try!(UserAccountRelation::insert_with_session(&relation, &mut session).await); tx_try!(AccessToken::insert_with_session(&token, &mut session).await); - tx_try!(PaymentMethod::insert_with_session(&payment_method, &mut session).await); + // TODO: payments + // tx_try!(PaymentMethod::insert_with_session(&payment_method, &mut session).await); tx_try!(EmailVerificationCode::update_by_id_with_session(&verification_code_document.id, doc! { "$set": { EmailVerificationCode::KEY_USED_AT: now } }, &mut session).await) });