We have a preconfigured collection in POSTMAN to speed up the understanding of the basic operation of the API, in this section you will find how to configure this test environment that will allow you to initialize payment attempts for your merchant.

POSTMAN Collection

<aside> <img src="/icons/info-alternate_blue.svg" alt="/icons/info-alternate_blue.svg" width="40px" /> In order to make use of the collection you need to have access to POSTMAN either in its application format or website, you can access this service at postman.com

</aside>


  1. Import the POSTMAN collection using this linkđź”—.

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c61a8627-b836-43f1-ba63-f5c7df147059/image-20220603-162042.png

  2. Declare the collection variables provided by the ETpay integration team.

    Assign in   the variables without considering “session_token”

    Assign in  CURRENT VALUE the variables without considering “session_token”

  3. Make a call with pre-configured test data.

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/076cd006-a51b-4358-b80f-ba86a01be443/image-20220603-154113.png

  4. Observe the request response.

    Untitled

    Note that in this quick start section we will only use the token, but consider that the signature token is extremely important and of mandatory use for the transition to production.

  5. Use the URL in the result “TEST”.

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/723cc71c-4143-49e4-af63-1433ad04e47a/image-20220603-154500.png

    <aside> ⚠️ The QR_URL contains the URL of the payment attempt in QR format, this is so you can more easily test the payment system from a smartphone, however, it uses an external API to transform the URL into QR. We recommend to use it only for testing purposes

    </aside>

  6. Replicate call in your programming language.

    The following Python code executes the POST request described above, and with the session_token obtained redirects to the url that initiates the client's session.

    import requests
    import webbrowser
    
    '''
    Simple API request,
    which redirects to the payment page.
    '''
    
    #Global variables provided by ETpay
    API_URL = r'valid_url'
    PTM_URL = r'valid_url'
    INIT_API = r'/session/initialize'
    MERCHANT_CODE = "valid_code"
    MERCHANT_API_TOKEN = "valid_api_key"
    
    request_data = {
        "merchant_code": MERCHANT_CODE,
        "merchant_api_token": MERCHANT_API_TOKEN,
        "merchant_order_id": "order-1992", #id of the retailer's own purchase order
        "order_amount" : 1,
    }
    
    #Getting session token
    resp = requests.post(API_URL+INIT_API, json=request_data)
    token = resp.json()['token']
    
    #Client session is launched
    webbrowser.open(PTM_URL+'/hites/'+token)
    '''Note that in this code the value of the signature_token is not stored. Its usefulness will be explained in detail later, but it should be noted that it is necessary to obtain its value.'''
    

    Back to TNB integration with API REST