Skip to content

Commit

Permalink
feat: temporarily remove payments management (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen authored Jan 20, 2024
2 parents facf6d8 + 020fdfd commit b5645f0
Show file tree
Hide file tree
Showing 12 changed files with 1,137 additions and 235 deletions.
4 changes: 0 additions & 4 deletions defs/api/accounts/POST/Payload.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"type": "object",
"required": [
"name",
"payment_method_id",
"plan_id"
],
"properties": {
Expand All @@ -27,9 +26,6 @@
"type": "object",
"additionalProperties": true,
"nullable": true
},
"payment_method_id": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
1 change: 0 additions & 1 deletion defs/api/accounts/POST/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export type Payload = {
user_id?: string;
user_metadata?: Metadata;
system_metadata?: Metadata;
payment_method_id: string;
};
8 changes: 0 additions & 8 deletions defs/api/auth/user/register/POST/Payload.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"first_name",
"last_name",
"password",
"payment_method_nonce",
"plan_id"
],
"properties": {
Expand Down Expand Up @@ -75,13 +74,6 @@
},
"device_id": {
"type": "string"
},
"payment_method_nonce": {
"type": "string"
},
"payment_device_data": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
Expand Down
2 changes: 0 additions & 2 deletions defs/api/auth/user/register/POST/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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<import("$api/accounts/POST/Output").Output>("/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;
}
})
Expand Down Expand Up @@ -116,9 +131,11 @@
padding: 0 1.5rem;
}
/* TODO: payments
.view-pay h2 {
margin-bottom: 1rem;
}
*/
.org-explain {
color: #999;
Expand Down Expand Up @@ -184,6 +201,7 @@
background: rgba(0,0,0,0.05);
}
/* TODO: payments
.back-to {
margin-top: 1rem;
font-size: 0.9rem;
Expand All @@ -198,7 +216,7 @@
min-height: 10rem;
padding: 0 2.5rem;
width: 100%;
}
} */
</style>

<svelte:head>
Expand Down Expand Up @@ -290,7 +308,8 @@
</form>
</Formy>

<Formy action={send_pay} let:submit>
<!-- TODO: payments
<Formy action={send_pay} let:submit>
<form
novalidate
class="view view-pay"
Expand All @@ -308,7 +327,7 @@
bind:saved_methods={data.payment_methods.items}
bind:this={selector}
/>
<!--<Dropin authorization="sandbox_d58xyrp3_xbw6cq92jcgfmzdh" bind:this={dropin} />-->
<-- <Dropin authorization="sandbox_d58xyrp3_xbw6cq92jcgfmzdh" bind:this={dropin} /> ->
</div>
<button class="back-to" on:click|preventDefault={() => back_to_data()}>
Expand All @@ -319,6 +338,6 @@
{$locale.pages["accounts/create_account/plan"].form.submit}
</button>
</form>
</Formy>
</Formy> -->
</div>
</div>
Loading

0 comments on commit b5645f0

Please sign in to comment.