Query Transaction Status


This function allows merchant to query the current status of a previous transaction based on a transactionID.


Endpoints

HTTP Method API URL API Version
GET https://api.payzone.ma/transaction/{transactionID} >= 002

Accepted parameters

No fields are needed in the request. The transaction reference is in the URI.


Code samples

Note: Gateway API transactions are done with a different library than payment-page API. See the code sample comments for more info:

   
    /*
    *   Transaction name is 'StatusTransaction', once you create a new transaction passing this as parameter, 
    *   you need to set the mandatory data using the following method:
    *    setReferralInformation()
    */

    $client = new GatewayClient();

    $transaction = $client->newTransaction('StatusTransaction', 'testMerchant', 'testPassword');
    $transaction->setTransactionID($transactionID);

    $response = $transaction->send();

    if ('000' === $response->errorCode) {
        $transactionID  = $response->transactionID;
    } else {
        echo "Error {$response->errorCode} with message {$response->errorMessage}";
    }
                      
   
    PaymentGatewayConnector connector = new PaymentGatewayConnector(API_URL, ORIGINATOR, PASSWORD);

    TransactionStatusResponse response = null;
    TransactionStatusRequest request = new TransactionStatusRequest();
    request.setTransactionId(1234567L);

    try {
        response = connector.getTransactionStatus(request);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (response != null) {
        if (TransactionResultCode.TRANSACTION_SUCCESSFULLY.equals(response.getErrorCode()) {
        // Just examples, careful to NPE
        System.out.println("Success: " + response.getErrorMessage());
        System.out.println("Transaction order ID: " + response.getTransaction().getOrderId());
        // If account is allowed to access payment mean info
        if (TransactionType.CREDIT_CARD.equals(response.getTransaction().getPaymentType())) {
            CreditCardPaymentMeanInfo pmInfo = response.getTransaction().getPaymentMeanInfo(CreditCardPaymentMeanInfo.class);
            System.out.println("Credit card is a " + pmInfo.getCardBrand().getFormattedMessage(Locale.ENGLISH));
        }
        } else {
        System.out.println("Failure: " + response.getErrorMessage());
        }
    }
                      
   
    const gateway = require("payxpert")("123456", "GreatP4ssw0rd").gateway;

    let transactionID = "111...";

    let responseQuery = await gateway.queryTransaction(transactionID);

    if (responseQuery.code == "000") {
        // Success
    }
        
        
   
    var client = new GatewayClient(OriginatorConfig.ORIGINATOR_ID, OriginatorConfig.ORIGINATOR_PASSWORD);
    var queryTransactionSale = client.NewQueryTransactionStatus(transactionID);

    var transactionInfo = await queryTransactionSale.Send();
    Console.WriteLine("Transaction timestamp retrieved from server: " + transactionInfo.transaction.date);

    // ...
                        
                        

Response

The body of the response is in JSON format.

The following fields are present in the response :


Name Type Description
transactionID String Transaction reference returned by the system
errorCode String See API Response Codes
errorMessage String See API Response Codes
transaction String Transaction object if found. (see Transaction object)

© Payzone | 2023