ISubscriptionsApi subscriptionsApi = client.SubscriptionsApi;
SubscriptionsApi
- Create Subscription
- Bulk Swap Plan
- Search Subscriptions
- Retrieve Subscription
- Update Subscription
- Delete Subscription Action
- Change Billing Anchor Date
- Cancel Subscription
- List Subscription Events
- Pause Subscription
- Resume Subscription
- Swap Plan
Enrolls a customer in a subscription.
If you provide a card on file in the request, Square charges the card for
the subscription. Otherwise, Square sends 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.
For more information, see Create a subscription.
CreateSubscriptionAsync(
Models.CreateSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
CreateSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.CreateSubscriptionResponse>
Models.CreateSubscriptionRequest body = new Models.CreateSubscriptionRequest.Builder(
"S8GWD5R9QB376",
"CHFGVKYY8RSV93M5KCYTG4PN0G"
)
.IdempotencyKey("8193148c-9586-11e6-99f9-28cfe92138cf")
.PlanVariationId("6JHXF3B2CW3YKHDV4XEM674H")
.StartDate("2023-06-20")
.CardId("ccof:qy5x8hHGYsgLrp4Q4GB")
.Timezone("America/Los_Angeles")
.Source(
new Models.SubscriptionSource.Builder()
.Name("My Application")
.Build())
.Phases(
new List<Models.Phase>
{
new Models.Phase.Builder()
.Ordinal(0L)
.OrderTemplateId("U2NaowWxzXwpsZU697x7ZHOAnCNZY")
.Build(),
})
.Build();
try
{
CreateSubscriptionResponse result = await subscriptionsApi.CreateSubscriptionAsync(body);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Schedules a plan variation change for all active subscriptions under a given plan variation. For more information, see Swap Subscription Plan Variations.
BulkSwapPlanAsync(
Models.BulkSwapPlanRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
BulkSwapPlanRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.BulkSwapPlanResponse>
Models.BulkSwapPlanRequest body = new Models.BulkSwapPlanRequest.Builder(
"FQ7CDXXWSLUJRPM3GFJSJGZ7",
"6JHXF3B2CW3YKHDV4XEM674H",
"S8GWD5R9QB376"
)
.Build();
try
{
BulkSwapPlanResponse result = await subscriptionsApi.BulkSwapPlanAsync(body);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
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.
SearchSubscriptionsAsync(
Models.SearchSubscriptionsRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
SearchSubscriptionsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.SearchSubscriptionsResponse>
Models.SearchSubscriptionsRequest body = new Models.SearchSubscriptionsRequest.Builder()
.Query(
new Models.SearchSubscriptionsQuery.Builder()
.Filter(
new Models.SearchSubscriptionsFilter.Builder()
.CustomerIds(
new List<string>
{
"CHFGVKYY8RSV93M5KCYTG4PN0G",
})
.LocationIds(
new List<string>
{
"S8GWD5R9QB376",
})
.SourceNames(
new List<string>
{
"My App",
})
.Build())
.Build())
.Build();
try
{
SearchSubscriptionsResponse result = await subscriptionsApi.SearchSubscriptionsAsync(body);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Retrieves a specific subscription.
RetrieveSubscriptionAsync(
string subscriptionId,
string include = null)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription to retrieve. |
include |
string |
Query, Optional | A query parameter to specify related information to be included in the response. The supported query parameter values are: - actions : to include scheduled actions on the targeted subscription. |
Task<Models.RetrieveSubscriptionResponse>
string subscriptionId = "subscription_id0";
try
{
RetrieveSubscriptionResponse result = await subscriptionsApi.RetrieveSubscriptionAsync(subscriptionId);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Updates a subscription by modifying or clearing subscription
field values.
To clear a field, set its value to null
.
UpdateSubscriptionAsync(
string subscriptionId,
Models.UpdateSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription to update. |
body |
UpdateSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.UpdateSubscriptionResponse>
string subscriptionId = "subscription_id0";
Models.UpdateSubscriptionRequest body = new Models.UpdateSubscriptionRequest.Builder()
.Subscription(
new Models.Subscription.Builder()
.CanceledDate("canceled_date6")
.CardId("{NEW CARD ID}")
.Build())
.Build();
try
{
UpdateSubscriptionResponse result = await subscriptionsApi.UpdateSubscriptionAsync(
subscriptionId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Deletes a scheduled action for a subscription.
DeleteSubscriptionActionAsync(
string subscriptionId,
string actionId)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription the targeted action is to act upon. |
actionId |
string |
Template, Required | The ID of the targeted action to be deleted. |
Task<Models.DeleteSubscriptionActionResponse>
string subscriptionId = "subscription_id0";
string actionId = "action_id6";
try
{
DeleteSubscriptionActionResponse result = await subscriptionsApi.DeleteSubscriptionActionAsync(
subscriptionId,
actionId
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Changes the billing anchor date for a subscription.
ChangeBillingAnchorDateAsync(
string subscriptionId,
Models.ChangeBillingAnchorDateRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription to update the billing anchor date. |
body |
ChangeBillingAnchorDateRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.ChangeBillingAnchorDateResponse>
string subscriptionId = "subscription_id0";
Models.ChangeBillingAnchorDateRequest body = new Models.ChangeBillingAnchorDateRequest.Builder()
.MonthlyBillingAnchorDate(1)
.Build();
try
{
ChangeBillingAnchorDateResponse result = await subscriptionsApi.ChangeBillingAnchorDateAsync(
subscriptionId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Schedules a CANCEL
action to cancel an active subscription. This
sets the canceled_date
field to the end of the active billing period. After this date,
the subscription status changes from ACTIVE to CANCELED.
CancelSubscriptionAsync(
string subscriptionId)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription to cancel. |
Task<Models.CancelSubscriptionResponse>
string subscriptionId = "subscription_id0";
try
{
CancelSubscriptionResponse result = await subscriptionsApi.CancelSubscriptionAsync(subscriptionId);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Lists all events for a specific subscription.
ListSubscriptionEventsAsync(
string subscriptionId,
string cursor = null,
int? limit = null)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription to retrieve the events for. |
cursor |
string |
Query, Optional | When the total number of resulting subscription events exceeds the limit of a paged response, specify the cursor returned from a preceding response here to fetch the next set of results. If the cursor is unset, the response contains the last page of the results. For more information, see Pagination. |
limit |
int? |
Query, Optional | The upper limit on the number of subscription events to return in a paged response. |
Task<Models.ListSubscriptionEventsResponse>
string subscriptionId = "subscription_id0";
try
{
ListSubscriptionEventsResponse result = await subscriptionsApi.ListSubscriptionEventsAsync(subscriptionId);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Schedules a PAUSE
action to pause an active subscription.
PauseSubscriptionAsync(
string subscriptionId,
Models.PauseSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription to pause. |
body |
PauseSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.PauseSubscriptionResponse>
string subscriptionId = "subscription_id0";
Models.PauseSubscriptionRequest body = new Models.PauseSubscriptionRequest.Builder()
.Build();
try
{
PauseSubscriptionResponse result = await subscriptionsApi.PauseSubscriptionAsync(
subscriptionId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Schedules a RESUME
action to resume a paused or a deactivated subscription.
ResumeSubscriptionAsync(
string subscriptionId,
Models.ResumeSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription to resume. |
body |
ResumeSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.ResumeSubscriptionResponse>
string subscriptionId = "subscription_id0";
Models.ResumeSubscriptionRequest body = new Models.ResumeSubscriptionRequest.Builder()
.Build();
try
{
ResumeSubscriptionResponse result = await subscriptionsApi.ResumeSubscriptionAsync(
subscriptionId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Schedules a SWAP_PLAN
action to swap a subscription plan variation in an existing subscription.
For more information, see Swap Subscription Plan Variations.
SwapPlanAsync(
string subscriptionId,
Models.SwapPlanRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | The ID of the subscription to swap the subscription plan for. |
body |
SwapPlanRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
string subscriptionId = "subscription_id0";
Models.SwapPlanRequest body = new Models.SwapPlanRequest.Builder()
.NewPlanVariationId("FQ7CDXXWSLUJRPM3GFJSJGZ7")
.Phases(
new List<Models.PhaseInput>
{
new Models.PhaseInput.Builder(
0L
)
.OrderTemplateId("uhhnjH9osVv3shUADwaC0b3hNxQZY")
.Build(),
})
.Build();
try
{
SwapPlanResponse result = await subscriptionsApi.SwapPlanAsync(
subscriptionId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}