Skip to content

Commit 6ae6679

Browse files
committed
add new stripe system
1 parent 95a6fe5 commit 6ae6679

File tree

2 files changed

+47
-41
lines changed

2 files changed

+47
-41
lines changed

layouts/page/start-trial.html

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
{{ define "head" }}
2-
<meta name="robots" content="noindex, nofollow" />
3-
{{ end }}
4-
51
{{ define "main" }}
6-
<script>
7-
let __plan_name = "Professional";
8-
</script>
92
<div class="isolate px-6 py-24 sm:py-32 lg:px-8">
103
<div class="mx-auto max-w-2xl text-center">
114
<h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
@@ -17,7 +10,6 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
1710
</div>
1811

1912
<script>
20-
let start_trial_form_submitted = false;
2113
window.onload = function () {
2214
let referralCode = localStorage.getItem("referral-code");
2315

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

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

34-
if (serviceName) {
27+
if (serviceId && serviceName) {
28+
document.getElementById("service-id").value = serviceId;
3529
document.getElementById("service-name").value = serviceName;
3630
} else {
3731
window.location = "/";
3832
}
3933
};
4034

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

4443
btn.disabled = true;
4544
btn.textContent = "Submitting...";
46-
}
4745

48-
function onFormSubmit() {
49-
if (start_trial_form_submitted) {
50-
const plans = {
51-
startup: "https://buy.stripe.com/4gwaF0bWd3nh2AwaEF",
52-
professional: "https://buy.stripe.com/00gaF0gct9LF6QM6oq",
53-
business: "https://buy.stripe.com/cN29AW4tL9LFeje7sv",
54-
enterprise: "https://buy.stripe.com/dR614q2lD9LF0so6os",
55-
};
46+
const formData = new FormData(form);
47+
const requestData = Object.fromEntries(formData.entries());
5648

57-
__plan_name = __plan_name.toLowerCase();
49+
delete requestData.terms_and_conditions;
5850

59-
const paymentLink = plans[__plan_name] || plans.professional;
51+
requestData.plan = requestData.plan.toLowerCase();
52+
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+
);
64+
65+
if (!response.ok) {
66+
throw new Error("There was an error submitting the form.");
67+
}
6068

6169
localStorage.removeItem("referral-code");
62-
window.location = paymentLink;
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.");
6376
}
6477
}
6578
</script>
6679

67-
<iframe
68-
name="hidden_iframe"
69-
id="hidden_iframe"
70-
style="display:none;"
71-
onload="onFormSubmit()"></iframe>
72-
7380
<form
74-
action="https://docs.google.com/forms/d/e/1FAIpQLSeaxk4nWWZZw6LvQPPS80PuSOfEC3rmAWPtzOYapioaYguzqQ/formResponse"
7581
method="post"
76-
target="hidden_iframe"
77-
onsubmit="start_trial_form_submitted = true; loading()"
82+
onsubmit="submitForm(this)"
7883
class="mx-auto mt-16 max-w-xl sm:mt-20">
7984
<!-- Referral Code -->
80-
<input id="referral-code" type="hidden" name="entry.1415040235" />
85+
<input id="referral-code" type="hidden" name="referral_code" />
8186

8287
<div class="grid grid-cols-1 gap-x-8 gap-y-6 sm:grid-cols-2">
8388
<div>
@@ -89,7 +94,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
8994
<div class="mt-2.5">
9095
<input
9196
type="text"
92-
name="entry.973173615"
97+
name="first_name"
9398
id="first-name"
9499
autocomplete="given-name"
95100
placeholder="John"
@@ -106,7 +111,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
106111
<div class="mt-2.5">
107112
<input
108113
type="text"
109-
name="entry.876595051"
114+
name="last_name"
110115
id="last-name"
111116
autocomplete="family-name"
112117
placeholder="Smith"
@@ -124,7 +129,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
124129
<div class="mt-2.5">
125130
<input
126131
type="email"
127-
name="entry.943957029"
132+
name="admin_email"
128133
id="email"
129134
autocomplete="email"
130135
placeholder="Please provide valid email address to receive credentials"
@@ -141,7 +146,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
141146
<div class="mt-2.5">
142147
<input
143148
type="tel"
144-
name="entry.621899747"
149+
name="phone_number"
145150
id="phone-number"
146151
autocomplete="tel"
147152
placeholder="+1 (555) 987-6543"
@@ -155,9 +160,10 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
155160
Service Name
156161
</label>
157162
<div class="mt-2.5">
163+
<input type="hidden" id="service-id" name="service_id" />
158164
<input
159165
type="text"
160-
name="entry.2107164949"
166+
name="service_name"
161167
id="service-name"
162168
required
163169
readonly
@@ -188,7 +194,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
188194
<div class="flex h-5 items-center">
189195
<input
190196
id="terms-and-conditions"
191-
name="terms-and-conditions"
197+
name="terms_and_conditions"
192198
type="checkbox"
193199
required
194200
class="h-4 w-4 cursor-pointer rounded border-gray-300 text-indigo-600 focus:ring-indigo-500" />

layouts/partials/trial/machine-type.html

Lines changed: 2 additions & 2 deletions
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='entry.1848613537']",
12+
"input[type='radio'][name='plan']",
1313
);
1414

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

0 commit comments

Comments
 (0)