
Api.VoidApi Maven / Gradle / Ivy
/*
* CyberSource Merged Spec
* All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
*
* 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 Api;
import Invokers.ApiCallback;
import Invokers.ApiClient;
import Invokers.ApiException;
import Invokers.ApiResponse;
import Invokers.Configuration;
import Invokers.Pair;
import Invokers.ProgressRequestBody;
import Invokers.ProgressResponseBody;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.io.InputStream;
import Model.MitVoidRequest;
import Model.PtsV2PaymentsPost502Response;
import Model.PtsV2PaymentsVoidsPost201Response;
import Model.PtsV2PaymentsVoidsPost400Response;
import Model.VoidCaptureRequest;
import Model.VoidCreditRequest;
import Model.VoidPaymentRequest;
import Model.VoidRefundRequest;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import utilities.tracking.SdkTracker;
import com.cybersource.authsdk.util.mle.MLEUtility;
import com.cybersource.authsdk.util.mle.MLEException;
public class VoidApi {
private static Logger logger = LogManager.getLogger(VoidApi.class);
private ApiClient apiClient;
public VoidApi() {
this(Configuration.getDefaultApiClient());
}
public VoidApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Build call for mitVoid
* @param mitVoidRequest (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public okhttp3.Call mitVoidCall(MitVoidRequest mitVoidRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
SdkTracker sdkTracker = new SdkTracker();
Object localVarPostBody = sdkTracker.insertDeveloperIdTracker(mitVoidRequest, MitVoidRequest.class.getSimpleName(), apiClient.merchantConfig.getRunEnvironment(), apiClient.merchantConfig.getDefaultDeveloperId());
boolean isMLESupportedByCybsForApi = true;
if (MLEUtility.checkIsMLEForAPI(apiClient.merchantConfig, isMLESupportedByCybsForApi, "mitVoid,mitVoidAsync,mitVoidWithHttpInfo,mitVoidCall")) {
try {
localVarPostBody = MLEUtility.encryptRequestPayload(apiClient.merchantConfig, localVarPostBody);
} catch (MLEException e) {
logger.error("Failed to encrypt request body {}", e.getMessage(), e);
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}
// create path and map variables
String localVarPath = "/pts/v2/voids";
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/hal+json;charset=utf-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json;charset=utf-8"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
@Override
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
okhttp3.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, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call mitVoidValidateBeforeCall(MitVoidRequest mitVoidRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'mitVoidRequest' is set
if (mitVoidRequest == null) {
logger.error("Missing the required parameter 'mitVoidRequest' when calling mitVoid(Async)");
throw new ApiException("Missing the required parameter 'mitVoidRequest' when calling mitVoid(Async)");
}
okhttp3.Call call = mitVoidCall(mitVoidRequest, progressListener, progressRequestListener);
return call;
}
/**
* Timeout Void
* This is to void a previous payment, capture, refund, or credit that merchant does not receive a reply(Mostly due to timeout). To use this feature/API, make sure to pass unique value to field - clientReferenceInformation -> transactionId in your payment, capture, refund, or credit API call and use same transactionId in this API request payload to reverse the payment.
* @param mitVoidRequest (required)
* @return PtsV2PaymentsVoidsPost201Response
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public PtsV2PaymentsVoidsPost201Response mitVoid(MitVoidRequest mitVoidRequest) throws ApiException {
logger.info("CALL TO METHOD 'mitVoid' STARTED");
ApiResponse resp = mitVoidWithHttpInfo(mitVoidRequest);
logger.info("CALL TO METHOD 'mitVoid' ENDED");
return resp.getData();
}
/**
* Timeout Void
* This is to void a previous payment, capture, refund, or credit that merchant does not receive a reply(Mostly due to timeout). To use this feature/API, make sure to pass unique value to field - clientReferenceInformation -> transactionId in your payment, capture, refund, or credit API call and use same transactionId in this API request payload to reverse the payment.
* @param mitVoidRequest (required)
* @return ApiResponse<PtsV2PaymentsVoidsPost201Response>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse mitVoidWithHttpInfo(MitVoidRequest mitVoidRequest) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
okhttp3.Call call = mitVoidValidateBeforeCall(mitVoidRequest, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Timeout Void (asynchronously)
* This is to void a previous payment, capture, refund, or credit that merchant does not receive a reply(Mostly due to timeout). To use this feature/API, make sure to pass unique value to field - clientReferenceInformation -> transactionId in your payment, capture, refund, or credit API call and use same transactionId in this API request payload to reverse the payment.
* @param mitVoidRequest (required)
* @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 okhttp3.Call mitVoidAsync(MitVoidRequest mitVoidRequest, final ApiCallback callback) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
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);
}
};
}
okhttp3.Call call = mitVoidValidateBeforeCall(mitVoidRequest, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for voidCapture
* @param voidCaptureRequest (required)
* @param id The capture ID returned from a previous capture request. (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public okhttp3.Call voidCaptureCall(VoidCaptureRequest voidCaptureRequest, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
SdkTracker sdkTracker = new SdkTracker();
Object localVarPostBody = sdkTracker.insertDeveloperIdTracker(voidCaptureRequest, VoidCaptureRequest.class.getSimpleName(), apiClient.merchantConfig.getRunEnvironment(), apiClient.merchantConfig.getDefaultDeveloperId());
boolean isMLESupportedByCybsForApi = true;
if (MLEUtility.checkIsMLEForAPI(apiClient.merchantConfig, isMLESupportedByCybsForApi, "voidCapture,voidCaptureAsync,voidCaptureWithHttpInfo,voidCaptureCall")) {
try {
localVarPostBody = MLEUtility.encryptRequestPayload(apiClient.merchantConfig, localVarPostBody);
} catch (MLEException e) {
logger.error("Failed to encrypt request body {}", e.getMessage(), e);
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}
// create path and map variables
String localVarPath = "/pts/v2/captures/{id}/voids"
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/hal+json;charset=utf-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json;charset=utf-8"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
@Override
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
okhttp3.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, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call voidCaptureValidateBeforeCall(VoidCaptureRequest voidCaptureRequest, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'voidCaptureRequest' is set
if (voidCaptureRequest == null) {
logger.error("Missing the required parameter 'voidCaptureRequest' when calling voidCapture(Async)");
throw new ApiException("Missing the required parameter 'voidCaptureRequest' when calling voidCapture(Async)");
}
// verify the required parameter 'id' is set
if (id == null) {
logger.error("Missing the required parameter 'id' when calling voidCapture(Async)");
throw new ApiException("Missing the required parameter 'id' when calling voidCapture(Async)");
}
okhttp3.Call call = voidCaptureCall(voidCaptureRequest, id, progressListener, progressRequestListener);
return call;
}
/**
* Void a Capture
* Refund a capture API is only used, if you have requested Capture independenlty using [/pts/v2/payments/{id}/captures](https://developer.cybersource.com/api-reference-assets/index.html#payments_capture) API call. Include the capture ID in the POST request to cancel the capture.
* @param voidCaptureRequest (required)
* @param id The capture ID returned from a previous capture request. (required)
* @return PtsV2PaymentsVoidsPost201Response
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public PtsV2PaymentsVoidsPost201Response voidCapture(VoidCaptureRequest voidCaptureRequest, String id) throws ApiException {
logger.info("CALL TO METHOD 'voidCapture' STARTED");
ApiResponse resp = voidCaptureWithHttpInfo(voidCaptureRequest, id);
logger.info("CALL TO METHOD 'voidCapture' ENDED");
return resp.getData();
}
/**
* Void a Capture
* Refund a capture API is only used, if you have requested Capture independenlty using [/pts/v2/payments/{id}/captures](https://developer.cybersource.com/api-reference-assets/index.html#payments_capture) API call. Include the capture ID in the POST request to cancel the capture.
* @param voidCaptureRequest (required)
* @param id The capture ID returned from a previous capture request. (required)
* @return ApiResponse<PtsV2PaymentsVoidsPost201Response>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse voidCaptureWithHttpInfo(VoidCaptureRequest voidCaptureRequest, String id) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
okhttp3.Call call = voidCaptureValidateBeforeCall(voidCaptureRequest, id, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Void a Capture (asynchronously)
* Refund a capture API is only used, if you have requested Capture independenlty using [/pts/v2/payments/{id}/captures](https://developer.cybersource.com/api-reference-assets/index.html#payments_capture) API call. Include the capture ID in the POST request to cancel the capture.
* @param voidCaptureRequest (required)
* @param id The capture ID returned from a previous capture request. (required)
* @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 okhttp3.Call voidCaptureAsync(VoidCaptureRequest voidCaptureRequest, String id, final ApiCallback callback) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
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);
}
};
}
okhttp3.Call call = voidCaptureValidateBeforeCall(voidCaptureRequest, id, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for voidCredit
* @param voidCreditRequest (required)
* @param id The credit ID returned from a previous credit request. (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public okhttp3.Call voidCreditCall(VoidCreditRequest voidCreditRequest, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
SdkTracker sdkTracker = new SdkTracker();
Object localVarPostBody = sdkTracker.insertDeveloperIdTracker(voidCreditRequest, VoidCreditRequest.class.getSimpleName(), apiClient.merchantConfig.getRunEnvironment(), apiClient.merchantConfig.getDefaultDeveloperId());
boolean isMLESupportedByCybsForApi = true;
if (MLEUtility.checkIsMLEForAPI(apiClient.merchantConfig, isMLESupportedByCybsForApi, "voidCredit,voidCreditAsync,voidCreditWithHttpInfo,voidCreditCall")) {
try {
localVarPostBody = MLEUtility.encryptRequestPayload(apiClient.merchantConfig, localVarPostBody);
} catch (MLEException e) {
logger.error("Failed to encrypt request body {}", e.getMessage(), e);
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}
// create path and map variables
String localVarPath = "/pts/v2/credits/{id}/voids"
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/hal+json;charset=utf-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json;charset=utf-8"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
@Override
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
okhttp3.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, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call voidCreditValidateBeforeCall(VoidCreditRequest voidCreditRequest, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'voidCreditRequest' is set
if (voidCreditRequest == null) {
logger.error("Missing the required parameter 'voidCreditRequest' when calling voidCredit(Async)");
throw new ApiException("Missing the required parameter 'voidCreditRequest' when calling voidCredit(Async)");
}
// verify the required parameter 'id' is set
if (id == null) {
logger.error("Missing the required parameter 'id' when calling voidCredit(Async)");
throw new ApiException("Missing the required parameter 'id' when calling voidCredit(Async)");
}
okhttp3.Call call = voidCreditCall(voidCreditRequest, id, progressListener, progressRequestListener);
return call;
}
/**
* Void a Credit
* Include the credit ID in the POST request to cancel the credit.
* @param voidCreditRequest (required)
* @param id The credit ID returned from a previous credit request. (required)
* @return PtsV2PaymentsVoidsPost201Response
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public PtsV2PaymentsVoidsPost201Response voidCredit(VoidCreditRequest voidCreditRequest, String id) throws ApiException {
logger.info("CALL TO METHOD 'voidCredit' STARTED");
ApiResponse resp = voidCreditWithHttpInfo(voidCreditRequest, id);
logger.info("CALL TO METHOD 'voidCredit' ENDED");
return resp.getData();
}
/**
* Void a Credit
* Include the credit ID in the POST request to cancel the credit.
* @param voidCreditRequest (required)
* @param id The credit ID returned from a previous credit request. (required)
* @return ApiResponse<PtsV2PaymentsVoidsPost201Response>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse voidCreditWithHttpInfo(VoidCreditRequest voidCreditRequest, String id) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
okhttp3.Call call = voidCreditValidateBeforeCall(voidCreditRequest, id, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Void a Credit (asynchronously)
* Include the credit ID in the POST request to cancel the credit.
* @param voidCreditRequest (required)
* @param id The credit ID returned from a previous credit request. (required)
* @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 okhttp3.Call voidCreditAsync(VoidCreditRequest voidCreditRequest, String id, final ApiCallback callback) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
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);
}
};
}
okhttp3.Call call = voidCreditValidateBeforeCall(voidCreditRequest, id, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for voidPayment
* @param voidPaymentRequest (required)
* @param id The payment ID returned from a previous payment request. (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public okhttp3.Call voidPaymentCall(VoidPaymentRequest voidPaymentRequest, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
SdkTracker sdkTracker = new SdkTracker();
Object localVarPostBody = sdkTracker.insertDeveloperIdTracker(voidPaymentRequest, VoidPaymentRequest.class.getSimpleName(), apiClient.merchantConfig.getRunEnvironment(), apiClient.merchantConfig.getDefaultDeveloperId());
boolean isMLESupportedByCybsForApi = true;
if (MLEUtility.checkIsMLEForAPI(apiClient.merchantConfig, isMLESupportedByCybsForApi, "voidPayment,voidPaymentAsync,voidPaymentWithHttpInfo,voidPaymentCall")) {
try {
localVarPostBody = MLEUtility.encryptRequestPayload(apiClient.merchantConfig, localVarPostBody);
} catch (MLEException e) {
logger.error("Failed to encrypt request body {}", e.getMessage(), e);
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}
// create path and map variables
String localVarPath = "/pts/v2/payments/{id}/voids"
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/hal+json;charset=utf-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json;charset=utf-8"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
@Override
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
okhttp3.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, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call voidPaymentValidateBeforeCall(VoidPaymentRequest voidPaymentRequest, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'voidPaymentRequest' is set
if (voidPaymentRequest == null) {
logger.error("Missing the required parameter 'voidPaymentRequest' when calling voidPayment(Async)");
throw new ApiException("Missing the required parameter 'voidPaymentRequest' when calling voidPayment(Async)");
}
// verify the required parameter 'id' is set
if (id == null) {
logger.error("Missing the required parameter 'id' when calling voidPayment(Async)");
throw new ApiException("Missing the required parameter 'id' when calling voidPayment(Async)");
}
okhttp3.Call call = voidPaymentCall(voidPaymentRequest, id, progressListener, progressRequestListener);
return call;
}
/**
* Void a Payment
* Void a Payment API is only used, if you have requested Authorization and Capture together in [/pts/v2/payments](https://developer.cybersource.com/api-reference-assets/index.html#payments_payments) API call. Include the payment ID in the POST request to cancel the payment.
* @param voidPaymentRequest (required)
* @param id The payment ID returned from a previous payment request. (required)
* @return PtsV2PaymentsVoidsPost201Response
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public PtsV2PaymentsVoidsPost201Response voidPayment(VoidPaymentRequest voidPaymentRequest, String id) throws ApiException {
logger.info("CALL TO METHOD 'voidPayment' STARTED");
ApiResponse resp = voidPaymentWithHttpInfo(voidPaymentRequest, id);
logger.info("CALL TO METHOD 'voidPayment' ENDED");
return resp.getData();
}
/**
* Void a Payment
* Void a Payment API is only used, if you have requested Authorization and Capture together in [/pts/v2/payments](https://developer.cybersource.com/api-reference-assets/index.html#payments_payments) API call. Include the payment ID in the POST request to cancel the payment.
* @param voidPaymentRequest (required)
* @param id The payment ID returned from a previous payment request. (required)
* @return ApiResponse<PtsV2PaymentsVoidsPost201Response>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse voidPaymentWithHttpInfo(VoidPaymentRequest voidPaymentRequest, String id) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
okhttp3.Call call = voidPaymentValidateBeforeCall(voidPaymentRequest, id, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Void a Payment (asynchronously)
* Void a Payment API is only used, if you have requested Authorization and Capture together in [/pts/v2/payments](https://developer.cybersource.com/api-reference-assets/index.html#payments_payments) API call. Include the payment ID in the POST request to cancel the payment.
* @param voidPaymentRequest (required)
* @param id The payment ID returned from a previous payment request. (required)
* @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 okhttp3.Call voidPaymentAsync(VoidPaymentRequest voidPaymentRequest, String id, final ApiCallback callback) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
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);
}
};
}
okhttp3.Call call = voidPaymentValidateBeforeCall(voidPaymentRequest, id, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
* Build call for voidRefund
* @param voidRefundRequest (required)
* @param id The refund ID returned from a previous refund request. (required)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public okhttp3.Call voidRefundCall(VoidRefundRequest voidRefundRequest, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
SdkTracker sdkTracker = new SdkTracker();
Object localVarPostBody = sdkTracker.insertDeveloperIdTracker(voidRefundRequest, VoidRefundRequest.class.getSimpleName(), apiClient.merchantConfig.getRunEnvironment(), apiClient.merchantConfig.getDefaultDeveloperId());
boolean isMLESupportedByCybsForApi = true;
if (MLEUtility.checkIsMLEForAPI(apiClient.merchantConfig, isMLESupportedByCybsForApi, "voidRefund,voidRefundAsync,voidRefundWithHttpInfo,voidRefundCall")) {
try {
localVarPostBody = MLEUtility.encryptRequestPayload(apiClient.merchantConfig, localVarPostBody);
} catch (MLEException e) {
logger.error("Failed to encrypt request body {}", e.getMessage(), e);
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}
// create path and map variables
String localVarPath = "/pts/v2/refunds/{id}/voids"
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/hal+json;charset=utf-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
final String[] localVarContentTypes = {
"application/json;charset=utf-8"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
@Override
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
okhttp3.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, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call voidRefundValidateBeforeCall(VoidRefundRequest voidRefundRequest, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
// verify the required parameter 'voidRefundRequest' is set
if (voidRefundRequest == null) {
logger.error("Missing the required parameter 'voidRefundRequest' when calling voidRefund(Async)");
throw new ApiException("Missing the required parameter 'voidRefundRequest' when calling voidRefund(Async)");
}
// verify the required parameter 'id' is set
if (id == null) {
logger.error("Missing the required parameter 'id' when calling voidRefund(Async)");
throw new ApiException("Missing the required parameter 'id' when calling voidRefund(Async)");
}
okhttp3.Call call = voidRefundCall(voidRefundRequest, id, progressListener, progressRequestListener);
return call;
}
/**
* Void a Refund
* Include the refund ID in the POST request to cancel the refund.
* @param voidRefundRequest (required)
* @param id The refund ID returned from a previous refund request. (required)
* @return PtsV2PaymentsVoidsPost201Response
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public PtsV2PaymentsVoidsPost201Response voidRefund(VoidRefundRequest voidRefundRequest, String id) throws ApiException {
logger.info("CALL TO METHOD 'voidRefund' STARTED");
ApiResponse resp = voidRefundWithHttpInfo(voidRefundRequest, id);
logger.info("CALL TO METHOD 'voidRefund' ENDED");
return resp.getData();
}
/**
* Void a Refund
* Include the refund ID in the POST request to cancel the refund.
* @param voidRefundRequest (required)
* @param id The refund ID returned from a previous refund request. (required)
* @return ApiResponse<PtsV2PaymentsVoidsPost201Response>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse voidRefundWithHttpInfo(VoidRefundRequest voidRefundRequest, String id) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
okhttp3.Call call = voidRefundValidateBeforeCall(voidRefundRequest, id, null, null);
Type localVarReturnType = new TypeToken(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Void a Refund (asynchronously)
* Include the refund ID in the POST request to cancel the refund.
* @param voidRefundRequest (required)
* @param id The refund ID returned from a previous refund request. (required)
* @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 okhttp3.Call voidRefundAsync(VoidRefundRequest voidRefundRequest, String id, final ApiCallback callback) throws ApiException {
this.apiClient.setComputationStartTime(System.nanoTime());
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);
}
};
}
okhttp3.Call call = voidRefundValidateBeforeCall(voidRefundRequest, id, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy