@pagarme/sdk
v5.8.1
Published
Pagarme API
Downloads
453
Maintainers
Keywords
Readme
Getting started
Pagarme API
How to Build
The generated SDK relies on Node Package Manager (NPM) being available to resolve dependencies. If you don't already have NPM installed, please go ahead and follow instructions to install NPM from here. The SDK also requires Node to be installed. If Node isn't already installed, please install it from here
NPM is installed by default when Node is installed
To check if node and npm have been successfully installed, write the following commands in command prompt:
node --version
npm -version
Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):
npm install
This will install all dependencies in the node_modules
folder.
Once dependencies are resolved, you will need to move the folder PagarmeCoreApiLib
in to your node_modules
folder.
How to Use
The following section explains how to use the library in a new project.
1. Open Project Folder
Open an IDE/Text Editor for JavaScript like Sublime Text. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
Click on File
and select Open Folder
.
Select the folder of your SDK and click on Select Folder
to open it up in Sublime Text. The folder will become visible in the bar on the left.
2. Creating a Test File
Now right click on the folder name and select the New File
option to create a new test file. Save it as index.js
Now import the generated NodeJS library using the following lines of code:
var lib = require('lib');
Save changes.
3. Running The Test File
To run the index.js
file, open up the command prompt and navigate to the Path where the SDK folder resides. Type the following command to run the file:
node index.js
How to Test
These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run. Tests can be run in a number of ways:
Method 1 (Run all tests)
- Navigate to the root directory of the SDK folder from command prompt.
- Type
mocha --recursive
to run all the tests.
Method 2 (Run all tests)
- Navigate to the
../test/Controllers/
directory from command prompt. - Type
mocha *
to run all the tests.
Method 3 (Run specific controller's tests)
- Navigate to the
../test/Controllers/
directory from command prompt. - Type
mocha PagarmeCoreApiController
to run all the tests in that controller file.
To increase mocha's default timeout, you can change the
TEST_TIMEOUT
parameter's value inTestBootstrap.js
.
Initialization
Authentication
In order to setup authentication in the API client, you need the following information.
| Parameter | Description | |-----------|-------------| | basicAuthUserName | The username to use with basic authentication | | basicAuthPassword | The password to use with basic authentication |
API client can be initialized as following:
const lib = require('lib');
// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "basicAuthUserName"; // The username to use with basic authentication
lib.Configuration.basicAuthPassword = "basicAuthPassword"; // The password to use with basic authentication
Class Reference
List of Controllers
- SubscriptionsController
- OrdersController
- PlansController
- InvoicesController
- CustomersController
- ChargesController
- RecipientsController
- TokensController
- TransactionsController
- TransfersController
SubscriptionsController
Get singleton instance
The singleton instance of the SubscriptionsController
class can be accessed from the API Client.
var controller = lib.SubscriptionsController;
updateSubscriptionCard
Updates the credit card from a subscription
function updateSubscriptionCard(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| body | Required
| Request for updating a card |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateSubscriptionCardRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionCard(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
deleteUsage
Deletes a usage
function deleteUsage(subscriptionId, itemId, usageId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| itemId | Required
| The subscription item id |
| usageId | Required
| The usage id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var itemId = item_id;
var usageId = usage_id;
var idempotencyKey = 'idempotency-key';
controller.deleteUsage(subscriptionId, itemId, usageId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
createDiscount
Creates a discount
function createDiscount(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| body | Required
| Request for creating a discount |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new CreateDiscountRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.createDiscount(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
createAnUsage
Create Usage
function createAnUsage(subscriptionId, itemId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| itemId | Required
| Item id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var itemId = item_id;
var idempotencyKey = 'idempotency-key';
controller.createAnUsage(subscriptionId, itemId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getUsages
Lists all usages from a subscription item
function getUsages(subscriptionId, itemId, page, size, code, group, usedSince, usedUntil, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| itemId | Required
| The subscription item id |
| page | Optional
| Page number |
| size | Optional
| Page size |
| code | Optional
| Identification code in the client system |
| group | Optional
| Identification group in the client system |
| usedSince | Optional
| TODO: Add a parameter description |
| usedUntil | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var itemId = item_id;
var page = 150;
var size = 150;
var code = 'code';
var group = 'group';
var usedSince = date("D M d, Y G:i");
var usedUntil = date("D M d, Y G:i");
controller.getUsages(subscriptionId, itemId, page, size, code, group, usedSince, usedUntil, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateCurrentCycleStatus
UpdateCurrentCycleStatus
function updateCurrentCycleStatus(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription Id |
| body | Required
| Request for updating the end date of the subscription current status |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateCurrentCycleStatusRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateCurrentCycleStatus(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSubscriptionPaymentMethod
Updates the payment method from a subscription
function updateSubscriptionPaymentMethod(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| body | Required
| Request for updating the paymentmethod from a subscription |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateSubscriptionPaymentMethodRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionPaymentMethod(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
deleteDiscount
Deletes a discount
function deleteDiscount(subscriptionId, discountId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| discountId | Required
| Discount Id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var discountId = discount_id;
var idempotencyKey = 'idempotency-key';
controller.deleteDiscount(subscriptionId, discountId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getSubscriptionItems
Get Subscription Items
function getSubscriptionItems(subscriptionId, page, size, name, code, status, description, createdSince, createdUntil, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| page | Optional
| Page number |
| size | Optional
| Page size |
| name | Optional
| The item name |
| code | Optional
| Identification code in the client system |
| status | Optional
| The item statis |
| description | Optional
| The item description |
| createdSince | Optional
| Filter for item's creation date start range |
| createdUntil | Optional
| Filter for item's creation date end range |
Example Usage
var subscriptionId = subscription_id;
var page = 150;
var size = 150;
var name = 'name';
var code = 'code';
var status = 'status';
var description = 'description';
var createdSince = created_since;
var createdUntil = created_until;
controller.getSubscriptionItems(subscriptionId, page, size, name, code, status, description, createdSince, createdUntil, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
createSubscriptionItem
Creates a new Subscription item
function createSubscriptionItem(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| body | Required
| Request for creating a subscription item |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new CreateSubscriptionItemRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.createSubscriptionItem(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getSubscriptionItem
Get Subscription Item
function getSubscriptionItem(subscriptionId, itemId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription Id |
| itemId | Required
| Item id |
Example Usage
var subscriptionId = subscription_id;
var itemId = item_id;
controller.getSubscriptionItem(subscriptionId, itemId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSubscriptionItem
Updates a subscription item
function updateSubscriptionItem(subscriptionId, itemId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription Id |
| itemId | Required
| Item id |
| body | Required
| Request for updating a subscription item |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var itemId = item_id;
var body = new UpdateSubscriptionItemRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionItem(subscriptionId, itemId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getSubscriptions
Gets all subscriptions
function getSubscriptions(page, size, code, billingType, customerId, planId, cardId, status, nextBillingSince, nextBillingUntil, createdSince, createdUntil, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| page | Optional
| Page number |
| size | Optional
| Page size |
| code | Optional
| Filter for subscription's code |
| billingType | Optional
| Filter for subscription's billing type |
| customerId | Optional
| Filter for subscription's customer id |
| planId | Optional
| Filter for subscription's plan id |
| cardId | Optional
| Filter for subscription's card id |
| status | Optional
| Filter for subscription's status |
| nextBillingSince | Optional
| Filter for subscription's next billing date start range |
| nextBillingUntil | Optional
| Filter for subscription's next billing date end range |
| createdSince | Optional
| Filter for subscription's creation date start range |
| createdUntil | Optional
| Filter for subscriptions creation date end range |
Example Usage
var page = 150;
var size = 150;
var code = 'code';
var billingType = billing_type;
var customerId = customer_id;
var planId = plan_id;
var cardId = card_id;
var status = 'status';
var nextBillingSince = date("D M d, Y G:i");
var nextBillingUntil = date("D M d, Y G:i");
var createdSince = date("D M d, Y G:i");
var createdUntil = date("D M d, Y G:i");
controller.getSubscriptions(page, size, code, billingType, customerId, planId, cardId, status, nextBillingSince, nextBillingUntil, createdSince, createdUntil, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
createSubscription
Creates a new subscription
function createSubscription(body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| body | Required
| Request for creating a subscription |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var body = new CreateSubscriptionRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.createSubscription(body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
cancelSubscription
Cancels a subscription
function cancelSubscription(subscriptionId, idempotencyKey, body, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
| body | Optional
| Request for cancelling a subscription |
Example Usage
var subscriptionId = subscription_id;
var idempotencyKey = 'idempotency-key';
var body = new CreateCancelSubscriptionRequest({"key":"value"});
controller.cancelSubscription(subscriptionId, idempotencyKey, body, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getSubscription
Gets a subscription
function getSubscription(subscriptionId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
Example Usage
var subscriptionId = subscription_id;
controller.getSubscription(subscriptionId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
createIncrement
Creates a increment
function createIncrement(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| body | Required
| Request for creating a increment |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new CreateIncrementRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.createIncrement(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getDiscountById
GetDiscountById
function getDiscountById(subscriptionId, discountId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| discountId | Required
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var discountId = 'discountId';
controller.getDiscountById(subscriptionId, discountId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSubscriptionAffiliationId
UpdateSubscriptionAffiliationId
function updateSubscriptionAffiliationId(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| TODO: Add a parameter description |
| body | Required
| Request for updating a subscription affiliation id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateSubscriptionAffiliationIdRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionAffiliationId(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSubscriptionMetadata
Updates the metadata from a subscription
function updateSubscriptionMetadata(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| body | Required
| Request for updating the subscrption metadata |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateMetadataRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionMetadata(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
deleteIncrement
Deletes a increment
function deleteIncrement(subscriptionId, incrementId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| incrementId | Required
| Increment id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var incrementId = increment_id;
var idempotencyKey = 'idempotency-key';
controller.deleteIncrement(subscriptionId, incrementId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getIncrementById
GetIncrementById
function getIncrementById(subscriptionId, incrementId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription Id |
| incrementId | Required
| The increment Id |
Example Usage
var subscriptionId = subscription_id;
var incrementId = increment_id;
controller.getIncrementById(subscriptionId, incrementId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getSubscriptionCycles
GetSubscriptionCycles
function getSubscriptionCycles(subscriptionId, page, size, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription Id |
| page | Required
| Page number |
| size | Required
| Page size |
Example Usage
var subscriptionId = subscription_id;
var page = 'page';
var size = 'size';
controller.getSubscriptionCycles(subscriptionId, page, size, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
renewSubscription
RenewSubscription
function renewSubscription(subscriptionId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| TODO: Add a parameter description |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var idempotencyKey = 'idempotency-key';
controller.renewSubscription(subscriptionId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getDiscounts
GetDiscounts
function getDiscounts(subscriptionId, page, size, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| page | Required
| Page number |
| size | Required
| Page size |
Example Usage
var subscriptionId = subscription_id;
var page = 150;
var size = 150;
controller.getDiscounts(subscriptionId, page, size, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSubscriptionBillingDate
Updates the billing date from a subscription
function updateSubscriptionBillingDate(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| body | Required
| Request for updating the subscription billing date |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateSubscriptionBillingDateRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionBillingDate(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
deleteSubscriptionItem
Deletes a subscription item
function deleteSubscriptionItem(subscriptionId, subscriptionItemId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription id |
| subscriptionItemId | Required
| Subscription item id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var subscriptionItemId = subscription_item_id;
var idempotencyKey = 'idempotency-key';
controller.deleteSubscriptionItem(subscriptionId, subscriptionItemId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getIncrements
GetIncrements
function getIncrements(subscriptionId, page, size, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| page | Optional
| Page number |
| size | Optional
| Page size |
Example Usage
var subscriptionId = subscription_id;
var page = 150;
var size = 150;
controller.getIncrements(subscriptionId, page, size, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSubscriptionDueDays
Updates the boleto due days from a subscription
function updateSubscriptionDueDays(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription Id |
| body | Required
| TODO: Add a parameter description |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateSubscriptionDueDaysRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionDueDays(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSubscriptionStartAt
Updates the start at date from a subscription
function updateSubscriptionStartAt(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| body | Required
| Request for updating the subscription start date |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateSubscriptionStartAtRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionStartAt(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateLatestPeriodEndAt
UpdateLatestPeriodEndAt
function updateLatestPeriodEndAt(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| TODO: Add a parameter description |
| body | Required
| Request for updating the end date of the current signature cycle |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateCurrentCycleEndDateRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateLatestPeriodEndAt(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSubscriptionMiniumPrice
Atualização do valor mínimo da assinatura
function updateSubscriptionMiniumPrice(subscriptionId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| Subscription Id |
| body | Required
| Request da requisição com o valor mínimo que será configurado |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var body = new UpdateSubscriptionMinimumPriceRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateSubscriptionMiniumPrice(subscriptionId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getSubscriptionCycleById
GetSubscriptionCycleById
function getSubscriptionCycleById(subscriptionId, cycleId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription id |
| cycleId | Required
| TODO: Add a parameter description |
Example Usage
var subscriptionId = subscription_id;
var cycleId = 'cycleId';
controller.getSubscriptionCycleById(subscriptionId, cycleId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getUsageReport
GetUsageReport
function getUsageReport(subscriptionId, periodId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| subscriptionId | Required
| The subscription Id |
| periodId | Required
| The period Id |
Example Usage
var subscriptionId = subscription_id;
var periodId = period_id;
controller.getUsageReport(subscriptionId, periodId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateSplitSubscription
UpdateSplitSubscription
function updateSplitSubscription(id, body, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| id | Required
| Subscription's id |
| body | Required
| TODO: Add a parameter description |
Example Usage
var id = 'id';
var body = new UpdateSubscriptionSplitRequest({"key":"value"});
controller.updateSplitSubscription(id, body, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
OrdersController
Get singleton instance
The singleton instance of the OrdersController
class can be accessed from the API Client.
var controller = lib.OrdersController;
getOrders
Gets all orders
function getOrders(page, size, code, status, createdSince, createdUntil, customerId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| page | Optional
| Page number |
| size | Optional
| Page size |
| code | Optional
| Filter for order's code |
| status | Optional
| Filter for order's status |
| createdSince | Optional
| Filter for order's creation date start range |
| createdUntil | Optional
| Filter for order's creation date end range |
| customerId | Optional
| Filter for order's customer id |
Example Usage
var page = 150;
var size = 150;
var code = 'code';
var status = 'status';
var createdSince = date("D M d, Y G:i");
var createdUntil = date("D M d, Y G:i");
var customerId = customer_id;
controller.getOrders(page, size, code, status, createdSince, createdUntil, customerId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
createOrder
Creates a new Order
function createOrder(body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| body | Required
| Request for creating an order |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var body = new CreateOrderRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.createOrder(body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
deleteAllOrderItems
DeleteAllOrderItems
function deleteAllOrderItems(orderId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| orderId | Required
| Order Id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var orderId = 'orderId';
var idempotencyKey = 'idempotency-key';
controller.deleteAllOrderItems(orderId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
createOrderItem
CreateOrderItem
function createOrderItem(orderId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| orderId | Required
| Order Id |
| body | Required
| Order Item Model |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var orderId = 'orderId';
var body = new CreateOrderItemRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.createOrderItem(orderId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateOrderItem
UpdateOrderItem
function updateOrderItem(orderId, itemId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| orderId | Required
| Order Id |
| itemId | Required
| Item Id |
| body | Required
| Item Model |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var orderId = 'orderId';
var itemId = 'itemId';
var body = new UpdateOrderItemRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateOrderItem(orderId, itemId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
deleteOrderItem
DeleteOrderItem
function deleteOrderItem(orderId, itemId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| orderId | Required
| Order Id |
| itemId | Required
| Item Id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var orderId = 'orderId';
var itemId = 'itemId';
var idempotencyKey = 'idempotency-key';
controller.deleteOrderItem(orderId, itemId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getOrderItem
GetOrderItem
function getOrderItem(orderId, itemId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| orderId | Required
| Order Id |
| itemId | Required
| Item Id |
Example Usage
var orderId = 'orderId';
var itemId = 'itemId';
controller.getOrderItem(orderId, itemId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
closeOrder
CloseOrder
function closeOrder(id, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| id | Required
| Order Id |
| body | Required
| Update Order Model |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var id = 'id';
var body = new UpdateOrderStatusRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.closeOrder(id, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updateOrderMetadata
Updates the metadata from an order
function updateOrderMetadata(orderId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| orderId | Required
| The order id |
| body | Required
| Request for updating the order metadata |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var orderId = order_id;
var body = new UpdateMetadataRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updateOrderMetadata(orderId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
getOrder
Gets an order
function getOrder(orderId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| orderId | Required
| Order id |
Example Usage
var orderId = order_id;
controller.getOrder(orderId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
PlansController
Get singleton instance
The singleton instance of the PlansController
class can be accessed from the API Client.
var controller = lib.PlansController;
getPlan
Gets a plan
function getPlan(planId, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| planId | Required
| Plan id |
Example Usage
var planId = plan_id;
controller.getPlan(planId, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updatePlan
Updates a plan
function updatePlan(planId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| planId | Required
| Plan id |
| body | Required
| Request for updating a plan |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var planId = plan_id;
var body = new UpdatePlanRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updatePlan(planId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
deletePlan
Deletes a plan
function deletePlan(planId, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| planId | Required
| Plan id |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var planId = plan_id;
var idempotencyKey = 'idempotency-key';
controller.deletePlan(planId, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updatePlanMetadata
Updates the metadata from a plan
function updatePlanMetadata(planId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| planId | Required
| The plan id |
| body | Required
| Request for updating the plan metadata |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var planId = plan_id;
var body = new UpdateMetadataRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updatePlanMetadata(planId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |
updatePlanItem
Updates a plan item
function updatePlanItem(planId, planItemId, body, idempotencyKey, callback)
Parameters
| Parameter | Tags | Description |
|-----------|------|-------------|
| planId | Required
| Plan id |
| planItemId | Required
| Plan item id |
| body | Required
| Request for updating the plan item |
| idempotencyKey | Optional
| TODO: Add a parameter description |
Example Usage
var planId = plan_id;
var planItemId = plan_item_id;
var body = new UpdatePlanItemRequest({"key":"value"});
var idempotencyKey = 'idempotency-key';
controller.updatePlanItem(planId, planItemId, body, idempotencyKey, function(error, response, context) {
});
Errors
| Error Code | Error Description | |------------|-------------------| | 400 | Invalid request | | 401 | Invalid API key | | 404 | An informed resource was not found | | 412 | Business validation error | | 422 | Contract validation error | | 500 | Internal server error |