All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.GBSEcom.api.OrderApi Maven / Gradle / Ivy

Go to download

Java SDK to be used with a First Data Gateway account. This SDK has been created and packaged to offer the easiest way to integrate your application into the First Data Gateway. This SDK gives you the ability to run transactions such as sales, preauthorizations, postauthorizations, credits, voids, and returns; transaction inquiries; setting up scheduled payments and much more.

There is a newer version: 1.15.0
Show newest version
/*
 * Payment Gateway API Specification
 * Payment Gateway API for payment processing. 
 *
 * OpenAPI spec version: 0.0.1
 * 
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */


package com.github.GBSEcom.api;

import com.github.GBSEcom.client.ApiCallback;
import com.github.GBSEcom.client.ApiClient;
import com.github.GBSEcom.client.ApiException;
import com.github.GBSEcom.client.ApiResponse;
import com.github.GBSEcom.client.Configuration;
import com.github.GBSEcom.client.Pair;
import com.github.GBSEcom.client.ProgressRequestBody;
import com.github.GBSEcom.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.github.GBSEcom.model.ErrorResponse;
import com.github.GBSEcom.model.SecondaryTransaction;
import com.github.GBSEcom.model.TransactionResponse;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class OrderApi {
    private ApiClient apiClient;

    public OrderApi() {
        this(Configuration.getDefaultApiClient());
    }

    public OrderApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * Build call for performPaymentPostAuthorisation
     * @param contentType content type (required)
     * @param clientRequestId A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format. (required)
     * @param apiKey  (required)
     * @param timestamp Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins). (required)
     * @param messageSignature Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256  algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (required)
     * @param orderId Gateway order identifier as returned in the parameter orderId (required)
     * @param payload  (required)
     * @param storeId an optional outlet id for clients that support multiple store in the same developer app (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call performPaymentPostAuthorisationCall(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = payload;

        // create path and map variables
        String localVarPath = "/v1/orders/{order-id}/postauth"
            .replaceAll("\\{" + "order-id" + "\\}", apiClient.escapeString(orderId.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (storeId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("storeId", storeId));

        Map localVarHeaderParams = new HashMap();
        if (contentType != null)
        localVarHeaderParams.put("Content-Type", apiClient.parameterToString(contentType));
        if (clientRequestId != null)
        localVarHeaderParams.put("Client-Request-Id", apiClient.parameterToString(clientRequestId));
        if (apiKey != null)
        localVarHeaderParams.put("Api-Key", apiClient.parameterToString(apiKey));
        if (timestamp != null)
        localVarHeaderParams.put("Timestamp", apiClient.parameterToString(timestamp));
        if (messageSignature != null)
        localVarHeaderParams.put("Message-Signature", apiClient.parameterToString(messageSignature));

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] {  };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call performPaymentPostAuthorisationValidateBeforeCall(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'contentType' is set
        if (contentType == null) {
            throw new ApiException("Missing the required parameter 'contentType' when calling performPaymentPostAuthorisation(Async)");
        }
        
        // verify the required parameter 'clientRequestId' is set
        if (clientRequestId == null) {
            throw new ApiException("Missing the required parameter 'clientRequestId' when calling performPaymentPostAuthorisation(Async)");
        }
        
        // verify the required parameter 'apiKey' is set
        if (apiKey == null) {
            throw new ApiException("Missing the required parameter 'apiKey' when calling performPaymentPostAuthorisation(Async)");
        }
        
        // verify the required parameter 'timestamp' is set
        if (timestamp == null) {
            throw new ApiException("Missing the required parameter 'timestamp' when calling performPaymentPostAuthorisation(Async)");
        }
        
        // verify the required parameter 'messageSignature' is set
        if (messageSignature == null) {
            throw new ApiException("Missing the required parameter 'messageSignature' when calling performPaymentPostAuthorisation(Async)");
        }
        
        // verify the required parameter 'orderId' is set
        if (orderId == null) {
            throw new ApiException("Missing the required parameter 'orderId' when calling performPaymentPostAuthorisation(Async)");
        }
        
        // verify the required parameter 'payload' is set
        if (payload == null) {
            throw new ApiException("Missing the required parameter 'payload' when calling performPaymentPostAuthorisation(Async)");
        }
        

        com.squareup.okhttp.Call call = performPaymentPostAuthorisationCall(contentType, clientRequestId, apiKey, timestamp, messageSignature, orderId, payload, storeId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Use this to capture/complete a transaction. Partial postauths are allowed.
     * This can be used for postauth and partial postauths.
     * @param contentType content type (required)
     * @param clientRequestId A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format. (required)
     * @param apiKey  (required)
     * @param timestamp Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins). (required)
     * @param messageSignature Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256  algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (required)
     * @param orderId Gateway order identifier as returned in the parameter orderId (required)
     * @param payload  (required)
     * @param storeId an optional outlet id for clients that support multiple store in the same developer app (optional)
     * @return TransactionResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransactionResponse performPaymentPostAuthorisation(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId) throws ApiException {
        ApiResponse resp = performPaymentPostAuthorisationWithHttpInfo(contentType, clientRequestId, apiKey, timestamp, messageSignature, orderId, payload, storeId);
        return resp.getData();
    }

    /**
     * Use this to capture/complete a transaction. Partial postauths are allowed.
     * This can be used for postauth and partial postauths.
     * @param contentType content type (required)
     * @param clientRequestId A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format. (required)
     * @param apiKey  (required)
     * @param timestamp Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins). (required)
     * @param messageSignature Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256  algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (required)
     * @param orderId Gateway order identifier as returned in the parameter orderId (required)
     * @param payload  (required)
     * @param storeId an optional outlet id for clients that support multiple store in the same developer app (optional)
     * @return ApiResponse<TransactionResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse performPaymentPostAuthorisationWithHttpInfo(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId) throws ApiException {
        com.squareup.okhttp.Call call = performPaymentPostAuthorisationValidateBeforeCall(contentType, clientRequestId, apiKey, timestamp, messageSignature, orderId, payload, storeId, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Use this to capture/complete a transaction. Partial postauths are allowed. (asynchronously)
     * This can be used for postauth and partial postauths.
     * @param contentType content type (required)
     * @param clientRequestId A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format. (required)
     * @param apiKey  (required)
     * @param timestamp Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins). (required)
     * @param messageSignature Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256  algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (required)
     * @param orderId Gateway order identifier as returned in the parameter orderId (required)
     * @param payload  (required)
     * @param storeId an optional outlet id for clients that support multiple store in the same developer app (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call performPaymentPostAuthorisationAsync(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId, final ApiCallback callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = performPaymentPostAuthorisationValidateBeforeCall(contentType, clientRequestId, apiKey, timestamp, messageSignature, orderId, payload, storeId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for returnTransaction
     * @param contentType content type (required)
     * @param clientRequestId A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format. (required)
     * @param apiKey  (required)
     * @param timestamp Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins). (required)
     * @param messageSignature Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256  algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (required)
     * @param orderId Gateway order identifier as returned in the parameter orderId (required)
     * @param payload  (required)
     * @param storeId an optional outlet id for clients that support multiple store in the same developer app (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call returnTransactionCall(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = payload;

        // create path and map variables
        String localVarPath = "/v1/orders/{order-id}/return"
            .replaceAll("\\{" + "order-id" + "\\}", apiClient.escapeString(orderId.toString()));

        List localVarQueryParams = new ArrayList();
        List localVarCollectionQueryParams = new ArrayList();
        if (storeId != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("storeId", storeId));

        Map localVarHeaderParams = new HashMap();
        if (contentType != null)
        localVarHeaderParams.put("Content-Type", apiClient.parameterToString(contentType));
        if (clientRequestId != null)
        localVarHeaderParams.put("Client-Request-Id", apiClient.parameterToString(clientRequestId));
        if (apiKey != null)
        localVarHeaderParams.put("Api-Key", apiClient.parameterToString(apiKey));
        if (timestamp != null)
        localVarHeaderParams.put("Timestamp", apiClient.parameterToString(timestamp));
        if (messageSignature != null)
        localVarHeaderParams.put("Message-Signature", apiClient.parameterToString(messageSignature));

        Map localVarFormParams = new HashMap();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] {  };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call returnTransactionValidateBeforeCall(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'contentType' is set
        if (contentType == null) {
            throw new ApiException("Missing the required parameter 'contentType' when calling returnTransaction(Async)");
        }
        
        // verify the required parameter 'clientRequestId' is set
        if (clientRequestId == null) {
            throw new ApiException("Missing the required parameter 'clientRequestId' when calling returnTransaction(Async)");
        }
        
        // verify the required parameter 'apiKey' is set
        if (apiKey == null) {
            throw new ApiException("Missing the required parameter 'apiKey' when calling returnTransaction(Async)");
        }
        
        // verify the required parameter 'timestamp' is set
        if (timestamp == null) {
            throw new ApiException("Missing the required parameter 'timestamp' when calling returnTransaction(Async)");
        }
        
        // verify the required parameter 'messageSignature' is set
        if (messageSignature == null) {
            throw new ApiException("Missing the required parameter 'messageSignature' when calling returnTransaction(Async)");
        }
        
        // verify the required parameter 'orderId' is set
        if (orderId == null) {
            throw new ApiException("Missing the required parameter 'orderId' when calling returnTransaction(Async)");
        }
        
        // verify the required parameter 'payload' is set
        if (payload == null) {
            throw new ApiException("Missing the required parameter 'payload' when calling returnTransaction(Async)");
        }
        

        com.squareup.okhttp.Call call = returnTransactionCall(contentType, clientRequestId, apiKey, timestamp, messageSignature, orderId, payload, storeId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Use this to return/refund on the order. Partial returns are allowed.
     * This can be used for Returns and Partial Returns.
     * @param contentType content type (required)
     * @param clientRequestId A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format. (required)
     * @param apiKey  (required)
     * @param timestamp Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins). (required)
     * @param messageSignature Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256  algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (required)
     * @param orderId Gateway order identifier as returned in the parameter orderId (required)
     * @param payload  (required)
     * @param storeId an optional outlet id for clients that support multiple store in the same developer app (optional)
     * @return TransactionResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransactionResponse returnTransaction(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId) throws ApiException {
        ApiResponse resp = returnTransactionWithHttpInfo(contentType, clientRequestId, apiKey, timestamp, messageSignature, orderId, payload, storeId);
        return resp.getData();
    }

    /**
     * Use this to return/refund on the order. Partial returns are allowed.
     * This can be used for Returns and Partial Returns.
     * @param contentType content type (required)
     * @param clientRequestId A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format. (required)
     * @param apiKey  (required)
     * @param timestamp Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins). (required)
     * @param messageSignature Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256  algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (required)
     * @param orderId Gateway order identifier as returned in the parameter orderId (required)
     * @param payload  (required)
     * @param storeId an optional outlet id for clients that support multiple store in the same developer app (optional)
     * @return ApiResponse<TransactionResponse>
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse returnTransactionWithHttpInfo(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId) throws ApiException {
        com.squareup.okhttp.Call call = returnTransactionValidateBeforeCall(contentType, clientRequestId, apiKey, timestamp, messageSignature, orderId, payload, storeId, null, null);
        Type localVarReturnType = new TypeToken(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Use this to return/refund on the order. Partial returns are allowed. (asynchronously)
     * This can be used for Returns and Partial Returns.
     * @param contentType content type (required)
     * @param clientRequestId A client-generated ID for request tracking and signature creation, unique per request.  This is also used for idempotency control. We recommend 128-bit UUID format. (required)
     * @param apiKey  (required)
     * @param timestamp Epoch timestamp in milliseconds in the request from a client system. Used for Message Signature generation and time limit (5 mins). (required)
     * @param messageSignature Used to ensure the request has not been tampered with during transmission. The Message-Signature is the Base64 encoded HMAC hash (SHA256  algorithm with the API Secret as the key.) For more information, refer to the supporting documentation on the Developer Portal. (required)
     * @param orderId Gateway order identifier as returned in the parameter orderId (required)
     * @param payload  (required)
     * @param storeId an optional outlet id for clients that support multiple store in the same developer app (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call returnTransactionAsync(String contentType, String clientRequestId, String apiKey, Long timestamp, String messageSignature, String orderId, SecondaryTransaction payload, String storeId, final ApiCallback callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = returnTransactionValidateBeforeCall(contentType, clientRequestId, apiKey, timestamp, messageSignature, orderId, payload, storeId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy