Se rendre au contenu
# Recréation de l'archive ZIP après réinitialisation de l'état
from zipfile import ZipFile
import os
# Dossier de travail
base_path = "/mnt/data/orange_money_web_plugin"
os.makedirs(base_path, exist_ok=True)
# Fichier HTML (formulaire simple)
html_content = """
Payer avec Orange Money
Payer avec Orange Money
"""
# Fichier JS (script de paiement)
js_content = """
document.getElementById("paymentForm").addEventListener("submit", async function(event) {
event.preventDefault();
const phone = document.getElementById("phoneNumber").value;
const amount = document.getElementById("amount").value;
const resultDiv = document.getElementById("result");
const credentials = {
client_id: "DjRbLbmF5p4rCjgFKpXmo9rGyATBo8rR",
client_secret: "n21jsosrJCsDt20k05gYSZfIvvWBaWjjYVSnwkrFxIg4"
};
try {
// Authentification
const authResponse = await fetch("https://api.orange.com/oauth/v3/token", {
method: "POST",
headers: {
"Authorization": "Basic " + btoa(credentials.client_id + ":" + credentials.client_secret),
"Content-Type": "application/x-www-form-urlencoded"
},
body: "grant_type=client_credentials"
});
const authData = await authResponse.json();
const token = authData.access_token;
// Paiement
const paymentResponse = await fetch("https://api.orange.com/orange-money-webpay/gn/v1/webpayment", {
method: "POST",
headers: {
"Authorization": "Bearer " + token,
"Content-Type": "application/json"
},
body: JSON.stringify({
merchant_key: "orangemoneyafrique://gn/v1/openMerchantPayment?agentCode=646734¤cy=GNF&amountMinimum=100&amountMultipleOf=1",
currency: "GNF",
order_id: "order_" + Date.now(),
amount: amount,
return_url: "https://demarche-guinee.com"
})
});
const paymentData = await paymentResponse.json();
if (paymentData.payment_url) {
window.location.href = paymentData.payment_url;
} else {
resultDiv.innerText = "Erreur: " + JSON.stringify(paymentData);
}
} catch (err) {
resultDiv.innerText = "Erreur: " + err.message;
}
});
"""
# Enregistrer les fichiers
with open(os.path.join(base_path, "index.html"), "w") as f:
f.write(html_content)
with open(os.path.join(base_path, "script.js"), "w") as f:
f.write(js_content)
# Création du fichier ZIP
zip_path = "/mnt/data/orange_money_web_plugin.zip"
with ZipFile(zip_path, 'w') as zipf:
for root, _, files in os.walk(base_path):
for file in files:
full_path = os.path.join(root, file)
relative_path = os.path.relpath(full_path, base_path)
zipf.write(full_path, arcname=relative_path)
zip_path
Payer avec Orange MoneyPayer avec Orange Money
Payer maintenant
Payer maintenant