How to get a status message after a Paynow transaction


#1

Hello, I am developing a JavaScript application that enables users to make Paynow payments. The issue I have is that I need a way to log a transaction status message (OK or Error) depending on whether the transaction was successful or not, and then execute a function based on the returned message. This will occur in an IF statement.

Is there anyway I can get the status message in my code, perhaps after a promise has executed?


#2

Is your Javascript application is client-side or server-side?


#3

I am using client side Javascript. It’s an Angular app


#4

Beware that the “secret key” used for your Paynow integration must NEVER be visible from the client side (obfuscation techniques just arent enough because Javascript applications can be reverse engineered with relative ease, compromising the security of your payments)

If you’re to execute requests to (and verify responses from) Paynow from client side, the “secret key” will need to be available on the client, thus compromising the security of your payments.

However, if your angular app simply communicates transaction results between your client and your server, then your Paynow communications can remain server-to-server which will maintain your security


#5

Ok got it. I am using the URL scheme with base 64 encoding from the docs for my transactions containing amount, merchant email and reference, using the JavaScript btoa function. So how do I get a transaction response of either success or failure. Is it a JSON object? Maybe something like { status: Paid } or something?


#6

I’d suggest reviewing the developer documentation here regarding status updates https://developers.paynow.co.zw/docs/status_update.html

You may find it simpler to use an SDK from here https://developers.paynow.co.zw/docs/quickstart.html


#7

Oh ok I just found something that might be of use from the 1st URL you sent. Something about permitting tokenized payment instruments to return fields from the status response message.

Looks like I will have to contact support to apply the functionality. Thank you for that.


#8

@NgoniX I don’t believe tokenization is the solution you are seeking, for the particular issue you have.

In order to receive status updates for your Paynow transactions you simply need to provide a resulturl when initiating a transaction. Paynow will respond with the appropriate status to that URL whenever the transaction status changes, e.g. Created, Cancelled, or Paid (see more statuses here)

As @James has mentioned though, it’d be a huge security risk to do the entire process from the client-side… there is sensitive data that must be handled on the server side of your application.

What are using for the server-side backend of your application? i.e. NodeJS, PHP, .NET?


#9

For the server-side I am using PHP Slim micro framework. When I try to do the initiate a transaction method from the docs and then provide the Integration ID and the other fields (including the hash) as a JSON object in my HTTP Post request it always writes

Status=Error&Error=Invalid+ID

I was sent the Integration ID & Key to my email. What could be the reason for that?


#10

@NgoniX, when you issue HTTP POST request to initiate a transaction, the request should be of content type application/x-www-form-urlencoded.


#11

Ok can i use a REST client like Postman to test the HTTP POST request with content type application/x-www-form-urlencoded?


#12

Yes, in Postman when you create a POST request,in the ‘Body’ tab just under the URL, there is a radio button option to select body content type as x-www-form-urlendcoded.


#13

Ok now I get it. Thank you so much. Let me try


#14

Can u assist me with this one please