Class PaymentApi

java.lang.Object
io.github.alejo2075.enzonasdk.client.PaymentApi

public class PaymentApi extends Object
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 Details

    • PaymentApi

      public PaymentApi(String consumerKey, String consumerSecret)
      Constructs a PaymentApi instance using provided consumer key and consumer secret. This constructor initializes an AuthClient for 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 - The ConfirmPaymentRequest object containing the necessary data for payment confirmation.
      Returns:
      A ConfirmPaymentResponse object containing the status of the confirmed payment.
      Throws:
      EnzonaException - If there is an issue with network communication or processing the request/response.
    • completePayment

      public CompletePaymentResponse completePayment(String transactionUuid) throws EnzonaException
      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 CompletePaymentResponse object containing details about the completed payment transaction.
      Throws:
      EnzonaException - If there is a problem with the network communication.
    • getRefundDetails

      public RefundDetailsResponse getRefundDetails(String transactionUuid) throws EnzonaException
      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 RefundDetailsResponse object containing detailed information about the requested refund.
      Throws:
      EnzonaException - If there is an issue with network communication or processing the request/response.
    • getRefundsList

      public RefundsListResponse getRefundsList(RefundsListRequest request) throws EnzonaException
      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 - The RefundsListRequest object containing all the necessary data to filter the refunds list.
      Returns:
      A RefundsListResponse object 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

      public CreatePaymentResponse createPayment(CreatePaymentRequest request) throws EnzonaException
      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 - The CreatePaymentRequest object containing all the necessary data to create a new payment.
      Returns:
      A CreatePaymentResponse object 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

      public PaymentsListResponse getPaymentsList(PaymentsListRequest request) throws EnzonaException
      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 - The PaymentsListRequest object containing all the necessary data to filter the payments list.
      Returns:
      A PaymentsListResponse object 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

      public PaymentDetailsResponse getPaymentDetails(String transactionUuid) throws EnzonaException
      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 PaymentDetailsResponse object containing detailed information about the specified payment transaction.
      Throws:
      EnzonaException - If there is an issue with network communication or processing the request/response.
    • performCheckout

      public CheckoutResponse performCheckout(String uuid) throws EnzonaException
      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 CheckoutResponse object 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 - The CreateReceiveCodeRequest object containing all the necessary data to create a receive code.
      Returns:
      A CreateReceiveCodeResponse object containing the response from the payment service.
      Throws:
      EnzonaException - If there is an issue with network communication or processing the request/response.
    • listRefunds

      public ListRefundsResponse listRefunds(ListRefundsRequest request) throws EnzonaException
      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 - The ListRefundsRequest object containing the transaction UUID and optional filtering criteria.
      Returns:
      A ListRefundsResponse containing 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

      public PayProductResponse payProduct(PayProductRequest request) throws EnzonaException
      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 - The PayProductRequest object containing all the necessary data for the payment transaction.
      Returns:
      A PayProductResponse object 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 - The CreatePaymentOrderRequest object containing all the necessary data for the payment order creation.
      Returns:
      A CreatePaymentOrderResponse object 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

      public CancelPaymentResponse cancelPayment(String transactionUuid) throws EnzonaException
      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 CancelPaymentResponse object 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 - The RefundPaymentRequest object containing all the necessary data for processing the refund.
      Returns:
      A RefundPaymentResponse object 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.