Payload to database

A payment gateway delivers a payload upon transaction. I created a table for this payload, when the payload is posted it returns an ‘Invalid Header’ error.

The payload looks like this:

const ITN_Payload = {
‘m_payment_id’: ‘SuperUnique1’,
‘pf_payment_id’: ‘1089250’,
‘payment_status’: ‘COMPLETE’,
‘item_name’: ‘test+product’,
‘item_description’: ‘test+description’ ,
‘amount_gross’: 200.00,
‘amount_fee’: -4.60,
‘amount_net’: 195.40,
‘custom_str1’: ‘’,
‘custom_str2’: ‘’,
‘custom_str3’: ‘’,
‘custom_str4’: ‘’,
‘custom_str5’: ‘’,
‘custom_int1’: ‘’,
‘custom_int2’: ‘’,
‘custom_int3’: ‘’,
‘custom_int4’: ‘’,
‘custom_int5’: ‘’,
‘name_first’: ‘’,
‘name_last’: ‘’,
‘email_address’: ‘’,
‘merchant_id’: ‘10000100’,
‘signature’: ‘ad8e7685c9522c24365d7ccea8cb3db7’
};

The endpoint to post to would be this table:

It posts to : https://api.backendless.com/53D8E0B3-CAB5-DBDC-FF1F-CD01F1E14900/{API KEY}/data/ITN_Payload

What would be the best approach in accepting this payload, an API service or Business logic… please kindly advise?

Hi, @Marco_De_Freitas

Due to error which you receive seems like there is missed a header in your request. You should first test calling the business logic method from the console. If everything is fine there, the request is being processed and you don’t see any errors you need to export the request to CURL and check the headers.

I would also recommend you to generate your API-key which you sent us, as the key has been compromised.

What would be the best approach in accepting this payload, an API service or Business logic… please kindly advise?

In your case it will be good to use REST.

Regards,
Marina

Thank you @Marina.Kan

I have passed the objectId of the owner plus the user-token along with the payload, but fails:

HTTP/1.1 401 Unauthorized
Server: nginx
Date: Fri, 18 Dec 2020 13:19:21 GMT
Content-Type: application/json
Content-Length: 125 Connection: keep-alive Strict-Transport-Security: max-age=31536000; preload

Make sure you have the correct permissions for this table. Just for the testing, grant access for the NotAuthenticatedUser to create objects in this table. If so, is the query successful?
Make sure that you pass a valid user-token of the user.

Regards,
Marina

1 Like

Thank you for your advice and assistance, managed to solve this by sending the payload to a PHP page, JSON decoding payload and posting to backendless.