Cheat Sheet: How to run PUSH (OCT) Transaction for Query API

jmedlen
Visa Employee

Watch the recording of my How to Run the Query API in Visa Direct Transactions as you follow along with this cheat that includes more details and sample code needed to run the PUSH (OCT) transaction. 

 

This guide will walk you through two things:

 

  1. How to extend a PUSH (OCT) transaction for Query API - We are going to run the PUSH (OCT) and after we are going to retrieve the PUSH (OCT) transaction details using acquiringBin and transactionIdentifier

 

  1. We are going to simulate a timeout for PUSH(OCT) transaction by passing header “x-transaction-timeout-ms","1" and use Query API to retrieve the transaction details. In this case, we do not have transactionIdentifier, so we can use retrievalReferenceNumber (RRN) and systemsTraceAuditNumber(STAN) to retrieve the PUSH(OCT) transaction which has timed out.

 

If the Query API was not able to retrieve a transaction for some reason, you would have to use retry the logic and send the PUSH (OCT) transaction again.

 

query1.png

 

Let's get started. 

 

1 - Modify Python Sample Code

 

We are going to slightly modify our Python Sample Code (found here) in order to capture transactionIdentifier which is going to be used in our Query API example. We are also going to capture the X-CORRELATION-ID as well.

 

2- Generate retrievalReferenceNumber (RRN) and systemTraceAuditNumber (STAN). For that, we have developed two functions, more details can be found here.

 

Now we are ready to run the Query API

 

Why do we need the Query API? It allows service providers to query history of transactions and return the entire transaction set related to the original Visa Direct transaction. A transaction set will include approved and settled original Visa Direct transactions, reversals, chargebacks, adjustments, and re-presentments.

 

For more details, please see our API documentation

 

Scenario A: PUSH(OCT) transaction was successful and in this case we have transactionIdentifier

 

- If this happens, we can use GET in this format to retrieve transaction details e.g.: /transactionquery?acquiringBIN=408999&transactionIdentifier=234234322342343

 

Scenario B: PUSH(OCT) transaction was NOT successful and in this case we do NOT have transactionIdentifier.

 

- If this happens, ee have to use STAN and RRN to retrieve transaction details using GET in this format to retrieve transaction details

e.g.: /transactionquery?acquiringBIN=408999&stan=351480&rrn=221917871070

 

Now, let's simulate a timeout and retrieve transaction data using Query API

 

In order for us to simulate timeout, we have to add one parameter into header.

 

“x-transaction-timeout-ms","1" (it is case insensitive)

 

 

 

 

 

headers = { "content-type": "application/json",
            "Accept": "application/json",
            "X-Transaction-Timeout-MS" : "1"
            }

 

 

 

 

 

HTTP HEADER VARIABLE

DESCRIPTION

X-Transaction-Timeout-MS

This is an optional variable.

Elapsed time in milliseconds (ms) in which an API will respond back. If no value is specified then it defaults to 30000 ms (i.e. 30 seconds), which is the maximum value allowed. If the set value is greater than the maximum value then timeout will not occur. The API will respond with HTTP 202 ACCEPTED if the processing has not yet completed. If the processing completes within the designated timeout period, then the API will return HTTP 200 OK and the XML- or JSON-formatted response, based on the Content-Type value.

 

202

None

The POST transaction timed out. If the API is not able to complete the transaction within 30 seconds (default) or within the timeout duration set in the HTTP header, it will respond with an 202 HTTP Status Code and a statusIdentifier value that can be used in the GET operation as the statusIdentifier in the URI.

 

Query2.png

 

The Sample Code is attached. 

 

There you have it! Hope you find this guide helpful 

 

Please make sure to save this and if you have any questions comment below, ask in our forums or email us at developer@visa.com - we're here to help. 

 

Have feedback? Share below.