21/03/23 - 22h
parent
243d736481
commit
25cbdd88eb
|
@ -143,6 +143,8 @@ function CheckOut(props) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const [stripe_existing_souscription_id, setstripe_existing_souscription_id] = useState();
|
||||||
|
|
||||||
const [stripe_account_id, setstripe_account_id] = useState("aaa");
|
const [stripe_account_id, setstripe_account_id] = useState("aaa");
|
||||||
const [stripe_paymentmethod_id, setstripe_paymentmethod_id] = useState();
|
const [stripe_paymentmethod_id, setstripe_paymentmethod_id] = useState();
|
||||||
|
|
||||||
|
@ -273,6 +275,12 @@ function CheckOut(props) {
|
||||||
document.getElementsByName("telephone")[0].style.backgroundColor = "#ECEFF1";
|
document.getElementsByName("telephone")[0].style.backgroundColor = "#ECEFF1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (mylocaltraining.stripe_subscription_id) {
|
||||||
|
|
||||||
|
setstripe_existing_souscription_id(mylocaltraining.stripe_subscription_id);
|
||||||
|
}
|
||||||
|
|
||||||
desablefield1();
|
desablefield1();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -462,11 +470,26 @@ function CheckOut(props) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(" ### stripe_existing_souscription_id = ", stripe_existing_souscription_id);
|
||||||
|
|
||||||
//initpayement_front();
|
//initpayement_front();
|
||||||
|
|
||||||
// ---------- debut
|
// ---------- debut
|
||||||
|
|
||||||
setpayment_in_process("1");
|
setpayment_in_process("1");
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
IMPORTANT :
|
||||||
|
Quand c'est la première fois ou si le partenaire n'a pas de deja un abonnement en cours,
|
||||||
|
alors on faire une creation.
|
||||||
|
|
||||||
|
Si non c'est une mise à jour qu'il faut faire
|
||||||
|
|
||||||
|
la souscription_id du partenaire est stocké ici : stripe_existing_souscription_id
|
||||||
|
*/
|
||||||
|
if (!stripe_existing_souscription_id) {
|
||||||
|
// Le client n'a pas de soucription id, donc on fait une creation.
|
||||||
var myurl = process.env.REACT_APP_API_URL + "myclass/api/create-subscription/";
|
var myurl = process.env.REACT_APP_API_URL + "myclass/api/create-subscription/";
|
||||||
|
|
||||||
var form1 = new FormData();
|
var form1 = new FormData();
|
||||||
|
@ -506,7 +529,51 @@ function CheckOut(props) {
|
||||||
//console.log('Error:', error.message);
|
//console.log('Error:', error.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Le client a une souscription id, donc on fait une mise à jour
|
||||||
|
var myurl = process.env.REACT_APP_API_URL + "myclass/api/strip_update_subscription_plan/";
|
||||||
|
|
||||||
|
var form1 = new FormData();
|
||||||
|
|
||||||
|
var local_souscription_id;
|
||||||
|
var local_souscription_id2;
|
||||||
|
|
||||||
|
const stored_cookie = getCookie('tokenmysypart');
|
||||||
|
form1.append("token", stored_cookie);
|
||||||
|
form1.append("pack", currentpack);
|
||||||
|
form1.append("qty", nb_formations);
|
||||||
|
|
||||||
|
fetch(myurl, {
|
||||||
|
method: 'POST',
|
||||||
|
body: form1,
|
||||||
|
}).then((data) => data.json())
|
||||||
|
.then((data) => {
|
||||||
|
console.log(" #### status", data['status'], ' ### message : ', data['message']);
|
||||||
|
//local_souscription_id = data['subscription_id'];
|
||||||
|
|
||||||
|
//console.log(" ### INSIDE initpayement_front(); : local_souscription_id = ", local_souscription_id);
|
||||||
|
//setpayement_id(data['subscription_id']);
|
||||||
|
|
||||||
|
if (String(data['status']) === String("true")) {
|
||||||
|
|
||||||
|
console.log(" status = OKKK ");
|
||||||
|
//console.log(" subscriptionId = " + subscriptionId + " -- et clientSecret = " + clientSecret);
|
||||||
|
//setclientSecret_id(data['payment_intent_client_secret']);
|
||||||
|
//setpayement_id(data['subscription_id']);
|
||||||
|
|
||||||
|
//local_souscription_id2 = data['subscription_id'];
|
||||||
|
|
||||||
|
//setSubscriptionData(data['subscription_id'], data['payment_intent_client_secret'] );
|
||||||
|
//alert(" subscriptionId = " + data['subscription_id'] + " -- et clientSecret = " + data['payment_intent_client_secret']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}).catch((error) => {
|
||||||
|
//console.log('Error:', error.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
// ----- end
|
// ----- end
|
||||||
|
|
||||||
//console.log(" ### apres initpayement_front(); : local_souscription_id = ", local_souscription_id, " local_souscription_id2 = ",local_souscription_id2);
|
//console.log(" ### apres initpayement_front(); : local_souscription_id = ", local_souscription_id, " local_souscription_id2 = ",local_souscription_id2);
|
||||||
|
@ -564,12 +631,43 @@ function CheckOut(props) {
|
||||||
setgotocheckout("");
|
setgotocheckout("");
|
||||||
|
|
||||||
console.log(" ### packprice = ", packprice);
|
console.log(" ### packprice = ", packprice);
|
||||||
|
|
||||||
|
/*
|
||||||
|
IMPORTANT :
|
||||||
|
On fait une finalisation d'abonnement que si c'est la première fois qu'il souscrit
|
||||||
|
*/
|
||||||
|
if (!stripe_existing_souscription_id) {
|
||||||
if (parseFloat(packprice) > 0)
|
if (parseFloat(packprice) > 0)
|
||||||
finalize_abonnement(local_souscription_id);
|
finalize_abonnement(local_souscription_id);
|
||||||
else if (String(props.packs).toLowerCase() === String("decouverte")) {
|
else if (String(props.packs).toLowerCase() === String("decouverte")) {
|
||||||
MySy_LMS_Account_Management();
|
MySy_LMS_Account_Management();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
console.log(" laaaaa ")
|
||||||
|
if (String(props.packs).toLowerCase() === String("decouverte")) {
|
||||||
|
MySy_LMS_Account_Management();
|
||||||
|
alert(" La mise à jour de votre abonnement a été correctement traitée. Vous allez recevoir par email les details de la commande et la facture.")
|
||||||
|
window.location.reload();
|
||||||
|
}else{
|
||||||
|
MySy_LMS_Account_Management();
|
||||||
|
alert(" La mise à jour de votre abonnement a été correctement traitée. Vous allez recevoir par email les details de la commande et la facture.")
|
||||||
|
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
JE suis ici.
|
||||||
|
la mise à jour du pack semble fonctionner.
|
||||||
|
a faire :
|
||||||
|
tester à fond.
|
||||||
|
si changement de forfait. desactivier toutes les formations avant (dans mysy et le lms)
|
||||||
|
|
||||||
|
pb : coté backoffice. la gestion du : #salt = salt.decode('UTF-8')
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -585,8 +683,6 @@ function CheckOut(props) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const [paymentadded, setpaymentadded] = useState("");
|
const [paymentadded, setpaymentadded] = useState("");
|
||||||
|
@ -1035,9 +1131,11 @@ function CheckOut(props) {
|
||||||
{payement_3DS_url && <div>
|
{payement_3DS_url && <div>
|
||||||
|
|
||||||
<iframe src={payement_3DS_url} id="3DS_iframe"
|
<iframe src={payement_3DS_url} id="3DS_iframe"
|
||||||
style={{ "border": "solid 2px", "width": "90%", "height": "600px",
|
style={{
|
||||||
|
"border": "solid 2px", "width": "90%", "height": "600px",
|
||||||
"marginBottom": "2rem",
|
"marginBottom": "2rem",
|
||||||
"marginLeft":"5%" }}>
|
"marginLeft": "5%"
|
||||||
|
}}>
|
||||||
|
|
||||||
</iframe>
|
</iframe>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue