Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Latest commit

 

History

History
317 lines (210 loc) · 11.5 KB

SubscriptionsApi.md

File metadata and controls

317 lines (210 loc) · 11.5 KB

SquareConnect.SubscriptionsApi

All URIs are relative to https://connect.squareup.com

Method HTTP request Description
cancelSubscription POST /v2/subscriptions/{subscription_id}/cancel CancelSubscription
createSubscription POST /v2/subscriptions CreateSubscription
listSubscriptionEvents GET /v2/subscriptions/{subscription_id}/events ListSubscriptionEvents
retrieveSubscription GET /v2/subscriptions/{subscription_id} RetrieveSubscription
searchSubscriptions POST /v2/subscriptions/search SearchSubscriptions
updateSubscription PUT /v2/subscriptions/{subscription_id} UpdateSubscription

cancelSubscription

Note: This endpoint is in beta.

CancelSubscriptionResponse cancelSubscription(subscriptionId)

CancelSubscription

Sets the `canceled_date` field to the end of the active billing period. After this date, the status changes from ACTIVE to CANCELED.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.SubscriptionsApi();

var subscriptionId = "subscriptionId_example"; // String | The ID of the subscription to cancel.

apiInstance.cancelSubscription(subscriptionId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
subscriptionId String The ID of the subscription to cancel.

Return type

CancelSubscriptionResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

createSubscription

Note: This endpoint is in beta.

CreateSubscriptionResponse createSubscription(body)

CreateSubscription

Creates a subscription for a customer to a subscription plan. If you provide a card on file in the request, Square charges the card for the subscription. Otherwise, Square bills an invoice to the customer's email address. The subscription starts immediately, unless the request includes the optional `start_date`. Each individual subscription is associated with a particular location.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.SubscriptionsApi();

var body = new SquareConnect.CreateSubscriptionRequest(); // CreateSubscriptionRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.createSubscription(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
body CreateSubscriptionRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CreateSubscriptionResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

listSubscriptionEvents

Note: This endpoint is in beta.

ListSubscriptionEventsResponse listSubscriptionEvents(subscriptionId, opts)

ListSubscriptionEvents

Lists all events for a specific subscription. In the current implementation, only `START_SUBSCRIPTION` and `STOP_SUBSCRIPTION` (when the subscription was canceled) events are returned.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.SubscriptionsApi();

var subscriptionId = "subscriptionId_example"; // String | The ID of the subscription to retrieve the events for.

var opts = { 
  'cursor': "cursor_example", // String | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query.  For more information, see [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pagination).
  'limit': 56 // Number | The upper limit on the number of subscription events to return  in the response.   Default: `200`
};
apiInstance.listSubscriptionEvents(subscriptionId, opts).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
subscriptionId String The ID of the subscription to retrieve the events for.
cursor String A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. For more information, see Pagination. [optional]
limit Number The upper limit on the number of subscription events to return in the response. Default: `200` [optional]

Return type

ListSubscriptionEventsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

retrieveSubscription

Note: This endpoint is in beta.

RetrieveSubscriptionResponse retrieveSubscription(subscriptionId)

RetrieveSubscription

Retrieves a subscription.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.SubscriptionsApi();

var subscriptionId = "subscriptionId_example"; // String | The ID of the subscription to retrieve.

apiInstance.retrieveSubscription(subscriptionId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
subscriptionId String The ID of the subscription to retrieve.

Return type

RetrieveSubscriptionResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

searchSubscriptions

Note: This endpoint is in beta.

SearchSubscriptionsResponse searchSubscriptions(body)

SearchSubscriptions

Searches for subscriptions. Results are ordered chronologically by subscription creation date. If the request specifies more than one location ID, the endpoint orders the result by location ID, and then by creation date within each location. If no locations are given in the query, all locations are searched. You can also optionally specify `customer_ids` to search by customer. If left unset, all customers associated with the specified locations are returned. If the request specifies customer IDs, the endpoint orders results first by location, within location by customer ID, and within customer by subscription creation date. For more information, see Retrieve subscriptions.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.SubscriptionsApi();

var body = new SquareConnect.SearchSubscriptionsRequest(); // SearchSubscriptionsRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.searchSubscriptions(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
body SearchSubscriptionsRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

SearchSubscriptionsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

updateSubscription

Note: This endpoint is in beta.

UpdateSubscriptionResponse updateSubscription(subscriptionId, body)

UpdateSubscription

Updates a subscription. You can set, modify, and clear the `subscription` field values.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.SubscriptionsApi();

var subscriptionId = "subscriptionId_example"; // String | The ID for the subscription to update.

var body = new SquareConnect.UpdateSubscriptionRequest(); // UpdateSubscriptionRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.updateSubscription(subscriptionId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
subscriptionId String The ID for the subscription to update.
body UpdateSubscriptionRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

UpdateSubscriptionResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json