According to wix - I can Post data to http-function.js file in the backend which can handle request,(Get , Post methods ) and save Data to Collection, This http-function.js file works as exposed api from the wix .But when I post to backend file the url opens “http://wixhome/_functions/fillnameandphone” the site says this page is not working.
But I want to show the name and phone number(Json Posted from external page ) after Posting data from external website on the page where data is sent? How can I do that ?
These two examples should help you:
You will need to supply more information for us to be able to assist you. What do you mean by “when I post to backend file…”? What code are you using in the backend? What are you doing on the page itself?
I am Using a Payment gateway, which sends the JSON of information,name,txnid,phone,amount to Url. This payment gateway asks The Url where I want to send JSON data . After processing Transaction
the Payment gateway page navigate to the URLs where data is sent.
and I can’t find the way to get the JSON from wix page which is sent by payment gateway .
So I Used http-function.js to fill Posted data into my collection and then I want to show success message on page on the same page where Json is Posted by Payment Gateway
Hi "firstname " Your Transaction id is “txnid” and your payment is Successful
But I can’t find any way please suggest any method to show message to the user .The page says “http://wixhome/_functions/fillnameandphone”
The page is not working
///// code works fine for putting JSON to my collection.
and I created a Dynamic page from the collection which shows
the message
Hi "firstname " Your Transaction id is “txnid” and your payment is Successful .
But I can’t find the possible way to navigate to this dynamic page from the https-function page.And in the end the user finds, This page is not working
. I am stuck on it ,
due to wixlocation 500 internal error occur .
{Is there any way to get JSON by the wix-page , put Json data to collection and navigate to dynamic page ,which shows message to user }
import {created, serverError} from ‘wix-http-functions’;
import wixData from ‘wix-data’;
export async function post_ fillnameandphone (request) {
let options = {
“headers”: {
“Content-Type”: “application/x-www-form-urlencoded”,
“key”:“—”
}
};
return request.body.text()
.then( (body) => {
var str = body.toString()
var mainString = str.slice(9,str.length)
var detail = decodeURIComponent(mainString)
let recordInsert = {
"title": detail.encryptedPaymentId,
"firstname": detail.firstname,
"amount": detail.amount,
"phone": detail.phone,
"txnid": detail.txnid
}
return wixData.insert("paymentrecords", recordInsert);
} )
.then( (results) => {
options.body = results ;
return created(options);
} )
.catch( (error) => {
options.body = {
"error": error
};
return serverError(options);
} );
}
You can’t send a notification to a front end page from backend code. Pages can call backend code ( web modules ) which can return data, values, status, etc.
Is the payment initiated on a specific page in the site? If so, when you call the payment function in the backend, you can return the status when it arrives.
See the Stripe Payment Processing example for a demonstration.
Also, where does “http://wixhome/_functions/fillnameandphone” come from? Is fillnameandphone a function? Why is it http - Wix sites only support https by default.
That’s the name of the function in http-function.js where Payment Gateway sends JSON .
“You can’t send a notification to a front end page from backend code.” That’s why I was asking Is there any way to get the JSON data posted to front end page, and then call Backend file and put data to the collection and then redirect to dynamic page , as frontend page allows wix-location, where I can show Transaction success message to the user .
I checked Inspect network after Payment Transaction ,the Wix frontend page receives the JSON data ,but gives response 403 forbidden
OK, so I’m confused - which does happen from time to time, even before I have my beer for lunch.
Please post the editor URL of your site so I can take a look what you’ve got. Only authorized Wix personnel can get access to your site in the editor. Please include the names of the relevant site pages and backend files so I know where to look.
well this page
https://www.swastikhomecare.com/payment
sends user to the payment gateway page
after processing transaction, the payment gateway page
sends the data to " https://www.swastikhomecare.com/ _functions/addpayments"
you can see in Screenshot(88) , I have Success Url option to send data
and from collection, I am creating a dynamic page
https://www.swastikhomecare.com/status/4E5A0E0777CA4034B5B32B224C0DAAFB
which have the sufficient variables to generate pdf receipt and show success message
Suggest me any idea to take user to this dynamic page of message and pdf
@kartikgotenk OK, now I (sort of) understand what’s going on.
I would higly recommend interfacing to the payment provider’s API to ensure that the transactions and their data are secure and private.
See the docs for the PayUMoney API for more information. You can use the Stripe Payment Processing example as a starting point to integrate PayUMoney into your site.
The current way that you have set up will expose sensitive information, and also presents a technical challenge to fully integrate notifications and processing.