### Installing SDK Library Locally (Maven) Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/README.md Executes the Maven install goal to build and install the Pagarme Java SDK library into the local Maven repository. The flags '-Dmaven.test.skip=true' and '-Dmaven.javadoc.skip=true' are used to skip tests and Javadoc generation during the installation process. ```bash mvn install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true ``` -------------------------------- ### Example JSON Response for Get Plan Item Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-plan-item-response.md This JSON snippet shows an example structure for the `GetPlanItemResponse` object received from the Pagarme API. It illustrates the typical fields like ID, name, status, creation timestamp, and update timestamp with example values and formatting. ```json { "id": "id8", "name": "name8", "status": "status0", "created_at": "2016-03-13T12:52:32.123Z", "updated_at": "2016-03-13T12:52:32.123Z" } ``` -------------------------------- ### JSON Example for Create Setup Request Payload Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/create-setup-request.md This snippet provides a sample JSON payload illustrating the structure and required fields for the `CreateSetupRequest` when creating a subscription setup. It includes nested details for amount, description, and various payment methods like credit card, debit card, boleto, and voucher. ```json { "amount": 160, "description": "description8", "payment": { "payment_method": "payment_method4", "credit_card": { "installments": 52, "statement_descriptor": "statement_descriptor8", "card": { "number": "number6", "holder_name": "holder_name2", "exp_month": 228, "exp_year": 68, "cvv": "cvv4" }, "card_id": "card_id4", "card_token": "card_token2" }, "debit_card": { "statement_descriptor": "statement_descriptor4", "card": { "number": "number6", "holder_name": "holder_name2", "exp_month": 228, "exp_year": 68, "cvv": "cvv4" }, "card_id": "card_id0", "card_token": "card_token6", "recurrence": false }, "boleto": { "retries": 226, "bank": "bank8", "instructions": "instructions2", "due_at": "2016-03-13T12:52:32.123Z", "billing_address": { "street": "street8", "number": "number4", "zip_code": "zip_code2", "neighborhood": "neighborhood4", "city": "city2", "state": "state6", "country": "country2", "complement": "complement6", "metadata": { "key0": "metadata5", "key1": "metadata6" }, "line_1": "line_18", "line_2": "line_26" }, "billing_address_id": "billing_address_id6", "nosso_numero": "nosso_numero0", "document_number": "document_number6", "statement_descriptor": "statement_descriptor0", "interest": { "days": 156, "type": "type0", "amount": 230 } }, "currency": "currency6", "voucher": { "statement_descriptor": "statement_descriptor2", "card_id": "card_id8", "card_token": "card_token8", "Card": { "number": "number8", "holder_name": "holder_name6", "exp_month": 240, "exp_year": 56, "cvv": "cvv8" }, "recurrency_cycle": "recurrency_cycle6" } } } ``` -------------------------------- ### Example JSON Payload for GetSetupResponse Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-setup-response.md This JSON snippet provides an example structure and typical values for the `GetSetupResponse` object, illustrating the format of the data returned when fetching subscription setup details. It shows the fields `id`, `description`, `amount`, and `status` with sample data. ```JSON { "id": "id6", "description": "description4", "amount": 152, "status": "status2" } ``` -------------------------------- ### Example Response Payload JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-checkout-card-installment-options-response.md Provides a sample JSON representation of the GetCheckoutCardInstallmentOptionsResponse object, illustrating the expected structure and data types for the `number` and `total` fields. This example helps developers visualize the response data format. ```json { "number": 40, "total": 188 } ``` -------------------------------- ### Example GetManagingPartnerResponse JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-managing-partner-response.md This JSON snippet provides an example structure and sample values for the `GetManagingPartnerResponse` object, illustrating the format expected when receiving data. ```json { "name": "name0", "email": "email6", "document": "document6", "type": "type0", "mother_name": "mother_name6" } ``` -------------------------------- ### Example Get Payment Origin Response JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-payment-origin-response.md Provides an example of the `GetPaymentOriginResponse` structure in JSON format, illustrating the expected keys and data types. ```json { "charge_id": "charge_id8", "brand_id": "brand_id4" } ``` -------------------------------- ### Get Charges Example Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/charges.md This example demonstrates how to list charges using the ChargesController. It calls the getCharges method with all optional parameters set to null, effectively fetching the first page of charges with default size, and prints the response or handles errors. ```java try { ListChargesResponse result = chargesController.getCharges(null, null, null, null, null, null, null, null, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example JSON for GetSubscriptionSplitResponse Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-subscription-split-response.md Provides a sample JSON payload demonstrating the structure and data types of the `GetSubscriptionSplitResponse` object. This example illustrates the `enabled` flag and a list of `rules`, each containing details about split amounts, recipients, and gateway options. ```JSON { "enabled": false, "rules": [ { "type": "type2", "amount": 118, "recipient": { "id": "id8", "name": "name8", "email": "email8", "document": "document8", "description": "description2" }, "gateway_id": "gateway_id2", "options": { "liable": false, "charge_processing_fee": false, "charge_remainder_fee": "charge_remainder_fee0" } }, { "type": "type2", "amount": 118, "recipient": { "id": "id8", "name": "name8", "email": "email8", "document": "document8", "description": "description2" }, "gateway_id": "gateway_id2", "options": { "liable": false, "charge_processing_fee": false, "charge_remainder_fee": "charge_remainder_fee0" } }, { "type": "type2", "amount": 118, "recipient": { "id": "id8", "name": "name8", "email": "email8", "document": "document8", "description": "description2" }, "gateway_id": "gateway_id2", "options": { "liable": false, "charge_processing_fee": false, "charge_remainder_fee": "charge_remainder_fee0" } } ] } ``` -------------------------------- ### Initializing Pagarme API Client (Java) Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/README.md Demonstrates how to initialize the Pagarme API client in Java using the Builder pattern. It shows how to configure HTTP client settings (like timeout), set a service referer name, and provide basic authentication credentials required to interact with the Pagarme API. ```java PagarmeApiSDKClient client = new PagarmeApiSDKClient.Builder() .httpClientConfig(configBuilder -> configBuilder .timeout(0)) .serviceRefererName("ServiceRefererName") .basicAuthCredentials(new BasicAuthModel.Builder( "BasicAuthUserName", "BasicAuthPassword" ) .build()) .build(); ``` -------------------------------- ### Sample JSON Response for Get Plan Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-plan-response.md Provides a partial example of the JSON payload returned by the Pagarme API when successfully retrieving a plan. It illustrates the basic structure and includes common fields like id, name, description, url, and statement_descriptor. ```json { "id": "id0", "name": "name0", "description": "description0", "url": "url4", "statement_descriptor": "statement_descriptor0" } ``` -------------------------------- ### Getting List of Subscription Items (Java) Example Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Provides an example of calling the `getSubscriptionItems` method to retrieve a list of items for a given subscription ID. This example calls the method with the required subscription ID and passes null for all optional filtering parameters, demonstrating a basic retrieval. Includes exception handling. ```java String subscriptionId = "subscription_id0"; try { ListSubscriptionItemsResponse result = subscriptionsController.getSubscriptionItems(subscriptionId, null, null, null, null, null, null, null, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example GetDeviceResponse JSON Structure Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-device-response.md An example JSON structure showing the typical format of the GetDeviceResponse object, illustrating the 'platform' field which represents the device's platform name. ```json { "platform": "platform8" } ``` -------------------------------- ### JSON Example for GetSplitOptionsResponse Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-split-options-response.md This JSON snippet provides an example representation of the `GetSplitOptionsResponse` data structure, showing typical values for its fields. ```JSON { "liable": false, "charge_processing_fee": false, "charge_remainder_fee": "charge_remainder_fee6" } ``` -------------------------------- ### Getting List of Subscriptions (Java) Example Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Demonstrates calling the `getSubscriptions` method to retrieve a list of all subscriptions without applying any filters. It passes null for all optional query parameters. The example includes basic exception handling for potential API and IO errors. ```java try { ListSubscriptionsResponse result = subscriptionsController.getSubscriptions(null, null, null, null, null, null, null, null, null, null, null, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example GetBalanceResponse JSON Structure Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-balance-response.md Provides a sample JSON structure illustrating the fields and nested objects within the `GetBalanceResponse` model. It shows typical data types and example values for currency, amounts, and the nested recipient object. ```JSON { "currency": "currency2", "available_amount": 96, "recipient": { "id": "id8", "name": "name8", "email": "email8", "document": "document8", "description": "description2" }, "transferred_amount": 142, "waiting_funds_amount": 174 } ``` -------------------------------- ### Example JSON Response for Get Checkout Pix Payment Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-checkout-pix-payment-response.md This JSON snippet provides an example structure and data for the `GetCheckoutPixPaymentResponse` object, illustrating the format of the `expires_at` and `additional_information` fields as received in a successful response. ```json { "expires_at": "2016-03-13T12:52:32.123Z", "additional_information": [ { "Name": "Name0", "Value": "Value2" }, { "Name": "Name0", "Value": "Value2" }, { "Name": "Name0", "Value": "Value2" } ] } ``` -------------------------------- ### Example GetCustomerResponse JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-customer-response.md Provides an example JSON structure representing the GetCustomerResponse object, illustrating common fields returned by the API. ```JSON { "id": "id4", "name": "name4", "email": "email2", "delinquent": false, "created_at": "2016-03-13T12:52:32.123Z" } ``` -------------------------------- ### Example Getting Token by ID - Pagar.me Java SDK Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/tokens.md Provides an example of how to retrieve a token using the `tokensController.getToken` method. It shows how to specify the token ID and public key and demonstrates calling the method within a try-catch block to handle potential API errors. ```java String id = "id0"; String publicKey = "public_key6"; try { GetTokenResponse result = tokensController.getToken(id, publicKey); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example Usage: Get Invoice in Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/invoices.md This example shows how to call the `getInvoice` method using a sample invoice ID. It demonstrates retrieving a specific invoice and includes error handling for API and IO exceptions. ```java String invoiceId = "invoice_id0"; try { GetInvoiceResponse result = invoicesController.getInvoice(invoiceId); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example Usage: Get Invoices in Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/invoices.md This example demonstrates a basic call to the `getInvoices` method, passing null for all optional filter and pagination parameters to retrieve the default list of invoices. It includes error handling. ```java try { ListInvoicesResponse result = invoicesController.getInvoices(null, null, null, null, null, null, null, null, null, null, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Sample Get Order Response JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-order-response.md This JSON snippet provides an example representation of the `GetOrderResponse` object, showing the typical structure and data types for some of its fields. ```json { "id": "id6", "code": "code4", "amount": 64, "currency": "currency6", "closed": false } ``` -------------------------------- ### Example Pagarme Subscription JSON Payload Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/create-subscription-request.md This snippet presents a comprehensive example of the JSON object structure expected by the Pagarme API for creating or representing a subscription. It includes nested data for customer details, payment methods (like credit card, boleto), pricing schemes, line items, shipping information, discounts, increments, and initial setup fees. ```json { "customer": { "name": "Tony Stark", "email": "email6", "document": "document6", "type": "type0", "address": { "street": "street6", "number": "number4", "zip_code": "zip_code0", "neighborhood": "neighborhood2", "city": "city6", "state": "state2", "country": "country0", "complement": "complement2", "metadata": { "key0": "metadata3", "key1": "metadata2", "key2": "metadata1" }, "line_1": "line_10", "line_2": "line_24" }, "metadata": { "key0": "metadata3" }, "phones": { "home_phone": { "country_code": "country_code0", "number": "number2", "area_code": "area_code0", "Type": "Type0" }, "mobile_phone": { "country_code": "country_code0", "number": "number8", "area_code": "area_code0", "Type": "Type0" } }, "code": "code8", "gender": "gender6", "document_type": "document_type8" }, "card": { "type": "credit", "number": "number6", "holder_name": "holder_name2", "exp_month": 228, "exp_year": 68, "cvv": "cvv4" }, "code": "code0", "payment_method": "payment_method8", "billing_type": "billing_type4", "statement_descriptor": "statement_descriptor2", "description": "description8", "currency": "currency2", "interval": "interval0", "interval_count": 220, "pricing_scheme": { "scheme_type": "scheme_type8", "price_brackets": [ { "start_quantity": 144, "price": 174, "end_quantity": 152, "overage_price": 166 }, { "start_quantity": 144, "price": 174, "end_quantity": 152, "overage_price": 166 }, { "start_quantity": 144, "price": 174, "end_quantity": 152, "overage_price": 166 } ], "price": 166, "minimum_price": 6, "percentage": 251.76 }, "items": [ { "description": "description2", "pricing_scheme": { "scheme_type": "scheme_type8", "price_brackets": [ { "start_quantity": 144, "price": 174, "end_quantity": 152, "overage_price": 166 }, { "start_quantity": 144, "price": 174, "end_quantity": 152, "overage_price": 166 }, { "start_quantity": 144, "price": 174, "end_quantity": 152, "overage_price": 166 } ], "price": 166, "minimum_price": 6, "percentage": 251.76 }, "id": "id8", "plan_item_id": "plan_item_id8", "discounts": [ { "value": 90.66, "discount_type": "discount_type2", "item_id": "item_id4", "cycles": 126, "description": "description4" } Произношение ], "name": "name8", "cycles": 214, "quantity": 22, "minimum_price": 222 } ], "shipping": { "amount": 52, "description": "description6", "recipient_name": "recipient_name2", "recipient_phone": "recipient_phone6", "address_id": "address_id6", "address": { "street": "street6", "number": "number4", "zip_code": "zip_code0", "neighborhood": "neighborhood2", "city": "city6", "state": "state2", "country": "country0", "complement": "complement2", "metadata": { "key0": "metadata3", "key1": "metadata2", "key2": "metadata1" }, "line_1": "line_10", "line_2": "line_24" }, "max_delivery_date": "2016-03-13T12:52:32.123Z", "estimated_delivery_date": "2016-03-13T12:52:32.123Z", "type": "type6" }, "discounts": [ { "value": 90.66, "discount_type": "discount_type2", "item_id": "item_id4", "cycles": 126, "description": "description4" } ], "metadata": { "key0": "metadata1" }, "increments": [ { "value": 252.86, "increment_type": "increment_type6", "item_id": "item_id6", "cycles": 34, "description": "description4" } ], "setup": { "amount": 110, "description": "description4", "payment": { "payment_method": "payment_method4", "credit_card": { "installments": 52, "statement_descriptor": "statement_descriptor8", "card": { "number": "number6", "holder_name": "holder_name2", "exp_month": 228, "exp_year": 68, "cvv": "cvv4" }, "card_id": "card_id4", "card_token": "card_token2" }, "debit_card": { "statement_descriptor": "statement_descriptor4", "card": { "number": "number6", "holder_name": "holder_name2", "exp_month": 228, "exp_year": 68, "cvv": "cvv4" }, "card_id": "card_id0", "card_token": "card_token6", "recurrence": false }, "boleto": { "retries": 226, "bank": "bank8", "instructions": "instructions2", "due_at": "2016-03-13T12:52:32.123Z", "billing_address": { "street": "street8", "number": "number4", "zip_code": "zip_code2", "neighborhood": "neighborhood4", "city": "city2", "state": "state6", "country": "country2", "complement": "complement6", "metadata": { "key0": "metadata5", "key1": "metadata6" }, "line_1": "line_18", "line_2": "line_26" }, "billing_address_id": "billing_address_id6", "nosso_numero": "nosso_numero0", "document_number": "document_number6", "statement_descriptor": "statement_descriptor0", "interest": { "days": 156, "type": "type0", "amount": 230 } }, "currency": "currency6", "voucher": { "statement_descriptor": "statement_descriptor2", "card_id": "card_id8", "card_token": "card_token8", "Card": { "number": "number8", "holder_name": "holder_name6", "exp_month": 240, "exp_year": 56, "cvv": "cvv8" }, "recurrency_cycle": "recurrency_cycle6" } } }, "plan_id": "plan_id4", "customer_id": "customer_id0", "card_id": "card_id2", "billing_day": 152 } ``` -------------------------------- ### Example Response Pagar.me JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-subscription-boleto-response.md This JSON snippet provides an example structure and values for the GetSubscriptionBoletoResponse object. It illustrates the format for interest, fine, and maximum days allowed for paying a past-due boleto, matching the object's fields. ```json { "interest": { "days": 2, "type": "percentage", "amount": 20 }, "fine": { "days": 2, "type": "flat", "amount": 10 }, "max_days_to_pay_past_due": 2 } ``` -------------------------------- ### Example: Get Discount by Id Pagarme API Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Demonstrates how to call the `getDiscountById` method using the Pagarme Java SDK. It requires a subscription ID and a discount ID and handles potential API or IO exceptions. ```Java String subscriptionId = "subscription_id0"; String discountId = "discountId0"; try { GetDiscountResponse result = subscriptionsController.getDiscountById(subscriptionId, discountId); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example JSON Response for Get Price Bracket Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-price-bracket-response.md This JSON snippet provides a sample representation of the `GetPriceBracketResponse` object, illustrating the expected structure and data types for its fields like start quantity, price, end quantity, and overage price when returned from the API. ```json { "start_quantity": 186, "price": 124, "end_quantity": 194, "overage_price": 208 } ``` -------------------------------- ### Checkout Card Installment Option Request JSON Example Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/create-checkout-card-installment-option-request.md This JSON snippet provides an example of the data structure required for the Create Checkout Card Installment Option Request. It demonstrates the 'number' field for the installment quantity and the 'total' field for the total amount, both expected as integers. ```json { "number": 154, "total": 46 } ``` -------------------------------- ### Listing Plans Example - Pagar.me Java SDK Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/plans.md Demonstrates how to retrieve a list of plans using the `plansController.getPlans` method. This example shows the basic call with null parameters and includes standard `try-catch` blocks for error handling, specifically `ApiException` and `IOException`. Requires an initialized `plansController`. ```Java try { ListPlansResponse result = plansController.getPlans(null, null, null, null, null, null, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example: Get Subscription Cycles Pagarme API Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Demonstrates calling the `getSubscriptionCycles` method to retrieve subscription cycles. It uses specified subscription ID, page number, and page size, including basic error handling. ```Java String subscriptionId = "subscription_id0"; String page = "page8"; String size = "size0"; try { ListCyclesResponse result = subscriptionsController.getSubscriptionCycles(subscriptionId, page, size); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Getting Single Subscription Item (Java) Example Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Provides an example of calling the `getSubscriptionItem` method to retrieve a single item by its ID within a specific subscription. It demonstrates passing the required subscription and item IDs to the controller method and includes basic exception handling. ```java String subscriptionId = "subscription_id0"; String itemId = "item_id0"; try { GetSubscriptionItemResponse result = subscriptionsController.getSubscriptionItem(subscriptionId, itemId); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Initializing Pagarme API Client with Configuration - Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/client.md Demonstrates how to initialize the Pagarme API SDK client using its builder pattern. It shows how to configure the HTTP client (setting timeout), set a service referer name, and provide basic authentication credentials. ```java PagarmeApiSDKClient client = new PagarmeApiSDKClient.Builder() .httpClientConfig(configBuilder -> configBuilder .timeout(0)) .serviceRefererName("ServiceRefererName") .basicAuthCredentials(new BasicAuthModel.Builder( "BasicAuthUserName", "BasicAuthPassword" ) .build()) .build(); ``` -------------------------------- ### Example Get Shipping Response JSON Structure Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-shipping-response.md This JSON snippet provides an example representation of the `GetShippingResponse` object, illustrating the typical structure and field names returned in a response. ```json { "amount": 214, "description": "description8", "recipient_name": "recipient_name6", "recipient_phone": "recipient_phone0", "address": { "id": "id6", "street": "street6", "number": "number4", "complement": "complement2", "zip_code": "zip_code0" } } ``` -------------------------------- ### Example JSON Response for Get Token Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-token-response.md This JSON snippet provides an example of the data structure returned by a successful get token operation. It shows the expected fields like id, type, created_at, expires_at, and a nested card object, illustrating the typical data format and values. ```json { "id": "id8", "type": "type2", "created_at": "2016-03-13T12:52:32.123Z", "expires_at": "expires_at2", "card": { "last_four_digits": "last_four_digits2", "holder_name": "holder_name2", "holder_document": "holder_document0", "exp_month": 228, "exp_year": 68 } } ``` -------------------------------- ### Example Usage for Creating Discount - Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Demonstrates calling the createDiscount method. It builds a CreateDiscountRequest object with necessary details (value, type, item ID) and invokes the controller method, including exception handling. ```java String subscriptionId = "subscription_id0"; CreateDiscountRequest request = new CreateDiscountRequest.Builder( 185.28D, "discount_type4", "item_id6" ) .build(); try { GetDiscountResponse result = subscriptionsController.createDiscount(subscriptionId, request, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example: Create Subscription Pagarme API Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Provides an example of constructing a complex `CreateSubscriptionRequest` object with various nested details (customer, card, items, shipping, discounts, increments) and calling the `createSubscription` method. Includes basic exception handling for API and IO errors. ```Java CreateSubscriptionRequest body = new CreateSubscriptionRequest.Builder( new CreateCustomerRequest.Builder( "Tony Stark", "email6", "document6", "type0", new CreateAddressRequest.Builder( "street6", "number4", "zip_code0", "neighborhood2", "city6", "state2", "country0", "complement2", "line_10", "line_24" ) .build(), new LinkedHashMap() {{ put("key0", "metadata3"); }}, new CreatePhonesRequest.Builder() .build(), "code8" ) .build(), new CreateCardRequest.Builder() .type("credit") .build(), "code4", "payment_method4", "billing_type0", "statement_descriptor6", "description4", "currency6", "interval6", 170, new CreatePricingSchemeRequest.Builder( "scheme_type8" ) .build(), Arrays.asList( new CreateSubscriptionItemRequest.Builder( "description2", new CreatePricingSchemeRequest.Builder( "scheme_type8" ) .build(), "id8", "plan_item_id8", Arrays.asList( new CreateDiscountRequest.Builder( 90.66D, "discount_type2", "item_id4" ) .build() ), "name8" ) .build() ), new CreateShippingRequest.Builder( 52, "description6", "recipient_name2", "recipient_phone6", "address_id6", new CreateAddressRequest.Builder( "street6", "number4", "zip_code0", "neighborhood2", "city6", "state2", "country0", "complement2", "line_10", "line_24" ) .build(), "type6" ) .build(), Arrays.asList( new CreateDiscountRequest.Builder( 90.66D, "discount_type2", "item_id4" ) .build() ), new LinkedHashMap() {{ put("key0", "metadata7"); put("key1", "metadata8"); }}, Arrays.asList( new CreateIncrementRequest.Builder( 252.86D, "increment_type6", "item_id6" ) .build() ) ) .build(); try { GetSubscriptionResponse result = subscriptionsController.createSubscription(body, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example Balance Operation Response JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-balance-operation-response.md This snippet shows an example of the JSON structure returned by the API for a Get Balance Operation response, illustrating the typical fields and their data types. ```json { "id": "id0", "status": "status2", "balance_amount": "balance_amount0", "balance_old_amount": "balance_old_amount8", "type": "type0" } ``` -------------------------------- ### Creating Subscription Usage (Java) Example Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Provides an example of calling the `createUsage` method to record usage for a subscription item. It requires the subscription and item IDs and demonstrates building a `CreateUsageRequest` object with details like quantity, description, and the usage timestamp. Includes exception handling. ```java String subscriptionId = "subscription_id0"; String itemId = "item_id0"; CreateUsageRequest body = new CreateUsageRequest.Builder( 156, "description4", DateTimeHelper.fromRfc8601DateTime("2016-03-13T12:52:32.123Z") ) .build(); try { GetUsageResponse result = subscriptionsController.createUsage(subscriptionId, itemId, body, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example JSON for Get Anticipation Limits Response Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-anticipation-limits-response.md This snippet provides a JSON example demonstrating the structure of the `GetAnticipationLimitsResponse` object. It shows the `max` and `min` limits, each containing the `amount` and `anticipation_fee`. ```json { "max": { "amount": 140, "anticipation_fee": 234 }, "min": { "amount": 34, "anticipation_fee": 60 } } ``` -------------------------------- ### Example JSON for Get Usage Report Response Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-usage-report-response.md This snippet shows a sample JSON payload representing the `GetUsageReportResponse` object, illustrating the expected format and data types for its URL fields. ```JSON { "url": "url2", "usage_report_url": "usage_report_url0", "grouped_report_url": "grouped_report_url0" } ``` -------------------------------- ### Example Usage for Creating Usage - Java Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/subscriptions.md Shows how to call the createAnUsage method using the subscription ID and item ID. The example includes exception handling for ApiException and IOException. ```java String subscriptionId = "subscription_id0"; String itemId = "item_id0"; try { GetUsageResponse result = subscriptionsController.createAnUsage(subscriptionId, itemId, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example List Plans Response JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/list-plans-response.md This JSON snippet provides an example structure of the response received when listing plans, demonstrating the 'data' array containing plan objects and the 'paging' object. ```json { "data": [ { "id": "id0", "name": "name0", "description": "description0", "url": "url4", "statement_descriptor": "statement_descriptor0" }, { "id": "id0", "name": "name0", "description": "description0", "url": "url4", "statement_descriptor": "statement_descriptor0" }, { "id": "id0", "name": "name0", "description": "description0", "url": "url4", "statement_descriptor": "statement_descriptor0" } ], "paging": { "total": 6, "previous": "previous2", "next": "next8" } } ``` -------------------------------- ### Example JSON for Get Phones Response Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-phones-response.md This JSON snippet provides an example representation of the `GetPhonesResponse` object, illustrating the expected structure including nested `GetPhoneResponse` objects for home and mobile phones. ```JSON { "home_phone": { "country_code": "country_code0", "number": "number2", "area_code": "area_code0" }, "mobile_phone": { "country_code": "country_code0", "number": "number8", "area_code": "area_code0" } } ``` -------------------------------- ### Updating Plan Example - Pagar.me Java SDK Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/plans.md Provides a practical example of updating a plan using the Pagar.me Java SDK. It illustrates the creation of an `UpdatePlanRequest` object using a builder and demonstrates calling the `plansController.updatePlan` method with a specific `planId` and the request object. Includes error handling via `try-catch`. ```Java String planId = "plan_id8"; UpdatePlanRequest request = new UpdatePlanRequest.Builder( "name6", "description6", Arrays.asList( 151, 152 ), "statement_descriptor6", "currency6", "interval4", 114, Arrays.asList( "payment_methods1", "payment_methods0", "payment_methods9" ), "billing_type0", "status8", false, Arrays.asList( 115 ), new LinkedHashMap() {{ put("key0", "metadata3"); }} ) .build(); try { GetPlanResponse result = plansController.updatePlan(planId, request, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example Get Transfer Target Response JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-transfer-target-response.md This JSON snippet provides an example structure and placeholder values for the GetTransferTargetResponse object. It illustrates the expected format containing `target_id` and `type` fields as described in the documentation. ```json { "target_id": "target_id0", "type": "type0" } ``` -------------------------------- ### Initializing Plans Controller - Pagarme Java SDK Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/plans.md Obtains an instance of the `PlansController` from the Pagarme client. This controller provides access to methods for interacting with plan-related API endpoints in the Pagarme service. ```java PlansController plansController = client.getPlansController(); ``` -------------------------------- ### Example JSON: Get Withdraw Target Response Structure Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-withdraw-target-response.md This JSON snippet provides an example of the structure and values for the `GetWithdrawTargetResponse` object when serialized. It demonstrates the format for the `target_id` and `type` fields typically received in a response. ```json { "target_id": "target_id4", "type": "type6" } ``` -------------------------------- ### Creating a Plan - Pagarme Java SDK Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/plans.md Creates a new plan in the system using the details provided in the `CreatePlanRequest` body. This request includes essential plan properties like name, description, items, payment methods, etc. An optional `idempotencyKey` is supported. ```java GetPlanResponse createPlan( final CreatePlanRequest body, final String idempotencyKey) ``` ```java CreatePlanRequest body = new CreatePlanRequest.Builder( "name6", "description4", "statement_descriptor6", Arrays.asList( new CreatePlanItemRequest.Builder( "name8", new CreatePricingSchemeRequest.Builder( "scheme_type8" ) .build(), "id8", "description2" ) .build() ), false, Arrays.asList( "payment_methods9" ), Arrays.asList( 207 ), "currency6", "interval6", 170, Arrays.asList( 201, 200 ), "billing_type0", new CreatePricingSchemeRequest.Builder( "scheme_type8" ) .build(), new LinkedHashMap() {{ put("key0", "metadata7"); put("key1", "metadata8"); }} ) .build(); try { GetPlanResponse result = plansController.createPlan(body, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example Get Order Item Response JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-order-item-response.md Illustrates the structure and typical field values of the GetOrderItemResponse object in JSON format, showing how a successful response for retrieving an order item might look. ```JSON { "id": "id8", "type": "type8", "description": "description8", "amount": 224, "quantity": 82 } ``` -------------------------------- ### Example Get Movement Object Fee Collection Response JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-movement-object-fee-collection-response.md This JSON object provides an example of the data structure returned by the API for a MovementObjectFeeCollection response, illustrating the fields and their potential values. ```json { "id": "id2", "status": "status4", "amount": "amount4", "created_at": "created_at0", "description": "description4", "payment_date": "payment_date4", "recipient_id": "recipient_id6" } ``` -------------------------------- ### Example JSON Get Discount Response Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-discount-response.md This JSON snippet provides an example of the structure and data format for a `GetDiscountResponse` object as returned by the API, illustrating typical fields like `id`, `value`, `discount_type`, `status`, and `created_at`. ```json { "id": "id4", "value": 139.66, "discount_type": "discount_type2", "status": "status6", "created_at": "2016-03-13T12:52:32.123Z" } ``` -------------------------------- ### Creating New Customer (Java) Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/controllers/customers.md Shows how to create a new customer by building a CreateCustomerRequest object with mandatory and optional fields (like name, email, document, type, address, metadata, phones, code) and invoking the createCustomer method. Includes error handling. ```java CreateCustomerRequest request = new CreateCustomerRequest.Builder( "Tony Stark", "email0", "document0", "type4", new CreateAddressRequest.Builder( "street6", "number4", "zip_code0", "neighborhood2", "city6", "state2", "country0", "complement2", "line_10", "line_24" ) .build(), new LinkedHashMap() {{ put("key0", "metadata3"); }}, new CreatePhonesRequest.Builder() .build(), "code4" ) .build(); try { GetCustomerResponse result = customersController.createCustomer(request, null); System.out.println(result); } catch (ApiException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Example Get Checkout Debit Card Payment Response JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-checkout-debit-card-payment-response.md An example of the expected JSON structure for the `GetCheckoutDebitCardPaymentResponse` object, showing typical values for the statement descriptor and nested authentication details. ```JSON { "statement_descriptor": "statement_descriptor6", "authentication": { "type": "type2", "threed_secure": { "mpi": "mpi0", "eci": "eci2", "cavv": "cavv8", "transaction_Id": "transaction_Id2", "success_url": "success_url4" } } } ``` -------------------------------- ### Example Get Split Response Object JSON Source: https://github.com/pagarme/pagarme-java-sdk/blob/main/doc/models/get-split-response.md This JSON snippet provides an example of the `GetSplitResponse` object structure with sample data. It illustrates how the different fields, including nested `recipient` and `options` objects, are represented in JSON format when returned by the API. ```json { "type": "type0", "amount": 252, "recipient": { "id": "id8", "name": "name8", "email": "email8", "document": "document8", "description": "description2" }, "gateway_id": "gateway_id0", "options": { "liable": false, "charge_processing_fee": false, "charge_remainder_fee": "charge_remainder_fee0" } } ```