Skip to content

Commit b52685c

Browse files
committed
revert to simple subscription system
1 parent f431c40 commit b52685c

File tree

3 files changed

+38
-48
lines changed

3 files changed

+38
-48
lines changed

layouts/_default/single.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h2 class="text-xl mt-9">{{ .Params.content.title }}</h2>
2626

2727
<div class="flex items-center justify-start gap-3 my-5 flex-wrap">
2828
<a
29-
href="/start-trial?service_id={{ .Params.content.id }}&service_name={{ .Params.content.name }}"
29+
href="/start-trial?service={{ .Params.content.name }}"
3030
class="rounded-md isolate bg-gradient-to-r from-[#ff80b5] to-[#9089fc] px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:opacity-70 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2">
3131
Start Free Trial
3232
</a>

layouts/page/start-trial.html

+35-45
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{{ define "main" }}
2+
<script>
3+
let __plan_name = "Professional";
4+
</script>
25
<div class="isolate px-6 py-24 sm:py-32 lg:px-8">
36
<div class="mx-auto max-w-2xl text-center">
47
<h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
@@ -10,6 +13,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
1013
</div>
1114

1215
<script>
16+
let start_trial_form_submitted = false;
1317
window.onload = function () {
1418
let referralCode = localStorage.getItem("referral-code");
1519

@@ -21,68 +25,55 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
2125
document.getElementById("referral-code").value = referralCode;
2226
}
2327

24-
const serviceId = getQueryParam("service_id");
25-
const serviceName = getQueryParam("service_name");
28+
const serviceName = getQueryParam("service");
2629

27-
if (serviceId && serviceName) {
28-
document.getElementById("service-id").value = serviceId;
30+
if (serviceName) {
2931
document.getElementById("service-name").value = serviceName;
3032
} else {
3133
window.location = "/";
3234
}
3335
};
3436

35-
async function submitForm(form) {
36-
event.preventDefault();
37-
38-
alert("Currently not accepting new accounts, Try after few minutes");
39-
return;
40-
37+
function loading() {
4138
const btn = document.getElementById("submit-btn");
4239

4340
btn.disabled = true;
4441
btn.textContent = "Submitting...";
42+
}
4543

46-
const formData = new FormData(form);
47-
const requestData = Object.fromEntries(formData.entries());
48-
49-
delete requestData.terms_and_conditions;
50-
51-
requestData.plan = requestData.plan.toLowerCase();
44+
function onFormSubmit() {
45+
if (start_trial_form_submitted) {
46+
const plans = {
47+
startup: "https://buy.stripe.com/4gwaF0bWd3nh2AwaEF",
48+
professional: "https://buy.stripe.com/00gaF0gct9LF6QM6oq",
49+
business: "https://buy.stripe.com/cN29AW4tL9LFeje7sv",
50+
enterprise: "https://buy.stripe.com/dR614q2lD9LF0so6os",
51+
};
5252

53-
try {
54-
const response = await fetch(
55-
"https://admin.octabyte.app/items/customer_services",
56-
{
57-
method: "POST",
58-
headers: {
59-
"Content-Type": "application/json",
60-
},
61-
body: JSON.stringify(requestData),
62-
},
63-
);
53+
__plan_name = __plan_name.toLowerCase();
6454

65-
if (!response.ok) {
66-
throw new Error("There was an error submitting the form.");
67-
}
55+
const paymentLink = plans[__plan_name] || plans.professional;
6856

6957
localStorage.removeItem("referral-code");
70-
71-
const data = await response.json();
72-
const session_url = data.data.session_url;
73-
window.location = session_url;
74-
} catch (error) {
75-
alert("There was an error submitting the form.");
58+
window.location = paymentLink;
7659
}
7760
}
7861
</script>
7962

63+
<iframe
64+
name="hidden_iframe"
65+
id="hidden_iframe"
66+
style="display:none;"
67+
onload="onFormSubmit()"></iframe>
68+
8069
<form
70+
action="https://docs.google.com/forms/d/e/1FAIpQLSeaxk4nWWZZw6LvQPPS80PuSOfEC3rmAWPtzOYapioaYguzqQ/formResponse"
8171
method="post"
82-
onsubmit="submitForm(this)"
72+
target="hidden_iframe"
73+
onsubmit="start_trial_form_submitted = true; loading()"
8374
class="mx-auto mt-16 max-w-xl sm:mt-20">
8475
<!-- Referral Code -->
85-
<input id="referral-code" type="hidden" name="referral_code" />
76+
<input id="referral-code" type="hidden" name="entry.1415040235" />
8677

8778
<div class="grid grid-cols-1 gap-x-8 gap-y-6 sm:grid-cols-2">
8879
<div>
@@ -94,7 +85,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
9485
<div class="mt-2.5">
9586
<input
9687
type="text"
97-
name="first_name"
88+
name="entry.973173615"
9889
id="first-name"
9990
autocomplete="given-name"
10091
placeholder="John"
@@ -111,7 +102,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
111102
<div class="mt-2.5">
112103
<input
113104
type="text"
114-
name="last_name"
105+
name="entry.876595051"
115106
id="last-name"
116107
autocomplete="family-name"
117108
placeholder="Smith"
@@ -129,7 +120,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
129120
<div class="mt-2.5">
130121
<input
131122
type="email"
132-
name="admin_email"
123+
name="entry.943957029"
133124
id="email"
134125
autocomplete="email"
135126
placeholder="Please provide valid email address to receive credentials"
@@ -146,7 +137,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
146137
<div class="mt-2.5">
147138
<input
148139
type="tel"
149-
name="phone_number"
140+
name="entry.621899747"
150141
id="phone-number"
151142
autocomplete="tel"
152143
placeholder="+1 (555) 987-6543"
@@ -160,10 +151,9 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
160151
Service Name
161152
</label>
162153
<div class="mt-2.5">
163-
<input type="hidden" id="service-id" name="service_id" />
164154
<input
165155
type="text"
166-
name="service_name"
156+
name="entry.2107164949"
167157
id="service-name"
168158
required
169159
readonly
@@ -194,7 +184,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
194184
<div class="flex h-5 items-center">
195185
<input
196186
id="terms-and-conditions"
197-
name="terms_and_conditions"
187+
name="terms-and-conditions"
198188
type="checkbox"
199189
required
200190
class="h-4 w-4 cursor-pointer rounded border-gray-300 text-indigo-600 focus:ring-indigo-500" />

layouts/partials/trial/machine-type.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<script>
1010
document.addEventListener("DOMContentLoaded", function () {
1111
const radioButtons = document.querySelectorAll(
12-
"input[type='radio'][name='plan']",
12+
"input[type='radio'][name='entry.1848613537']",
1313
);
1414

1515
radioButtons.forEach((radio) => {
@@ -62,7 +62,7 @@
6262
{{ end }}">
6363
<input
6464
type="radio"
65-
name="plan"
65+
name="entry.1848613537"
6666
value="{{ $option.label }}"
6767
class="sr-only"
6868
{{ if eq $index 1 }}checked{{ end }}

0 commit comments

Comments
 (0)