Class PaymentApi
java.lang.Object
io.github.alejo2075.enzonasdk.client.PaymentApi
Handles payment-related operations for the Enzona API.
Provides functionality to manage payments, including creating, confirming, and completing transactions.
This class interacts with the Enzona API's payment endpoints by sending HTTP requests to manage payment transactions.
Each request is authenticated using an access token obtained via
AuthClient.
Instances of this class should be created by providing the consumer key and consumer secret which are used to
instantiate an AuthClient. This client is then used to authenticate requests made by this class.
Example usage:
PaymentApi paymentApi = new PaymentApi("consumerKey", "consumerSecret");
ConfirmPaymentRequest confirmRequest = new ConfirmPaymentRequest(...);
ConfirmPaymentResponse confirmResponse = paymentApi.confirmPayment("transactionUuid", confirmRequest);
-
Constructor Summary
ConstructorsConstructorDescriptionPaymentApi(String consumerKey, String consumerSecret) Constructs a PaymentApi instance using provided consumer key and consumer secret. -
Method Summary
Modifier and TypeMethodDescriptioncancelPayment(String transactionUuid) Cancels a payment transaction identified by the given UUID.completePayment(String transactionUuid) Completes a payment for the given transaction UUID.confirmPayment(String transactionUuid, ConfirmPaymentRequest request) Confirms a payment for a specified transaction using its unique identifier.createPayment(CreatePaymentRequest request) Creates a new payment with the specified details.Creates a payment order with the specified details.Creates a receive code for a vendor payment with specified details.getPaymentDetails(String transactionUuid) Retrieves the details of a specific payment transaction.getPaymentsList(PaymentsListRequest request) Retrieves a list of payments based on specified criteria.getRefundDetails(String transactionUuid) Retrieves the details of a refund for a specific transaction.getRefundsList(RefundsListRequest request) Retrieves a list of refunds based on provided criteria encapsulated within a request object.listRefunds(ListRefundsRequest request) Fetches a list of refunds associated with a specific payment transaction.payProduct(PayProductRequest request) Submits a payment for products added to a shopping cart.performCheckout(String uuid) Initiates the checkout process for a payment identified by the given UUID.refundPayment(String transactionUuid, RefundPaymentRequest request) Processes a refund for a specified payment transaction.
-
Constructor Details
-
PaymentApi
Constructs a PaymentApi instance using provided consumer key and consumer secret. This constructor initializes anAuthClientfor handling authentication.- Parameters:
consumerKey- The consumer key issued by Enzona for API authentication.consumerSecret- The consumer secret issued by Enzona for API authentication.
-
-
Method Details
-
confirmPayment
public ConfirmPaymentResponse confirmPayment(String transactionUuid, ConfirmPaymentRequest request) throws EnzonaException Confirms a payment for a specified transaction using its unique identifier. This method sends a POST request to the payment service to confirm a payment transaction.- Parameters:
transactionUuid- The unique identifier of the transaction to be confirmed.request- TheConfirmPaymentRequestobject containing the necessary data for payment confirmation.- Returns:
- A
ConfirmPaymentResponseobject containing the status of the confirmed payment. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
completePayment
Completes a payment for the given transaction UUID. This method sends a POST request to the payment service to mark a transaction as completed.- Parameters:
transactionUuid- The unique identifier of the transaction to be completed.- Returns:
- A
CompletePaymentResponseobject containing details about the completed payment transaction. - Throws:
EnzonaException- If there is a problem with the network communication.
-
getRefundDetails
Retrieves the details of a refund for a specific transaction. This method makes a GET request to the payment service, querying for details about a particular refund.- Parameters:
transactionUuid- The unique identifier of the refund transaction to retrieve details for.- Returns:
- A
RefundDetailsResponseobject containing detailed information about the requested refund. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
getRefundsList
Retrieves a list of refunds based on provided criteria encapsulated within a request object. This method sends a GET request to the payment service, querying for a list of refunds.- Parameters:
request- TheRefundsListRequestobject containing all the necessary data to filter the refunds list.- Returns:
- A
RefundsListResponseobject containing a list of refunds that match the query criteria specified in the request object. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
createPayment
Creates a new payment with the specified details. This method sends a POST request to the payment service and expects a response containing the status of the payment.- Parameters:
request- TheCreatePaymentRequestobject containing all the necessary data to create a new payment.- Returns:
- A
CreatePaymentResponseobject containing the detailed result of the payment creation process. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
getPaymentsList
Retrieves a list of payments based on specified criteria. This method sends a GET request to the payment service, querying for a list of payments.- Parameters:
request- ThePaymentsListRequestobject containing all the necessary data to filter the payments list.- Returns:
- A
PaymentsListResponseobject containing a list of payments that match the query criteria specified in the request. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
getPaymentDetails
Retrieves the details of a specific payment transaction. This method sends a GET request to the payment service, querying for detailed information about a payment.- Parameters:
transactionUuid- The unique identifier of the payment transaction for which details are being requested.- Returns:
- A
PaymentDetailsResponseobject containing detailed information about the specified payment transaction. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
performCheckout
Initiates the checkout process for a payment identified by the given UUID. This method sends a GET request to the payment service to initiate the checkout process.- Parameters:
uuid- The unique identifier of the checkout process to be initiated.- Returns:
- A
CheckoutResponseobject containing a message about the outcome of the checkout initiation process. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
createReceiveCode
public CreateReceiveCodeResponse createReceiveCode(CreateReceiveCodeRequest request) throws EnzonaException Creates a receive code for a vendor payment with specified details. This method sends a POST request to the payment service with details necessary for generating a receive code.- Parameters:
request- TheCreateReceiveCodeRequestobject containing all the necessary data to create a receive code.- Returns:
- A
CreateReceiveCodeResponseobject containing the response from the payment service. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
listRefunds
Fetches a list of refunds associated with a specific payment transaction. This method queries the payment service for refunds related to a given transaction.- Parameters:
request- TheListRefundsRequestobject containing the transaction UUID and optional filtering criteria.- Returns:
- A
ListRefundsResponsecontaining a list of refunds matching the criteria specified in the request. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
payProduct
Submits a payment for products added to a shopping cart. This method sends a POST request to the shop endpoint with detailed information required for making a payment.- Parameters:
request- ThePayProductRequestobject containing all the necessary data for the payment transaction.- Returns:
- A
PayProductResponseobject containing the outcome of the payment operation, including a status message. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
createPaymentOrder
public CreatePaymentOrderResponse createPaymentOrder(CreatePaymentOrderRequest request) throws EnzonaException Creates a payment order with the specified details. This method sends a POST request to the payment orders endpoint with the necessary information for creating a new payment order.- Parameters:
request- TheCreatePaymentOrderRequestobject containing all the necessary data for the payment order creation.- Returns:
- A
CreatePaymentOrderResponseobject containing the detailed information of the created payment order, including amount details, status code, creation date, transaction UUID, and more. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
cancelPayment
Cancels a payment transaction identified by the given UUID. This method sends a POST request to the payment service to cancel a payment transaction.- Parameters:
transactionUuid- The unique identifier of the payment transaction to be canceled.- Returns:
- A
CancelPaymentResponseobject containing the outcome of the cancellation operation, including status codes and descriptions. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-
refundPayment
public RefundPaymentResponse refundPayment(String transactionUuid, RefundPaymentRequest request) throws EnzonaException Processes a refund for a specified payment transaction. This method sends a POST request to the payment service to process a refund for a payment.- Parameters:
transactionUuid- The unique identifier of the payment transaction for which the refund is being processed.request- TheRefundPaymentRequestobject containing all the necessary data for processing the refund.- Returns:
- A
RefundPaymentResponseobject containing details about the processed refund, including the status code, parent payment UUID, and other information. - Throws:
EnzonaException- If there is an issue with network communication or processing the request/response.
-