Getting Started with Visa Developer
First time to the Visa Developer Center? Watch this tutorial to learn where to find the Visa APIs th...
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:
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.
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. |
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. |
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First time to the Visa Developer Center? Watch this tutorial to learn where to find the Visa APIs th...
Watch the recording of my How to Run a Visa Direct Transaction using Python webinar as you follow al...
Learn how to create a project and where to find test data, credentials and sample code. Leave a comm...
We feel that the Visa Developer Center has come full circle since launch in 2016. It hosts many APIs...