### Get Setup Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-setup-response.md This is an example of the JSON response object for getting the setup from a subscription. It includes fields like id, description, amount, and status. ```json { "id": "id6", "description": "description4", "amount": 152, "status": "status2" } ``` -------------------------------- ### Create Setup Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-setup-request.md This JSON object represents a complete setup request, including amount, description, and detailed payment information for various 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" } } } ``` -------------------------------- ### Get Subscriptions Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/subscriptions.md Shows how to fetch a list of all subscriptions, with options for filtering and pagination. Includes error handling. ```typescript try { const { result, ...httpResponse } = await subscriptionsController.getSubscriptions(); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { if (error instanceof ApiError) { const errors = error.result; // const { statusCode, headers } = error; } } ``` -------------------------------- ### Get Subscription Response Example (JSON) Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-subscription-response.md This JSON object demonstrates the structure of a typical response when fetching subscription details. It includes fields like ID, code, start date, interval, and nested objects for boleto information. ```json { "boleto": { "interest": { "days": 2, "type": "percentage", "amount": 20 }, "fine": { "days": 2, "type": "flat", "amount": 10 }, "max_days_to_pay_past_due": 2 }, "id": "id4", "code": "code2", "start_at": "2016-03-13T12:52:32.123Z", "interval": "interval2", "interval_count": 224 } ``` -------------------------------- ### Get Subscription Items Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/subscriptions.md Demonstrates how to retrieve items for a specific subscription. Handles potential API errors. ```typescript const subscriptionId = 'subscription_id0'; try { const { result, ...httpResponse } = await subscriptionsController.getSubscriptionItems(subscriptionId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { if (error instanceof ApiError) { const errors = error.result; // const { statusCode, headers } = error; } } ``` -------------------------------- ### Update Subscription Start at Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/update-subscription-start-at-request.md This JSON object represents the structure for updating a subscription's start date. Ensure the date is in ISO 8601 format. ```json { "start_at": "2016-03-13T12:52:32.123Z" } ``` -------------------------------- ### Get Anticipation Limit Response Example (JSON) Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-anticipation-limit-response.md Example of the GetAnticipationLimitResponse structure in JSON format. ```json { "amount": 6, "anticipation_fee": 88 } ``` -------------------------------- ### Get Customer Cards Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/customers.md Retrieves a list of all cards associated with a customer. You can specify pagination parameters like `page` and `size`. The example includes basic error handling. ```typescript const customerId = 'customer_id8'; try { const { result, ...httpResponse } = await customersController.getCards(customerId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { if (error instanceof ApiError) { const errors = error.result; // const { statusCode, headers } = error; } } ``` -------------------------------- ### Get Order Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-order-response.md This is an example of a JSON response when retrieving an order. It includes basic order details such as ID, code, amount, currency, and closed status. ```json { "id": "id6", "code": "code4", "amount": 64, "currency": "currency6", "closed": false } ``` -------------------------------- ### Get Plan Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-plan-response.md This JSON object demonstrates the structure of a typical response when fetching plan details. It includes common fields like ID, name, description, URL, and statement descriptor. ```json { "id": "id0", "name": "name0", "description": "description0", "url": "url4", "statement_descriptor": "statement_descriptor0" } ``` -------------------------------- ### Get Access Token Response Example (JSON) Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-access-token-response.md This JSON object represents a typical response when retrieving an access token. It includes details such as the token ID, code, status, creation timestamp, and associated customer information. ```json { "id": "id0", "code": "code8", "status": "status2", "created_at": "2016-03-13T12:52:32.123Z", "customer": { "id": "id0", "name": "name0", "email": "email6", "delinquent": false, "created_at": "2016-03-13T12:52:32.123Z" } } ``` -------------------------------- ### Get Checkout Card Installment Options Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-checkout-card-installment-options-response.md This JSON object represents a typical response for checkout card installment options, showing the number of installments and the total amount. ```json { "number": 40, "total": 188 } ``` -------------------------------- ### Install SDK Dependencies Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/README.md Run this command in the SDK root directory to install all necessary dependencies. ```bash npm install ``` -------------------------------- ### Get Price Bracket JSON Response Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-price-bracket-response.md Example of the JSON structure returned when a price bracket is successfully retrieved. This format includes details like start quantity, price, end quantity, and overage price. ```json { "start_quantity": 186, "price": 124, "end_quantity": 194, "overage_price": 208 } ``` -------------------------------- ### Create Access Token Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/customers.md Shows how to create an access token for a customer. This requires the customer ID and a `CreateAccessTokenRequest` object. Optional idempotency keys and request options can be provided. Error handling is demonstrated. ```typescript const customerId = 'customer_id8'; const request: CreateAccessTokenRequest = { }; try { const { result, ...httpResponse } = await customersController.createAccessToken( customerId, request ); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { if (error instanceof ApiError) { const errors = error.result; // const { statusCode, headers } = error; } } ``` -------------------------------- ### Get Checkout Credit Card Payment Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-checkout-credit-card-payment-response.md This JSON object represents a typical response for a credit card payment within the checkout flow. It includes details on the statement descriptor, installment options, and authentication information. ```json { "statementDescriptor": "statementDescriptor8", "installments": [ { "number": 164, "total": 16 } ], "authentication": { "type": "type2", "threed_secure": { "mpi": "mpi0", "eci": "eci2", "cavv": "cavv8", "transaction_Id": "transaction_Id2", "success_url": "success_url4" } } } ``` -------------------------------- ### Create and Manage Plans with Pagar.me Node.js SDK Source: https://context7.com/pagarme/pagarme-nodejs-sdk/llms.txt This example shows how to create a monthly subscription plan and list active plans. Define items, pricing, and billing details when creating a plan. ```typescript import { PlansController, CreatePlanRequest, UpdatePlanRequest, ApiError } from 'pagarmeapisdklib'; const plansController = new PlansController(client); // Create a monthly plan const body: CreatePlanRequest = { name: 'Pro Monthly', description: 'Monthly professional plan with all features', statementDescriptor: 'MYAPP PRO', items: [ { name: 'Pro Features', pricingScheme: { schemeType: 'unit', price: 4990 }, // R$49.90 id: 'item-pro-001', description: 'Full access to all features', }, ], shippable: false, paymentMethods: ['credit_card', 'boleto'], installments: [1], currency: 'BRL', interval: 'month', intervalCount: 1, billingType: 'prepaid', pricingScheme: { schemeType: 'unit', price: 4990 }, metadata: { tier: 'pro' }, }; try { const { result } = await plansController.createPlan(body); console.log('Plan created:', result.id, '| Interval:', result.interval); } catch (error) { if (error instanceof ApiError) { console.error(error.result); } } // List all active plans try { const { result } = await plansController.getPlans(1, 10, undefined, 'active', 'prepaid'); result.data?.forEach(p => console.log(p.id, p.name, p.interval)); } catch (error) { if (error instanceof ApiError) { console.error(error.result); } } ``` -------------------------------- ### Get Movement Object Fee Collection Response Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-movement-object-fee-collection-response.md Example of a GetMovementObjectFeeCollectionResponse object. ```json { "id": "id2", "status": "status4", "amount": "amount4", "created_at": "created_at0", "description": "description4", "payment_date": "payment_date4", "recipient_id": "recipient_id6" } ``` -------------------------------- ### Client Initialization Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/client.md Demonstrates how to initialize the Pagar.me Node.js SDK Client with various configuration options. ```APIDOC ## Client Initialization The API client can be initialized with the following parameters: * `serviceRefererName` (string): Identifier for the service. * `timeout` (number): Timeout for API calls. Defaults to `0`. * `httpClientOptions` (`Partial`): Stable configurable http client options. * `unstableHttpClientOptions` (`any`): Unstable configurable http client options. * `basicAuthCredentials` (`BasicAuthCredentials`): The credential object for basic authentication. ### Example ```ts const client = new Client({ basicAuthCredentials: { username: 'BasicAuthUserName', password: 'BasicAuthPassword' }, serviceRefererName: 'ServiceRefererName', timeout: 0, }); ``` ``` -------------------------------- ### CreateSetupRequest Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-setup-request.md Represents the request object for creating a subscription setup. It includes the amount, description, and payment details. ```APIDOC ## CreateSetupRequest ### Description Represents the request object for creating a subscription setup. It includes the amount, description, and payment details. ### Fields #### amount (number) - Required Setup amount. #### description (string) - Required Description of the setup. #### payment (CreatePaymentRequest) - Required Payment data for the setup. ### Example (JSON) ```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" } } } ``` ``` -------------------------------- ### Get Charge Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-charge-response.md This is an example of the GetChargeResponse object in JSON format. It shows the structure and potential values for various fields. ```json { "recurrency_cycle": "\"first\" or \"subsequent\"", "id": "id0", "code": "code8", "gateway_id": "gateway_id0", "amount": 164, "status": "status2" } ``` -------------------------------- ### Initialize Node.js Project Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/README.md Execute this command in your project's root directory to initialize a new Node.js project with a package.json file. ```bash npm init --y ``` -------------------------------- ### Get Increment by Id - Subscriptions Controller Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/subscriptions.md Example of how to retrieve an increment by its ID for a given subscription. This snippet only shows the function signature and does not include a full usage example. ```typescript async getIncrementById( subscriptionId: string, incrementId: string, requestOptions?: RequestOptions ): Promise> ``` -------------------------------- ### ListPlansResponse Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/list-plans-response.md An example of the JSON response structure for listing plans. ```APIDOC ## Example (as JSON) ```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" } } ``` ``` -------------------------------- ### Create Customer Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-customer-request.md Provides an example of the JSON structure for creating a new customer. Ensure all required fields are populated correctly. ```json { "name": "Tony Stark", "email": "email8", "document": "document8", "type": "type2", "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": "metadata5" }, "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": "code6", "gender": "gender8", "document_type": "document_type6" } ``` -------------------------------- ### Get Movement Object Refund Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-movement-object-refund-response.md Example of the GetMovementObjectRefundResponse object in JSON format. This shows the structure and typical values for a refund movement response. ```json { "id": "id2", "status": "status4", "amount": "amount4", "created_at": "created_at0", "fraud_coverage_fee": "fraud_coverage_fee0", "charge_fee_recipient_id": "charge_fee_recipient_id2", "bank_account_id": "bank_account_id2", "local_transaction_id": "local_transaction_id8", "updated_at": "updated_at8" } ``` -------------------------------- ### Create Subscription Item Request Example (JSON) Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-subscription-item-request.md This JSON object represents a complete request to create a subscription item. It includes all required fields and some optional ones, demonstrating the structure for pricing schemes and discounts. ```json { "description": "description0", "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": "id0", "plan_item_id": "plan_item_id0", "discounts": [ { "value": 90.66, "discount_type": "discount_type2", "item_id": "item_id4", "cycles": 126, "description": "description4" } ], "name": "name0", "cycles": 106, "quantity": 130, "minimum_price": 114 } ``` -------------------------------- ### Get Bank Transfer Transaction Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-bank-transfer-transaction-response.md Example of a GetBankTransferTransactionResponse object in JSON format. This includes fields inherited from GetTransactionResponse and bank transfer specific fields. ```json { "gateway_id": "gateway_id8", "amount": 40, "status": "status6", "success": false, "created_at": "2016-03-13T12:52:32.123Z", "url": "url2", "bank_tid": "bank_tid2", "bank": "bank6", "paid_at": "2016-03-13T12:52:32.123Z", "paid_amount": 176 } ``` -------------------------------- ### Create Card Options Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-card-options-request.md This JSON object demonstrates how to configure options for creating a card, specifically setting the `verify_card` field. ```json { "verify_card": false } ``` -------------------------------- ### Create Individual Registration JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-register-information-individual-request.md Provides an example of the JSON structure for creating individual registration information. This includes personal details, contact information, and address. ```json { "email": "email4", "document": "document6", "type": "type8", "site_url": "site_url4", "phone_numbers": [ { "ddd": "ddd4", "number": "number2", "type": "type0" }, { "ddd": "ddd4", "number": "number2", "type": "type0" } ], "name": "name6", "mother_name": "mother_name2", "birthdate": "birthdate0", "monthly_income": 206, "professional_occupation": "professional_occupation0", "address": { "street": "street6", "complementary": "complementary8", "street_number": "street_number6", "neighborhood": "neighborhood2", "city": "city6", "state": "state2", "zip_code": "zip_code0", "reference_point": "reference_point0" } } ``` -------------------------------- ### Get Balance Operation Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-balance-operation-response.md This JSON object represents a typical response for a Get Balance Operation. It includes fields like id, status, balance_amount, balance_old_amount, and type. ```json { "id": "id0", "status": "status2", "balance_amount": "balance_amount0", "balance_old_amount": "balance_old_amount8", "type": "type0" } ``` -------------------------------- ### Initialize Plans Controller Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/plans.md Instantiate the PlansController with an authenticated Pagar.me client. ```typescript const plansController = new PlansController(client); ``` -------------------------------- ### Initialize Customers Controller Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/customers.md Instantiate the CustomersController with a Pagar.me client instance. ```typescript const customersController = new CustomersController(client); ``` -------------------------------- ### Create Private Label Payment Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-private-label-payment-request.md Example of a JSON payload for creating a private label payment request. Includes card details, installments, capture settings, and statement descriptor. ```json { "installments": 1, "capture": true, "recurrency_cycle": "\"first\" or \"subsequent\"", "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" } ``` -------------------------------- ### Create Device Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-device-request.md Example of a JSON object used to create a device request. The platform field is optional. ```json { "platform": "platform8" } ``` -------------------------------- ### Create Subscription with Pagar.me Node.js SDK Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/subscriptions.md Demonstrates how to create a subscription using the Pagar.me Node.js SDK. It includes a comprehensive request body with customer, card, billing, item, shipping, and discount details. Error handling for API errors is also shown. ```typescript const body: CreateSubscriptionRequest = { customer: { name: 'Tony Stark', email: 'email6', document: 'document6', type: 'type0', address: { street: 'street6', number: 'number4', zipCode: 'zip_code0', neighborhood: 'neighborhood2', city: 'city6', state: 'state2', country: 'country0', complement: 'complement2', line1: 'line_10', line2: 'line_24', }, metadata: { 'key0': 'metadata3' }, phones: { }, code: 'code8', }, card: { type: 'credit', }, code: 'code4', paymentMethod: 'payment_method4', billingType: 'billing_type0', statementDescriptor: 'statement_descriptor6', description: 'description4', currency: 'currency6', interval: 'interval6', intervalCount: 170, pricingScheme: { schemeType: 'scheme_type8', }, items: [ { description: 'description2', pricingScheme: { schemeType: 'scheme_type8', }, id: 'id8', planItemId: 'plan_item_id8', discounts: [ { value: 90.66, discountType: 'discount_type2', itemId: 'item_id4', } ], name: 'name8', } ], shipping: { amount: 52, description: 'description6', recipientName: 'recipient_name2', recipientPhone: 'recipient_phone6', addressId: 'address_id6', address: { street: 'street6', number: 'number4', zipCode: 'zip_code0', neighborhood: 'neighborhood2', city: 'city6', state: 'state2', country: 'country0', complement: 'complement2', line1: 'line_10', line2: 'line_24', }, type: 'type6', }, discounts: [ { value: 90.66, discountType: 'discount_type2', itemId: 'item_id4', } ], metadata: { 'key0': 'metadata7', 'key1': 'metadata8' }, increments: [ { value: 252.86, incrementType: 'increment_type6', itemId: 'item_id6', } ], }; try { const { result, ...httpResponse } = await subscriptionsController.createSubscription(body); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { if (error instanceof ApiError) { const errors = error.result; // const { statusCode, headers } = error; } } ``` -------------------------------- ### Get Subscription Item - Subscriptions Controller Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/subscriptions.md Example of how to retrieve a specific subscription item. Handles potential API errors. ```typescript const subscriptionId = 'subscription_id0'; const itemId = 'item_id0'; try { const { result, ...httpResponse } = await subscriptionsController.getSubscriptionItem( subscriptionId, itemId ); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { if (error instanceof ApiError) { const errors = error.result; // const { statusCode, headers } = error; } } ``` -------------------------------- ### Client Initialization with Basic Auth Credentials Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/auth/basic-authentication.md Provide basic authentication credentials when initializing the client. Ensure the username and password fields are correctly populated. ```typescript const client = new Client({ basicAuthCredentials: { username: 'BasicAuthUserName', password: 'BasicAuthPassword' }, }); ``` -------------------------------- ### Get Location Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-location-response.md This JSON object represents a typical response for a location request, including latitude and longitude. ```json { "latitude": "latitude6", "longitude": "longitude4" } ``` -------------------------------- ### Create Plan Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-plan-request.md This JSON object represents a complete request to create a new plan. It includes all required fields such as name, description, items, payment methods, currency, interval, billing type, pricing scheme, and metadata. Optional fields like minimum price, cycles, quantity, and trial period days are also demonstrated. ```json { "name": "name0", "description": "description0", "statement_descriptor": "statement_descriptor0", "items": [ { "name": "name8", "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", "description": "description2", "cycles": 214, "quantity": 22 } ], "shippable": false, "payment_methods": [ "payment_methods5", "payment_methods4" ], "installments": [ 195, 196 ], "currency": "currency0", "interval": "interval8", "interval_count": 158, "billing_days": [ 159 ], "billing_type": "billing_type4", "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 }, "metadata": { "key0": "metadata7" }, "minimum_price": 156, "cycles": 164, "quantity": 144, "trial_period_days": 130 } ``` -------------------------------- ### GetCheckoutPixPaymentResponse Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-checkout-pix-payment-response.md An example of the GetCheckoutPixPaymentResponse object in JSON format. ```APIDOC ## Example (as JSON) { "expires_at": "2016-03-13T12:52:32.123Z", "additional_information": [ { "Name": "Name0", "Value": "Value2" }, { "Name": "Name0", "Value": "Value2" }, { "Name": "Name0", "Value": "Value2" } ] } ``` -------------------------------- ### Get Invoice Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/invoices.md Demonstrates how to retrieve an invoice by its ID using the invoices controller. Includes error handling for API-specific errors. ```typescript const invoiceId = 'invoice_id0'; try { const { result, ...httpResponse } = await invoicesController.getInvoice(invoiceId); // Get more response info... // const { statusCode, headers } = httpResponse; } catch (error) { if (error instanceof ApiError) { const errors = error.result; // const { statusCode, headers } = error; } } ``` -------------------------------- ### Get Payment Authentication Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-payment-authentication-response.md This JSON object represents a typical response for a payment authentication, including details for 3D-S. ```json { "type": "type2", "threed_secure": { "mpi": "mpi0", "eci": "eci2", "cavv": "cavv8", "transaction_Id": "transaction_Id2", "success_url": "success_url4" } } ``` -------------------------------- ### GetSetupResponse Structure Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-setup-response.md The GetSetupResponse object contains details about a subscription's setup. It includes fields like id, description, amount, and status. ```APIDOC ## GetSetupResponse ### Description Response object for getting the setup from a subscription. ### Fields #### Optional Fields - **id** (string | null | undefined) - The unique identifier for the setup. - **description** (string | null | undefined) - A description of the setup. - **amount** (number | null | undefined) - The amount associated with the setup. - **status** (string | null | undefined) - The current status of the setup. ### Example (as JSON) ```json { "id": "id6", "description": "description4", "amount": 152, "status": "status2" } ``` ``` -------------------------------- ### Create Subscription Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-subscription-request.md This JSON object represents a complete request to create a subscription. It includes details for payment methods like card and boleto, customer information, and plan details. Ensure all required fields are populated according to your specific subscription plan and payment gateway requirements. ```json { "payment": { "credit_card": { "installments": 1, "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 } ``` -------------------------------- ### Get Address Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-address-response.md This JSON object represents a typical response when retrieving address information. It includes common address fields. ```json { "id": "id2", "street": "street2", "number": "number0", "complement": "complement8", "zip_code": "zip_code6" } ``` -------------------------------- ### Update Pricing Scheme Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/update-pricing-scheme-request.md An example of the JSON structure for an UpdatePricingSchemeRequest. This includes the scheme type, an array of price brackets with their respective start quantity, price, end quantity, and overage price, as well as optional overall price, minimum price, and percentage. ```json { "scheme_type": "scheme_type0", "price_brackets": [ { "start_quantity": 144, "price": 174, "end_quantity": 152, "overage_price": 166 } ], "price": 162, "minimum_price": 2, "percentage": 62.28 } ``` -------------------------------- ### Create Customer Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/controllers/customers.md Creates a new customer in the system. ```APIDOC ## POST /customers ### Description Creates a new customer. ### Method POST ### Endpoint /customers ### Parameters #### Request Body - **request** (CreateCustomerRequest) - Required - Request for creating a customer #### Header Parameters - **idempotencyKey** (string) - Optional - Used for idempotency control. #### Request Options - **requestOptions** (RequestOptions) - Optional - Additional request options. ### Response #### Success Response (200 or 201) - **result** (GetCustomerResponse) - The response data. ### Request Example ```ts const request: CreateCustomerRequest = { name: 'Tony Stark', email: 'email0', document: 'document0', type: 'type4', address: { street: 'street6', number: 'number4', zipCode: 'zip_code0', neighborhood: 'neighborhood2', city: 'city6', state: 'state2', country: 'country0', complement: 'complement2', line1: 'line_10', line2: 'line_24', }, metadata: { 'key0': 'metadata3' }, phones: {}, code: 'code4', }; try { const { result, ...httpResponse } = await customersController.createCustomer(request); } catch (error) { if (error instanceof ApiError) { const errors = error.result; } } ``` ``` -------------------------------- ### Get Usage Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-usage-response.md This JSON object represents a typical response when fetching usage data. It includes identifiers, quantities, descriptions, and timestamps. ```json { "id": "id2", "quantity": 34, "description": "description2", "used_at": "2016-03-13T12:52:32.123Z", "created_at": "2016-03-13T12:52:32.123Z" } ``` -------------------------------- ### Create Usage Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-usage-request.md This JSON object represents a sample request for creating a usage. Ensure all required fields are present and optional fields are correctly formatted. ```json { "quantity": 224, "description": "description8", "used_at": "2016-03-13T12:52:32.123Z", "code": "code0", "group": "group0", "amount": 110 } ``` -------------------------------- ### Get Anticipation Limits Response Example (JSON) Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-anticipation-limits-response.md This JSON object represents a typical response for retrieving anticipation limits, including both maximum and minimum values. ```json { "max": { "amount": 140, "anticipation_fee": 234 }, "min": { "amount": 34, "anticipation_fee": 60 } } ``` -------------------------------- ### Get Withdraw Target Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-withdraw-target-response.md This JSON object represents a typical response for retrieving a withdraw target. It includes the target's ID and type. ```json { "target_id": "target_id4", "type": "type6" } ``` -------------------------------- ### Create Fine Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-fine-request.md Provides an example of the JSON structure for a fine request, specifying days, type, and amount. ```json { "days": 218, "type": "percentage" or "flat", "amount": 220 } ``` -------------------------------- ### Get Safety Pay Transaction Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-safety-pay-transaction-response.md This JSON object represents a typical response for a Safety Pay transaction, including gateway-specific and payment-related fields. ```json { "gateway_id": "gateway_id8", "amount": 40, "status": "status6", "success": false, "created_at": "2016-03-13T12:52:32.123Z", "url": "url8", "bank_tid": "bank_tid8", "paid_at": "2016-03-13T12:52:32.123Z", "paid_amount": 154 } ``` -------------------------------- ### Initialize Pagar.me Client Source: https://context7.com/pagarme/pagarme-nodejs-sdk/llms.txt Initialize the main client with your Pagar.me API key and service referer name. You can also create derived clients with different configurations, such as for sandbox environments. ```typescript import { Client } from 'pagarmeapisdklib'; const client = new Client({ basicAuthCredentials: { username: 'your_api_key', // Pagar.me secret key as the username password: '', // Password is typically left empty }, serviceRefererName: 'MyEcommerceApp', timeout: 30000, // 30 seconds }); // Create a derived client with different settings const sandboxClient = client.withConfiguration({ basicAuthCredentials: { username: 'sk_test_xxxx', password: '' }, timeout: 10000, }); ``` -------------------------------- ### Get Pricing Scheme Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-pricing-scheme-response.md Illustrates the structure of a GetPricingSchemeResponse object as it would appear in a JSON response. This can be used for testing or understanding the data format. ```json { "price": 182, "scheme_type": "scheme_type8", "price_brackets": [ { "start_quantity": 144, "price": 174, "end_quantity": 152, "overage_price": 166 } ], "minimum_price": 170, "percentage": 166.36 } ``` -------------------------------- ### Get Period Response JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-period-response.md This JSON object represents a typical response when retrieving period information. It includes details about the period itself and nested subscription information. ```json { "start_at": "2016-03-13T12:52:32.123Z", "end_at": "2016-03-13T12:52:32.123Z", "id": "id0", "billing_at": "2016-03-13T12:52:32.123Z", "subscription": { "id": "id4", "code": "code2", "start_at": "2016-03-13T12:52:32.123Z", "interval": "interval2", "interval_count": 234 } } ``` -------------------------------- ### Create Plan Item Request JSON Example Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/create-plan-item-request.md This JSON object represents a complete request to create a plan item, including its name, pricing scheme, ID, description, optional cycles, and quantity. ```json { "name": "name0", "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": "id0", "description": "description0", "cycles": 52, "quantity": 184 } ``` -------------------------------- ### Get Gateway Response Response Example (JSON) Source: https://github.com/pagarme/pagarme-nodejs-sdk/blob/main/doc/models/get-gateway-response-response.md This JSON object demonstrates the structure of a gateway response, including an error code and a list of associated error messages. ```json { "code": "code6", "errors": [ { "message": "message0" }, { "message": "message0" } ] } ```