I have just implemented a payment gateway in my application. The final transaction status from the gateway is received at my redirect_url which I have set as one of my Google Firebase HTTPS Cloud Functions. The URL goes something like this:
https://*******.cloudfunctions.net/abcd
I don’t think this process has been used before by anyone and hence I am worried. The architecture runs great and the transaction completes successfully with the Cloud Function Correctly extracting the status. But the problem is that, when I checked the cloud function logs, I found that this function never ends with a Status OK. It is always:
“Function execution took 55636 ms, finished with status: ‘timeout'”
The code goes like this:
exports.ccavRes = functions.https.onRequest(async (req, res) => {
var ccavEncResponse = ''
var ccavResponse = ''
var workingKey = ******
var ccavPOST:any = ''
const md5 = *****//Hashing step;
const keyBase64 = *****//;
// Initializing Vector and then convert in base64 string
const ivBase64 = *******
ccavEncResponse = req.rawBody.toString()
ccavPOST = qs.parse(ccavEncResponse);
const encryption = *****
ccavResponse = ********
const params = ccavResponse.split("&");
let map = new Map<any, any>();
for (var i = 0; i < params.length; i++) {
var parts = params[i].split('=');
map.set(parts[0],parts[1].substr(0, parts[1].length))
}
const order_id = map.get('order_id')
const order_status = map.get('order_status')
const database = admin.database().ref()
await database.child(*****).child(order_id).child("Status").set(order_status)
return
})
I have tried adding res.send() before return as per the Firebase Documentation. But that gives a compilation error:
Property ‘send’ does not exist on type ‘Response’
The code is written in typescript.