patch https://api.chartmogul.com/v1/import/subscriptions/
Cancels a subscription that was generated from an imported invoice.
Examples
curl -X PATCH "https://api.chartmogul.com/v1/import/subscriptions/sub_e6bc5407-e258-4de0-bb43-61faaf062035" \
-u YOUR_API_KEY: \
-H "Content-Type: application/json" \
-d '{
"cancelled_at": "2016-01-15 00:00:00"
}'
curl -X PATCH "https://api.chartmogul.com/v1/import/subscriptions/sub_e6bc5407-e258-4de0-bb43-61faaf062035" \
-u YOUR_API_KEY: \
-H "Content-Type: application/json" \
-d '{
"cancellation_dates": ["2016-01-01T10:00:00.000Z", "2017-01-01T10:00:00.000Z"]
}'
customer = ChartMogul::Customer.all(external_id:"cus_0001").first
subscription = customer.subscriptions.last
subscription.cancel(Time.utc(2016, 1, 15))
subscription.update_cancellation_dates([Time.utc(2016, 1, 1), Time.utc(2017, 1, 1)])
ChartMogul.Subscription.cancel(config,
"sub_e6bc5407-e258-4de0-bb43-61faaf062035",
{ "cancelled_at": "2016-01-15 00:00:00" },
function(err, res) {
// asynchronously called
});
ChartMogul.Subscription.cancel(config,
"sub_e6bc5407-e258-4de0-bb43-61faaf062035",
{ "cancellation_dates": ["2016-01-01T10:00:00.000Z", "2017-01-01T10:00:00.000Z"] },
function(err, res) {
// asynchronously called
});
<?php
$canceldate = "2016-01-15 00:00:00";
$subscription = new ChartMogul\Subscription([
"uuid" => "sub_e6bc5407-e258-4de0-bb43-61faaf062035"
]);
$subscription->cancel($canceldate);
// Or set cancellation dates
$cancellationDates = ['2016-01-01T10:00:00.000Z', '2017-01-01T10:00:00.000Z']
$subscription = $subscriptions->last()->setCancellationDates($cancellationDates)
?>
api.CancelSubscription(
"sub_b8ba9b19-0d7d-401c-ad99-496104b435f1",
&cm.CancelSubscriptionParams{CancelledAt: "2016-01-15T00:00:00Z"})
api.CancelSubscription(
"sub_b8ba9b19-0d7d-401c-ad99-496104b435f1",
&cm.CancelSubscriptionParams{
CancellationDates: []string{
"2016-01-01T10:00:00.000Z", "2017-01-01T10:00:00.000Z"}})
chartmogul.Subscription.cancel(
config,
uuid="sub_00fbccd1-084d-4eec-9805-685ddafcd399",
data={"cancelled_at": "2016-01-15 00:00:00"}
chartmogul.Subscription.cancel(
config,
uuid="sub_00fbccd1-084d-4eec-9805-685ddafcd399",
data={"cancellation_dates":
["2016-01-01T10:00:00.000Z", "2017-01-01T10:00:00.000Z"] }
Result Format
{
"uuid": "sub_e6bc5407-e258-4de0-bb43-61faaf062035",
"external_id": "sub_0001",
"customer_uuid": "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7",
"plan_uuid": "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
"cancellation_dates": ["2016-01-15T00:00:00.000Z"],
"data_source_uuid": "ds_fef05d54-47b4-431b-aed2-eb6b9e545430"
}
{
"uuid": "sub_e6bc5407-e258-4de0-bb43-61faaf062035",
"external_id": "sub_0001",
"customer_uuid": "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7",
"plan_uuid": "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
"cancellation_dates": ["2016-01-01T10:00:00.000Z", "2017-01-01T10:00:00.000Z"],
"data_source_uuid": "ds_fef05d54-47b4-431b-aed2-eb6b9e545430"
}
#<ChartMogul::Subscription:0x007fb4991dae98
@uuid="sub_01e1b5d0-f7dd-441e-870e-62d6b7233a76",
@external_id="sub_0001",
@plan_uuid="pl_f364391a-c08b-4586-88db-d42ca5608360",
@cancellation_dates=[2016-01-15 00:00:00 UTC],
@data_source_uuid="ds_d138c0bd-6de1-4cf5-9a16-6f0d3bc540d7"
>
#<ChartMogul::Subscription:0x007fb4991dae98
@uuid="sub_01e1b5d0-f7dd-441e-870e-62d6b7233a76",
@external_id="sub_0001",
@plan_uuid="pl_f364391a-c08b-4586-88db-d42ca5608360",
@cancellation_dates=[2016-01-01 00:00:00 UTC, 2017-01-01 00:00:00 UTC],
@data_source_uuid="ds_d138c0bd-6de1-4cf5-9a16-6f0d3bc540d7"
>
{
"uuid": "sub_e6bc5407-e258-4de0-bb43-61faaf062035",
"external_id": "sub_0001",
"customer_uuid": "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7",
"plan_uuid": "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
"cancellation_dates": ["2016-01-15T00:00:00.000Z"],
"data_source_uuid": "ds_fef05d54-47b4-431b-aed2-eb6b9e545430"
}
{
"uuid": "sub_e6bc5407-e258-4de0-bb43-61faaf062035",
"external_id": "sub_0001",
"customer_uuid": "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7",
"plan_uuid": "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
"cancellation_dates": ["2016-01-01T10:00:00.000Z", "2017-01-01T10:00:00.000Z"],
"data_source_uuid": "ds_fef05d54-47b4-431b-aed2-eb6b9e545430"
}
<?php
ChartMogul\Subscription::__set_state(array(
"uuid" => "sub_e6bc5407-e258-4de0-bb43-61faaf062035",
"external_id" => "sub_0001",
"cancellation_dates" =>
array (
0 => "2016-01-15T00:00:00.000Z",
),
"plan_uuid" => "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
"data_source_uuid" => "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
));
ChartMogul\Subscription::__set_state(array(
"uuid" => "sub_e6bc5407-e258-4de0-bb43-61faaf062035",
"external_id" => "sub_0001",
"cancellation_dates" =>
array (
0 => "2016-01-01T00:00:00.000Z",
1 => "2017-01-01T00:00:00.000Z",
),
"plan_uuid" => "pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
"data_source_uuid" => "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
));
?>
(*chartmogul.Subscription)(0xc042004bd0)({
UUID: (string) (len=40) "sub_b8ba9b19-0d7d-401c-ad99-496104b435f1",
ExternalID: (string) (len=8) "sub_0001",
PlanUUID: (string) (len=39) "pl_8da1caec-ee0b-11e6-a4d9-dbe62a1a1694",
CustomerUUID: (string) (len=40) "cus_c0dc8d74-edfd-11e6-a357-832dddba822f",
DataSourceUUID: (string) (len=39) "ds_9bb53a1e-edfd-11e6-bf83-af49e978cb11",
CancellationDates: ([]string) (len=1) {
(string) (len=24) "2016-01-15T00:00:00.000Z"
}
})
(*chartmogul.Subscription)(0xc042004bd0)({
UUID: (string) (len=40) "sub_b8ba9b19-0d7d-401c-ad99-496104b435f1",
ExternalID: (string) (len=8) "sub_0001",
PlanUUID: (string) (len=39) "pl_8da1caec-ee0b-11e6-a4d9-dbe62a1a1694",
CustomerUUID: (string) (len=40) "cus_c0dc8d74-edfd-11e6-a357-832dddba822f",
DataSourceUUID: (string) (len=39) "ds_9bb53a1e-edfd-11e6-bf83-af49e978cb11",
CancellationDates: ([]string) (len=2) {
(string) (len=24) "2016-01-01T00:00:00.000Z",
(string) (len=24) "2017-01-01T00:00:00.000Z"
}
})
<Subscription{
cancellation_dates=[datetime.datetime(2016, 1, 15, 0, 0)],
customer_uuid='cus_c0dc8d74-edfd-11e6-a357-832dddba822f',
data_source_uuid='ds_9bb53a1e-edfd-11e6-bf83-af49e978cb11',
external_id='sub_0002',
plan_uuid='pl_8da1caec-ee0b-11e6-a4d9-dbe62a1a1694',
uuid='sub_00fbccd1-084d-4eec-9805-685ddafcd399'}>
<Subscription{
cancellation_dates=[
datetime.datetime(2016, 1, 1, 0, 0), datetime.datetime(2017, 1, 1, 0, 0)],
customer_uuid='cus_c0dc8d74-edfd-11e6-a357-832dddba822f',
data_source_uuid='ds_9bb53a1e-edfd-11e6-bf83-af49e978cb11',
external_id='sub_0002',
plan_uuid='pl_8da1caec-ee0b-11e6-a4d9-dbe62a1a1694',
uuid='sub_00fbccd1-084d-4eec-9805-685ddafcd399'}>
In the response, the JSON
object contains the following data:
uuid
- The UUID of thesubscription
object generated by ChartMogul.external_id
- The unique external identifier for this subscription, as specified by you.customer_uuid
- the UUID of the customer whose subscription this is.plan_uuid
- The UUID of theplan
object generated by ChartMogul.cancellation_dates
- An array ofcancelled_at
attributes specified by you. This is an array because a subscription may be re-activated and cancelled several times.data_source_uuid
- The UUID of the data source that this subscription plan belongs to.