Reporting
- 17 Jul 2023
 - 5 Minutes to read
 - Contributors

 
- Print
 - DarkLight
 - PDF
 
Reporting
- Updated on 17 Jul 2023
 - 5 Minutes to read
 - Contributors

 
- Print
 - DarkLight
 - PDF
 
Article summary
Did you find this summary helpful?    
Thank you for your feedback!
Use the Reporting web service to retrieve the invoices based on the parameters that are sent .
Syntax
POST rest/InvoicesService/reporting
Service Specifications
| Property and Information | 
  | 
Input Parameters
| Parameter | Description | 
|---|---|
| merchantID required  | An alphanumeric value that represents the Merchant ID. The Payment Gateway operation team provides this value based on the merchant enrollment. 
  | 
| authToken required  | An alphanumeric value that represents the Authentication Token. The Payment Gateway operation team provides this value based on the merchant enrollment.
  | 
| fromDate  required  | Date value representing the Start date of the desired date range for invoices. This value should be in format dd/mm/yyyy. 
  | 
| toDate required  | Date value representing the End date of the desired date range for invoices. This value should be in format dd/mm/yyyy. Maximum difference between fromDate & toDate should be one month 
  | 
| currency  optional  | The character ISO Code for the currency.
  | 
| expiryFromDate  optional  | Date value representing the start date of the desired date range for filtering invoices by expiry date. This value should be in format dd/mm/yyyy. 
  | 
| expiryToDate  optional  | Date value representing end date of the desired date range for filtering invoices by expiry date This value should be in format dd/mm/yyyy. 
  | 
| invoiceType  optional  | Number value representing the type of invoices, the below each number with its type. Possible Values: 
 
  | 
| invoiceId optional  | Alphanumeric value representing the Invoice ID, this value should be unique per invoice.
  | 
| includeDynamicFields    optional  | Boolean value representing the include dynamic fields, this flag to tell the webservice to return the dynamic fields with the response or not.
  | 
| invoiceStatus     optional  | Number value representing the statuses of invoices, the below each number with its status.
 
  | 
| usePagination      optional  | Boolean value representing the use pagination, this flag used for to enable the pagination in the webservice.
  | 
| pageSize conditional  | Number value representing the page size, this value used to determine number of invoices to be retrieved per page. It will be required when “usePagination ” is true 
  | 
| responseOptionalFields  conditional  | Array of Numbers that representing the optional extra fields that you may need in the response.
 
  | 
