I want to correlate the appearance of the lightbox with the change of Text value. It is the value in which the phrase appears =====>>>> “Thank you for your payment” <========
export function btnPay_click(event,$w) {
$w( "#txtMessage" ).show(); $w( "#txtMessage" ).expand();
$w( '#txtMessage' ).text = "Waiting for response from Stripe..." ;
$w( '#txtMessageLabel' ).hide(); $w( "#txtMessageLabel" ).expand();
payNow();
}
export function payNow() {
let payment = {
“amount” : ($w( “#Amount” ).value * 100 ),
“currency” : “USD” ,
“description” : $w( “#iptDesc” ).value
}
createToken(encodeCard(createCard()))
.then((token) => {
charge(token, payment)
.then((response) => {
if (response.chargeId) {
console.log(response.chargeId);
$w( '#txtMessage' ).text = "Thank you for your payment" ;
}
else {
console.log(response.error);
$w( ‘#txtMessage’ ).text = “Processing error:” + response.error;
}
});
});
if ($w( “#txtMessage” ).text === “Thank you for your payment” ) ///HERE <<<<<====
(wixWindow.openLightbox( "Payment Success" )
)
}
then appears this lightbox
Take a look at this example, then you should understand how to work with lightboxes and how to transfer data to them…
https://russian-dima.wixsite.com/meinewebsite/lightbox
THANK YOU but the example in the link is completely different from what I want to do
Do not understand what you want to do exactly?
When the “Thank you for your payment” message appears, what should happen ?
When the “Thank you for your payment” message appears then the lightbox show
And this do not work ?
Where is your “import”-part in the top of your code?
import wixWindow from 'wix-window';
What do you get back from console, when …
console.log($w("#txtMessage").text)
Perhaps this?
import wixWindow from 'wix-window';
export function btnPay_click(event,$w) {
$w("#txtMessage").show(); $w("#txtMessage").expand();
$w('#txtMessage').text = "Waiting for response from Stripe...";
$w('#txtMessageLabel').hide(); $w("#txtMessageLabel").expand();
payNow();
}
export function payNow() {
let payment = {
"amount": ($w("#Amount").value * 100),
"currency": "USD",
"description": $w("#iptDesc").value
}
createToken(encodeCard(createCard()))
.then((token) => {
charge(token, payment)
.then((response) => {
if(response.chargeId) {
console.log(response.chargeId);
$w('#txtMessage').text = "Thank you for your payment";
console.log($w('#txtMessage').text)
wixWindow.openLightbox("Payment Success")
}
else {
console.log(response.error);
$w('#txtMessage').text = "Processing error:" + response.error;
}
});
});
}
Thank you very much … the code works very well … all thanks and appreciation to you
I want another service if I don’t bother you with my requests
I have this form through which the customer fills in the data, selects the product, and then presses the purchase button… I want the customer when I click on the purchase button, the data is stored in the database at the same time, but only when the purchase is valid i.e. when this phrase appears “Thank you for your payment”
As in the previous example
In other words, when you click on the button( Stripe Checkout ), and the purchase is successful , it is saved in the database. In the event that the purchase process fails , it is not saved to the database
This is what you will need…
import wixData from 'wix-data';
2
3// ...
4
5let toInsert = {
6 "title": "Mr.",
7 "first_name": "John",
8 "last_name": "Doe"
9};
10
11wixData.insert("myCollection", toInsert)
12 .then( (results) => {
13 let item = results; //see item below
14 } )
15 .catch( (err) => {
16 let errorMsg = err;
17 } );
18
19
You will have to insert it after this code-line…(directly)…
$w('#txtMessage').text = "Thank you for your payment";
or as a calling function…
$w('#txtMessage').text = "Thank you for your payment";
myFunction();
In this way…
function myFunction (parameter) {
let toInsert = {
"title": "Mr.",
"first_name": "John",
"last_name": "Doe"
};
wixData.insert("myCollection", toInsert)
.then( (results) => {
let item = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} );
}
title and first name and last name -----> name of field in application or Field Key
@russian-dima title and first name and last name -----> name of field in application or Field Key
@contact39131
That was an example.
You have of course to modify it by your own…
Waht do you want to INSERT into which COLUMN (in your DATABASE) ???
What are the column-IDs in your database? title… firstName … lastName…eMail ???
I do not know the structure of your DB. Just you know this.
let toInsert = {
"title": $w('#input1').value,
"firstName": $w('#input2').value,
"lastName": $w('#input3').value
"email": $w('#input4').value
"country": $w('#input5').value
"state": $w('#input6').value
"countryCode": $w('#input7').value
//and so on.......
};
Good luck and happy coding and do not forget to like it if you liked it.
Thank you. I benefited from your information and the codes are working well. Thanks and appreciation
But still do not see any like or even best answer 
@russian-dima I want another service from you😅, a code to clean / reset the fields after the registration process and accept payment😊
@russian-dima Best Answers