mirror of
https://github.com/tavo-wasd-gh/conex-builder.git
synced 2025-06-06 11:43:29 -06:00
extend
This commit is contained in:
parent
1f41012621
commit
1826592828
4 changed files with 70 additions and 2 deletions
|
@ -124,6 +124,11 @@
|
||||||
<br>
|
<br>
|
||||||
<h2 data-translate="extendServiceDialogHeader"></h2>
|
<h2 data-translate="extendServiceDialogHeader"></h2>
|
||||||
<p data-translate="extendServiceDialogParagraph"></p>
|
<p data-translate="extendServiceDialogParagraph"></p>
|
||||||
|
<p data-translate="checkoutTermsAndPrivacyNotice"></p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/terminos.txt">Términos y condiciones</a></li>
|
||||||
|
<li><a href="/privacidad.txt">Política de Privacidad</a></li>
|
||||||
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
<div class="message neutral-message" id="checkdir-duedate"></div>
|
<div class="message neutral-message" id="checkdir-duedate"></div>
|
||||||
<div class="message success-message" id="checkout-extended-success-message"></div>
|
<div class="message success-message" id="checkout-extended-success-message"></div>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
"checkoutSaveNotif": "¡El progreso se guardó con éxito!",
|
"checkoutSaveNotif": "¡El progreso se guardó con éxito!",
|
||||||
"checkoutHeader": "Contratar por $20 al año",
|
"checkoutHeader": "Contratar por $20 al año",
|
||||||
"checkoutParagraph": "Gracias por elegir nuestro servicio para la compra de sitios web. Luego de ser aprobado, su sitio será publicado en menos de 24 horas a partir de la confirmación de tu compra. Utilizaremos los medios de contacto que proporcione para comunicarnos en caso de cualquier inconveniente con la publicación. Si experimenta algún problema, no dude en ponerte en contacto con nosotros a través de los canales:",
|
"checkoutParagraph": "Gracias por elegir nuestro servicio para la compra de sitios web. Luego de ser aprobado, su sitio será publicado en menos de 24 horas a partir de la confirmación de tu compra. Utilizaremos los medios de contacto que proporcione para comunicarnos en caso de cualquier inconveniente con la publicación. Si experimenta algún problema, no dude en ponerte en contacto con nosotros a través de los canales:",
|
||||||
"checkoutTermsAndPrivacyNotice": "Al comprar este sitio, se compromete a complir con nuestros términos y condiciones, y acepta nuestra política de privacidad disponible en los siguientes enlaces:",
|
"checkoutTermsAndPrivacyNotice": "Al hacer uso del servicio de Conex, se compromete a complir con nuestros términos y condiciones, y acepta nuestra política de privacidad disponible en los siguientes enlaces:",
|
||||||
"supportEmail": "Correo electrónico: conex.one.cr@gmail.com",
|
"supportEmail": "Correo electrónico: conex.one.cr@gmail.com",
|
||||||
"supportPhone": "",
|
"supportPhone": "",
|
||||||
"supportSchedule": "Horario de atención: L-V: 9:00 a.m. - 6:00 p.m.",
|
"supportSchedule": "Horario de atención: L-V: 9:00 a.m. - 6:00 p.m.",
|
||||||
|
|
|
@ -136,6 +136,14 @@ paypal.Buttons({
|
||||||
directory: savedData.directory,
|
directory: savedData.directory,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const response = await fetch("https://api.conex.one/api/extend", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(requestData),
|
||||||
|
});
|
||||||
|
|
||||||
const orderData = await response.json();
|
const orderData = await response.json();
|
||||||
|
|
||||||
if (orderData.id) {
|
if (orderData.id) {
|
||||||
|
@ -196,6 +204,15 @@ paypal.Buttons({
|
||||||
orderData,
|
orderData,
|
||||||
JSON.stringify(orderData, null, 2),
|
JSON.stringify(orderData, null, 2),
|
||||||
);
|
);
|
||||||
|
const dueDate = await getDueDate(dir);
|
||||||
|
const previewElement = document.getElementById('checkdir-duedate');
|
||||||
|
previewElement.style.display = "block"
|
||||||
|
|
||||||
|
if (dueDate) {
|
||||||
|
previewElement.innerHTML = `Fecha de término actualizada: ${dueDate}`;
|
||||||
|
} else {
|
||||||
|
previewElement.innerHTML = "No se pudo cargar la fecha de término.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
|
@ -126,6 +126,7 @@ func main() {
|
||||||
s3Client = s3.NewFromConfig(cfg)
|
s3Client = s3.NewFromConfig(cfg)
|
||||||
|
|
||||||
http.HandleFunc("/api/orders", CreateOrderHandler(db, amount))
|
http.HandleFunc("/api/orders", CreateOrderHandler(db, amount))
|
||||||
|
http.HandleFunc("/api/extend", ExtendOrderHandler(db, amount))
|
||||||
http.HandleFunc("/api/orders/", CaptureOrderHandler(db))
|
http.HandleFunc("/api/orders/", CaptureOrderHandler(db))
|
||||||
http.HandleFunc("/api/update", UpdateSiteHandler(db))
|
http.HandleFunc("/api/update", UpdateSiteHandler(db))
|
||||||
http.HandleFunc("/api/confirm", ConfirmChangesHandler(db))
|
http.HandleFunc("/api/confirm", ConfirmChangesHandler(db))
|
||||||
|
@ -188,7 +189,7 @@ func CreateOrderHandler(db *sql.DB, amount string) http.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(cart.Directory) > 35 {
|
if len(cart.Directory) > 35 {
|
||||||
http.Error(w, "Site already exists", http.StatusConflict)
|
http.Error(w, "Site title is too long", http.StatusConflict)
|
||||||
log.Printf("%s: %v", "Site title is too long", nil)
|
log.Printf("%s: %v", "Site title is too long", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -216,6 +217,51 @@ func CreateOrderHandler(db *sql.DB, amount string) http.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExtendOrderHandler(db *sql.DB, amount string) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
enableCORS(w)
|
||||||
|
if r.Method == http.MethodOptions {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var cart struct {
|
||||||
|
Directory string `json:"directory"`
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(&cart); err != nil {
|
||||||
|
httpErrorAndLog(w, err, errReadBody, "Error decoding response")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(cart.Directory) > 35 {
|
||||||
|
http.Error(w, "Site title is too long", http.StatusConflict)
|
||||||
|
log.Printf("%s: %v", "Site title is too long", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if exists := AvailableSite(db, cart.Directory); exists == nil {
|
||||||
|
http.Error(w, "Site doesn't exist", http.StatusConflict)
|
||||||
|
log.Printf("%s: %v", "Site doesn't exist", exists)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
orderID, err := CreateOrder(amount)
|
||||||
|
if err != nil {
|
||||||
|
httpErrorAndLog(w, err, errCreateOrder, "Error creating order")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var response struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
}
|
||||||
|
response.ID = orderID
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func CaptureOrderHandler(db *sql.DB) http.HandlerFunc {
|
func CaptureOrderHandler(db *sql.DB) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
enableCORS(w)
|
enableCORS(w)
|
||||||
|
|
Loading…
Reference in a new issue