Sample Request
The Reporting service request should contain the details of the Invoices that you want to collect.
It is in JSON format as the following:
invoice = {
	"authToken" : "YjI1MDc5ODUxNWEwMTkwMDQ4Mjg5YTgy",
	"merchantID" : "testMercahnt",
	"fromDate":"01/06/2023",
    "toDate":"01/07/2023",
    "currency":"",
    "invoiceStatus":"",
    "expiryFromDate":"",
    "expiryToDate":"",
    "invoiceType":"",
    "invoiceId":"",
    "includeDynamicFields": true,
    "responseOptionalFields":["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],
    "usePagination":"true",
    "pageSize":"1",
    "pageNumber":"1"
}
Output Parameters
| Parameter | Description | 
|---|---|
| numberOfPages  conditional  | A number value representing the total number of pages based on the pageSize value provided
  | 
| invoices required  | An JSON Array of invoices details - see section below. 
  | 
Invoices
| Parameter | Description | 
|---|---|
| invoiceCreationDate required  | The date creation of the invoice, with format dd/MM/yyyy hh:mm:ss a
  | 
| invoiceStatus  required  | A Alphanumeric value representing the invoices Status.
 
  | 
| invoiceId required  | Alphanumeric value representing the Invoice ID, this value should be unique per invoice.
  | 
| originalInvoiceAmount   optional  | A numeric value containing the Item purchase amount ISO Formatted
  | 
| cardType  optional  | A Alphanumeric value representing the card type.
  | 
| mobileNumber  optional  | Alphabetic value representing the customer mobile number.
  | 
| approvalCode  optional  | The Approval code of the Payment.
  | 
| originalInvoiceCurrency  optional  | The character ISO Code for the currency of the invoice.
  | 
| description  optional  | Alphanumeric string containing a narrative description of the novice using the language specified in the language parameter. This value should be URL decoded.
  | 
paymentLink optional  | URL representing the generated Payment Link that the customer will be able to process their transactions through
  | 
| maskedCardNumber  optional  | Alphanumeric value representing the masked card number.
  | 
| transactionId  optional  | The Transaction ID generated by the Merchant, it represents a unique identifier for the transaction, and it is alphanumeric. It can’t include special characters neither spaces.
  | 
| RRN  optional  | The Reference Retrival Number of the Payment.
  | 
| expiryDate  optional  | Date representing the computed expiry date and time fromatted as(dd/MM/yyyy HH:mm:ss a)
  | 
| authorizedCurrency  optional  | The character ISO Code for the currency.
  | 
| authorizedAmount  optional  | A numeric value containing the Item purchase amount ISO Formatted
  | 
| invoiceType   optional  | Character value representing the type of invoices,
 
  | 
| completionCurrency optional  | A numeric ISO Code represents the currency for the completedAmount parameter if provided back.
  | 
| paymentMethod  optional  | An Alphanumeric value to indicate which payment method that is used.
  | 
| email  optional  | Alphabetic value representing the customer email address.
  | 
| dynamicFields   conditional  | JSON Array representing the dynamic fields that configured for the merchant on DirectPay, each dynamic field as a JSON object inside the array.
  | 
Sample Response
Reporting service returns the response in JSON format.
The returned response as the following:
{
    "invoices": [
        {
            "originalInvoiceAmount": "1000.00",
            "approvalCode": "119657",
            "invoiceCreationDate": "25/08/2022 02:50:44 AM",
            "mobileNumber": "079999999999999",
            "dynamicFields": [
                {
                    "value": "MCP10587.1",
                    "key": "BookingReference"
                },
                {
                    "value": "16-10-2022 04:59:00",
                    "key": "CheckOut"
                },
                {
                    "value": "2 night, 1 room",
                    "key": "Reservation"
                },
                {
                    "value": "14-10-2022 04:59:00",
                    "key": "CheckIn"
                }
            ],
            "cardType": "Visa",
            "originalInvoiceCurrency": "SAR",
            "description": "Opera+Reservation",
            "paymentLink": "http://172.22.50.67:9082/URLShortener?t=zo9XKX",
            "maskedCardNumber": "401200******0026",
            "transactionId": "16613851109947471758",
            "RRN": "10101450304891",
            "expiryDate": "04/12/2022 08:34:44 AM",
            "authorizedCurrency": "SAR",
            "authorizedAmount": "1000.00",
            "invoiceType": "Pre-Auth & Completion",
            "paymentMethod": "",
            "invoiceId": "DOAA552992491",
            "invoiceStatus": "PAID",
            "email": "aseel.k@stspayone.com"
        }
    ],
    "numberOfPages": 16
}Sample Code
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
.
.
.
 String reportingInvoiceURL = "http://localhost:9081/URL2PayAdminWeb/rest/InvoicesService/reporting";
 
 try{
 JSONObject requestJson = new JSONObject();
 
 requestJson.put("merchantId", "2000568");
 
 
 requestJson.put("authToken", "ZGM1NDgzZTRhMmU2YTUzOGJhNzY1OTM5");
 
 requestJson.put("fromDate", "01/06/2023");
 requestJson.put("toDate", "20/06/2023");
 
 logger.info("the prepared JSON is : "+requestJson.toString());
 
 
 URL obj = new URL(reportingInvoiceURL);
 // Open a connection to the service
 HttpURLConnection con = (HttpURLConnection) obj.openConnection();
 
 // Set the request method to POST
 con.setRequestMethod("POST");
 
 // Set the request headers
 con.setRequestProperty("Content-Type", "application/json");
 con.setRequestProperty("Accept", "application/json");
 con.setRequestProperty("Accept-Encoding", "gzip, deflate, br");
 
 // Enable input and output streams
 con.setDoOutput(true);
 con.setDoInput(true);
 
 // Write the payload to the request body
 DataOutputStream wr = new DataOutputStream(con.getOutputStream());
 wr.writeBytes(requestJson.toString());
 wr.flush();
 wr.close();
 
 // Get the response from the service
 int responseCode = con.getResponseCode();
 
 // Read the response body
 BufferedReader in;
 if (responseCode >= 400) {
 in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
 } else {
 in = new BufferedReader(new InputStreamReader(con.getInputStream()));
 }
 
 String inputLine;
 StringBuilder responseBuilder = new StringBuilder();
 
 while ((inputLine = in.readLine()) != null) {
 responseBuilder.append(inputLine);
 }
 in.close();
 
 // Print the response
 logger.info("Response Code: " + responseCode);
 logger.info("Response Body: " + responseBuilder.toString());
 
 JSONObject responseJson=new JSONObject(responseBuilder.toString()); 
 
 request.setAttribute("invoices", responseJson.toString());
 request.getRequestDispatcher("ReportingInvoiceResponse.jsp").forward(request,response);
 
 }catch (JSONException e) {
// TODO: handle exception
 e.printStackTrace();
}
}
}