Export Transactions List

This function can be used to export and check if there is any inconsistency between the real-time responses and actual approval status at the bank processor end.


Endpoints

HTTP Method API URL API Version
GET https://api.payzone.ma/transactions(/{transactionOperation}) >= 002

Accepted parameters

URL Field Type Max Length Required Description
transactionOperation String 40 no Filter transaction operation to be exported : sale, refund, credit, authorize, capture, cancel or rebill

Get Fields Type Max Length Required Description
startDate String 20 yes Retrieve transactions on or after the startDate. UTC Unix Timestamp
endDate String 20 yes Retrieve transactions on or before the endDate. UTC Unix Timestamp
transactionType String 40 no Filter transaction type to be exported : creditcard, chargeback, fraud … (note: transactionOperation shouldn’t be set to export chargeback and fraud)
transactionErrorCode String 3 no Filter transaction error code to be exported. See API Response Codes

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 'ExportTransaction', once you create a new transaction passing this as parameter, 
    *   you need to set the mandatory data using the following method:
    *    setExportInterval()
    *
    *   Additionally, you can call the following methods for extra parameters:
    *    setExportTransactionOperation(), setExportErrorCode()
    */

    $client = new GatewayClient();

    $transaction = $client->newTransaction('ExportTransaction', 'testMerchant', 'testPassword');
    $transaction->setExportInterval(time() - 3600, time());  //1 hour window
    $transaction->setExportTransactionOperation('sale');          // sale only
    $transaction->setExportErrorCode('000');                 //Successful transaction only

    $response = $transaction->send();

    if ('000' === $response->errorCode) {
        $transactionList = $response->transactionList;
    } else {
        echo "Error {$response->errorCode} with message {$response->errorMessage}";
    }

    /*
    *   Another operation
    */

    $transaction = $client->newTransaction('ExportTransaction', 'testMerchant', 'testPassword');
    $transaction->setExportInterval(time() - 3600, time());  //1 hour window
    $transaction->setExportTransactionType('chargeback');    //chargeback only

    $response = $transaction->send();

    if ('000' === $response->errorCode) {
        $transactionList = $response->transactionList;
    } else {
        echo "Error {$response->errorCode} with message {$response->errorMessage}";
    }
                      
   
    // Export every successful sale transactions in the last hour
    PaymentGatewayConnector connector = new PaymentGatewayConnector(API_URL, ORIGINATOR, PASSWORD);

    TransactionsExportResponse response = null;
    TransactionsExportRequest request = new TransactionsExportRequest();
    request.setTransactionOperation(TransactionOperation.SALE);
    request.setTransactionErrorCode(TransactionResultCode.TRANSACTION_SUCCESSFULLY);

    Calendar cal = new GregorianCalendar();
    cal.add(Calendar.HOUR, -1);
    request.setStartDate(cal.getTime());
    request.setEndDate(new Date());

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

    if (response != null) {
        if (TransactionResultCode.TRANSACTION_SUCCESSFULLY.equals(response.getErrorCode()) {
        System.out.println("Success: " + response.getErrorMessage());
        } else {
        System.out.println("Failure: " + response.getErrorMessage());
        }
    }


    // Export every chargeback transactions in the last hour
    PaymentGatewayConnector connector = new PaymentGatewayConnector(API_URL, ORIGINATOR, PASSWORD);

    TransactionsExportResponse response = null;
    TransactionsExportRequest request = new TransactionsExportRequest();
    request.setTransactionType(TransactionTypeValue.CHARGEBACK);

    Calendar cal = new GregorianCalendar();
    cal.add(Calendar.HOUR, -1);
    request.setStartDate(cal.getTime());
    request.setEndDate(new Date());

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

    if (response != null) {
        if (TransactionResultCode.TRANSACTION_SUCCESSFULLY.equals(response.getErrorCode()) {
        System.out.println("Success: " + response.getErrorMessage());
        } else {
        System.out.println("Failure: " + response.getErrorMessage());
        }
    }
                      
   
    const gateway = require("payxpert")("123456", "GreatP4ssw0rd").gateway;
    let currentTimestamp = Math.floor(Date.now() / 1000);

    let requestBody = {
        startDate: currentTimestamp - (3600 * 5),
        endDate: currentTimestamp + (3600 * 5)
    };

    let exportResponse = await gateway.exportTransactionsList(requestBody);

    // ...

        
   
    var client = new GatewayClient(OriginatorConfig.ORIGINATOR_ID, OriginatorConfig.ORIGINATOR_PASSWORD);
    var exportTransactions = client.NewExportTransactionList(DateTime.UtcNow.AddMonths(-1), DateTime.UtcNow, null);
    var transactions = await exportTransactions.Send();

    Console.WriteLine("Total number of retrieved transactions: " + transactions.transactionList.Count.ToString());

    // ...

    

Response

The body of the response is in JSON format.

The following fields are present in the response :


Name Type Description
transactionList Object List (array) of Transaction objects (see Transaction object)
errorCode String See API Response Codes
errorMessage String See API Response Codes

© Payzone | 2023