PHP code example of chartmogul / chartmogul-php
1. Go to this page and download the library: Download chartmogul/chartmogul-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chartmogul / chartmogul-php example snippets
ChartMogul\Configuration::getDefaultConfiguration()
->setApiKey('<YOUR_API_KEY>');
print_r(ChartMogul\Ping::ping()->data);
try {
$dataSources = ChartMogul\DataSource::all();
} catch(\ChartMogul\Exceptions\ForbiddenException $e){
// handle authentication exception
} catch(\ChartMogul\Exceptions\ChartMogulException $e){
echo $e->getResponse();
echo $e->getStatusCode();
}
$ds = $dataSources->first();
var_dump($ds->uuid); // access Datasource properties
$dsAsArray = $ds->toArray(); // convert to array
$ds->destroy();
$ds = ChartMogul\DataSource::create([
'name' => 'In-house Billing'
]);
ChartMogul\DataSource::retrieve($uuid);
ChartMogul\DataSource::retrieve($uuid, [
'with_processing_status' => true,
'with_auto_churn_subscription_setting' => true,
'with_invoice_handling_setting' => true
]);
ChartMogul\DataSource::all();
ChartMogul\DataSource::all([
'with_processing_status' => true,
'with_auto_churn_subscription_setting' => true,
'with_invoice_handling_setting' => true
]);
$dataSources = ChartMogul\DataSource::all();
$ds = $dataSources->last();
$ds->destroy();
ChartMogul\Customer::create([
"data_source_uuid" => $ds->uuid,
"external_id" => "cus_0003",
"name" => "Adam Smith",
"email" => "[email protected] ",
"country" => "US",
"city" => "New York",
"lead_created_at" => "2016-10-01T00:00:00.000Z",
"free_trial_started_at" => "2016-11-02T00:00:00.000Z"
]);
ChartMogul\Customer::all([
'page' => 1,
'data_source_uuid' => $ds->uuid
]);
ChartMogul\Customer::findByExternalId([
"data_source_uuid" => "ds_fef05d54-47b4-431b-aed2-eb6b9e545430",
"external_id" => "cus_0001"
]);
$cus = ChartMogul\Customer::all()->last();
$cus->destroy();
ChartMogul\Customer::retrieve($uuid);
ChartMogul\Customer::retrieve($uuid, null, [
'with_overrides' => true,
'attributes_with_history' => 'company,custom.channel'
]);
ChartMogul\Customer::search('[email protected] ');
ChartMogul\Customer::merge([
'customer_uuid' => $cus1->uuid
], [
'customer_uuid' => $cus2->uuid
]);
// alternatively:
ChartMogul\Customer::merge([
'external_id' => $cus1->external_id,
'data_source_uuid' => $ds->uuid
], [
'external_id' => $cus2->external_id,
'data_source_uuid' => $ds->uuid
]);
ChartMogul\Customer::unmerge(
$cus->uuid,
$cus->external_id,
$ds->uuid,
["tasks", "opportunities", "notes"]
);
$result = ChartMogul\Customer::update([
'customer_uuid' => $cus1->uuid
], [
'name' => 'New Name'
]);
ChartMogul\Customer::connectSubscriptions("cus_5915ee5a-babd-406b-b8ce-d207133fb4cb", [
"subscriptions" => [
[
"data_source_uuid" => "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
"external_id" => "d1c0c885-add0-48db-8fa9-0bdf5017d6b0",
],
[
"data_source_uuid" => "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
"external_id" => "9db5f4a1-1695-44c0-8bd4-de7ce4d0f1d4",
],
]
]);
use ChartMogul\Metrics\Customers\Subscription;
// Fetch customer subscriptions
$subscriptions = $customer->subscriptions();
// Connect subscriptions
Subscription::connect(
"ds_ade45e52-47a4-231a-1ed2-eb6b9e541213", // data source UUID
"cus_5915ee5a-babd-406b-b8ce-d207133fb4cb", // customer UUID
$subscriptions->entries // array of Subscription objects
);
$subscription1->connect("cus_5915ee5a-babd-406b-b8ce-d207133fb4cb", $subscriptions);
ChartMogul\Customer::disconnectSubscriptions("cus_5915ee5a-babd-406b-b8ce-d207133fb4cb", [
"subscriptions" => [
[
"data_source_uuid" => "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
"external_id" => "d1c0c885-add0-48db-8fa9-0bdf5017d6b0",
],
[
"data_source_uuid" => "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213",
"external_id" => "9db5f4a1-1695-44c0-8bd4-de7ce4d0f1d4",
],
]
]);
use ChartMogul\Metrics\Customers\Subscription;
// Fetch customer subscriptions
$subscriptions = $customer->subscriptions();
// Disconnect subscriptions
Subscription::disconnect(
"ds_ade45e52-47a4-231a-1ed2-eb6b9e541213", // data source UUID
"cus_5915ee5a-babd-406b-b8ce-d207133fb4cb", // customer UUID
$subscriptions->entries // array of Subscription objects
);
$subscription1->disconnect("cus_5915ee5a-babd-406b-b8ce-d207133fb4cb", $subscriptions);
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$customer->attributes;
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$tags = $customer->addTags("important", "Prio1");
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$tagsArray = ["important", "Prio1", "enterprise"];
$tags = $customer->addTags($tagsArray);
$customers = ChartMogul\Customer::search('[email protected] ');
foreach ($customers->entries as $customer) {
$customer->addTags('foo', 'bar', 'baz');
}
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$tags = $customer->removeTags("important", "Prio1");
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$tagsToRemove = ["important", "Prio1"];
$tags = $customer->removeTags($tagsToRemove);
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$custom = $customer->addCustomAttributes(
['type' => 'String', 'key' => 'channel', 'value' => 'Facebook'],
['type' => 'Integer', 'key' => 'age', 'value' => 8 ]
);
$customer = ChartMogul\Customer::retrieve($cus->uuid);
// Build attributes array dynamically
$attributes = [];
if (!empty($channel)) {
$attributes[] = ['type' => 'String', 'key' => 'channel', 'value' => $channel];
}
if (!empty($age)) {
$attributes[] = ['type' => 'Integer', 'key' => 'age', 'value' => $age];
}
$custom = $customer->addCustomAttributes($attributes);
$customers = ChartMogul\Customer::search('[email protected] ');
foreach ($customers->entries as $customer) {
$customer->addCustomAttributes(
['type' => 'String', 'key' => 'channel', 'value' => 'Facebook'],
['type' => 'Integer', 'key' => 'age', 'value' => 8 ]
);
}
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$custom = $customer->updateCustomAttributes(
['type' => 'String', 'key' => 'channel', 'value' => 'Twitter'],
['type' => 'Integer', 'key' => 'age', 'value' => 18]
);
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$attributeUpdates = [
['type' => 'String', 'key' => 'channel', 'value' => 'Twitter'],
['type' => 'Integer', 'key' => 'age', 'value' => 18]
];
$custom = $customer->updateCustomAttributes($attributeUpdates);
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$tags = $customer->removeCustomAttributes("age", "channel");
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$attributesToRemove = [
['key' => 'age'],
['key' => 'channel']
];
$tags = $customer->removeCustomAttributes($attributesToRemove);
$customer = ChartMogul\Customer::retrieve($cus->uuid);
// New key: add it first, then override it
$customer->addCustomAttributes(['type' => 'String', 'key' => 'channel', 'value' => 'Facebook']);
$result = $customer->updateCustomAttributesWithOverrides(
['channel' => 'Facebook'],
['custom' => ['channel' => true]]
);
// A key the account already knows can be written and overridden in one call
$result = $customer->addCustomAttributesWithOverrides(
[['type' => 'String', 'key' => 'channel', 'value' => 'Facebook']],
['custom' => ['channel' => true]]
);
$result = $customer->updateCustomAttributesWithOverrides(
['channel' => 'Twitter'],
['custom' => ['channel' => true]]
);
$result = $customer->removeCustomAttributesWithOverrides(
['age'],
['custom' => ['age' => false]]
);
// The by-email request takes the same direct shape, but each returned entry
// carries customer-shaped overrides (['attributes' => ['custom' => [...]]]),
// unlike the calls above
ChartMogul\Customer::addCustomAttributesByEmail(
'[email protected] ',
[['type' => 'String', 'key' => 'channel', 'value' => 'Facebook']],
null,
['custom' => ['channel' => true]]
);
$customer = ChartMogul\Customer::retrieve($cus->uuid);
$attributes = $customer->retrieveAttributes([
'with_overrides' => true,
'attributes_with_history' => 'custom.channel'
]);
$customer = ChartMogul\Customer::retrieve($uuid);
$contacts = $customer->contacts([
'cursor' => 'aabbccdd...'
]);
$customer = ChartMogul\Customer::retrieve($uuid);
$new_customer = $customer->createContact([
"data_source_uuid" => "ds_00000000-0000-0000-0000-000000000000",
"first_name" => "Adam",
"last_name" => "Smith",
]);
$customer = ChartMogul\Customer::retrieve($uuid);
$notes = $customer->entityNotes([
'cursor' => 'aabbccdd...'
]);
$customer = ChartMogul\Customer::retrieve($uuid);
$new_note = $customer->createEntityNote([
'type' => 'note',
'text' => 'This is a note'
]);
$customer = ChartMogul\Customer::retrieve($uuid);
$customer_notes = $customer->notes([
'cursor' => 'aabbccdd...'
]);
$customer = ChartMogul\Customer::retrieve($uuid);
$new_customer_note = $customer->createNote([
'type' => 'note',
'text' => 'This is a note'
]);
$customer = ChartMogul\Customer::retrieve($uuid);
$opportunities = $customer->opportunities([
'cursor' => 'aabbccdd...'
]);
$customer = ChartMogul\Customer::retrieve($uuid);
$new_opportunity = $customer->createOpportunity([
'owner' => '[email protected] ',
'pipeline' => 'Sales',
'pipeline_stage' => 'Qualified',
'estimated_close_date' => '2022-03-30',
'currency' => 'USD',
'amount_in_cents' => 10000,
'type' => 'one-time',
'forecast_category' => 'Best Case',
'win_likelihood' => 80,
'custom' => [{key: 'custom_key', value: 'custom_value'}]
]);
$customer = ChartMogul\Customer::retrieve($customer_uuid);
$tasks = $customer->tasks([
'cursor' => 'aabbccdd...'
]);
$customer = ChartMogul\Customer::retrieve($customer_uuid);
$new_task = $customer->createTask([
'assignee' => '[email protected] ',
'task_details' => 'This is some task details text.',
'due_date' => '2025-04-30T00:00:00Z',
'completed_at' => '2025-04-20T00:00:00Z',
]);
$customer_notes = ChartMogul\CustomerNote::all([
'customer_uuid' => $uuid,
'cursor' => 'aabbccdd...'
])
$customer_note = ChartMogul\CustomerNote::create([
'customer_uuid' => $uuid,
'type' => 'note',
'text' => 'This is a note'
])
$customer_note = ChartMogul\CustomerNote::retrieve($note_uuid)
$updated_customer_note = ChartMogul\CustomerNote::update([
'note_uuid' => $note_uuid
], [
'text' => 'This is a new note'
]);
$customer_note = ChartMogul\CustomerNote::retrieve($note_uuid)
$customer_note->destroy();
$notes = ChartMogul\EntityNote::all([
'customer_uuid' => $customer_uuid, // or 'contact_uuid' => $contact_uuid
'type' => 'note', // 'note' or 'call'
'author_email' => '[email protected] ',
'per_page' => 50,
'cursor' => 'aabbccdd...'
]);
$note = ChartMogul\EntityNote::create([
'customer_uuid' => $customer_uuid,
'type' => 'note',
'author_email' => '[email protected] ',
'text' => 'This is a note'
]);
$note = ChartMogul\EntityNote::create([
'associated_object_identifier' => [
'associated_object' => 'contact',
'method' => 'uuid',
'value' => $contact_uuid
],
'type' => 'call',
'call_duration' => 120,
'text' => 'Call with the contact'
]);
$note = ChartMogul\EntityNote::retrieve($note_uuid);
$updated_note = ChartMogul\EntityNote::update([
'note_uuid' => $note_uuid
], [
'text' => 'This is a new note'
]);
$note = ChartMogul\EntityNote::retrieve($note_uuid);
$note->destroy();
$contacts = ChartMogul\Contact::all([
'customer_uuid' => $customer_uuid,
'data_source_uuid' => $data_source_uuid,
'email' => '[email protected] ',
'customer_external_id' => 'customer_001',
'external_id' => 'contact_001',
'cursor' => 'aabbccdd...'
]);
$new_contact = ChartMogul\Contact::create([
"customer_uuid" => "cus_00000000-0000-0000-0000-000000000000",
"data_source_uuid" => "ds_00000000-0000-0000-0000-000000000000",
"first_name" => "Adam",
"last_name" => "Smith",
"email" => "[email protected] ",
"last_seen" => "2025-01-01T00:00:00Z",
]);
$contact = ChartMogul\Contact::retrieve($uuid);
$contact = ChartMogul\Contact::retrieve($uuid, null, [
'with_overrides' => true,
'attributes_with_history' => 'title,phone'
]);
$contact = ChartMogul\Contact::retrieve($uuid);
$contact->destroy();
$updated_contact = ChartMogul\Contact::update([
'contact_uuid' => $uuid
], [
'first_name' => 'New Name',
'last_seen' => '2025-01-01T00:00:00Z'
]);
$updated_contact = ChartMogul\Contact::update([
'contact_uuid' => $uuid
], [
'title' => 'CTO',
'overrides' => ['title' => true]
]);
$merged_contact = ChartMogul\Contact::merge($into_contact_uuid, $from_contact_uuid);
$contact = ChartMogul\Contact::retrieve($uuid);
$tasks = $contact->tasks([
'cursor' => 'aabbccdd...'
]);
$contact = ChartMogul\Contact::retrieve($uuid);
$new_task = $contact->createTask([
'assignee' => '[email protected] ',
'task_details' => 'Call the contact back.',
'due_date' => '2025-04-30T00:00:00Z',
]);
$contact = ChartMogul\Contact::retrieve($uuid);
$notes = $contact->entityNotes([
'cursor' => 'aabbccdd...'
]);
$contact = ChartMogul\Contact::retrieve($uuid);
$new_note = $contact->createEntityNote([
'type' => 'note',
'text' => 'This is a contact note'
]);
$opportunities = ChartMogul\Opportunity::all([
'cursor' => 'aabbccdd...'
])
$opportunity = ChartMogul\Opportunity::create([
'customer_uuid' => $uuid,
'owner' => '[email protected] ',
'pipeline' => 'New business 1',
'pipeline_stage' => 'Discovery',
'estimated_close_date' => '2023-12-22',
'currency' => 'USD',
'amount_in_cents' => 100,
'type' => 'recurring',
'forecast_category' => 'pipeline',
'win_likelihood' => 3,
'custom' => [{ 'key': 'from_campaign', 'value': true }]
])
$opportunity = ChartMogul\Opportunity::retrieve($opportunity_uuid)
$updated_opportunity = ChartMogul\Opportunity::update($opportunity_uuid, [
'estimated_close_date' => '2024-12-22',
]);
$opportunity = ChartMogul\Opportunity::retrieve($opportunity_uuid)
$opportunity->destroy();
$tasks = ChartMogul\Task::all([
'customer_uuid' => $customer_uuid, // or 'contact_uuid' => $contact_uuid
'assignee' => '[email protected] ',
'due_date_on_or_after' => '2025-04-01T00:00:00Z',
'due_date_on_or_before' => '2025-04-30T00:00:00Z',
'completed' => false,
'cursor' => 'aabbccdd...'
])
$task = ChartMogul\Task::create([
'customer_uuid' => $customer_uuid,
'task_details' => 'This is some task details text.',
'assignee' => '[email protected] ',
'due_date' => '2025-04-30T00:00:00Z',
'completed_at' => '2025-04-20T00:00:00Z',
])
$task = ChartMogul\Task::create([
'associated_object_identifier' => [
'associated_object' => 'contact',
'method' => 'uuid',
'value' => $contact_uuid
],
'task_details' => 'Call the contact back.',
'assignee' => '[email protected] ',
'due_date' => '2025-04-30T00:00:00Z',
])
$task = ChartMogul\Task::retrieve($task_uuid)
$updated_task = ChartMogul\Task::update([
'uuid' => $task_uuid
], [
'task_details' => 'This is some other task details text.'
]);
$task = ChartMogul\Task::retrieve($task_uuid)
$task->destroy();
ChartMogul\Plan::create([
"data_source_uuid" => $ds->uuid,
"name" => "Bronze Plan",
"interval_count" => 1,
"interval_unit" => "month",
"external_id" => "plan_0001"
]);
ChartMogul\Plan::retrieve($uuid);
$plans = ChartMogul\Plan::all([
'page' => 1
]);
$plan = ChartMogul\Plan::all()->last();
$plan->destroy();
$plan = ChartMogul\Plan::update(["plan_uuid" => $plan->uuid], [
"name" => "Bronze Monthly Plan",
"interval_count" => 1,
"interval_unit" => "month"
]);
$subscription_events = ChartMogul\SubscriptionEvent::all();
ChartMogul\SubscriptionEvent::create(['subscription_event' => [
"external_id" => "evnt_026",
"customer_external_id" => "cus_0003",
"data_source_uuid" => $ds->uuid,
"event_type" => "subscription_start_scheduled",
"event_date" => "2022-03-30",
"effective_date" => "2022-04-01",
"subscription_external_id" => "sub_0001",
"plan_external_id" => "plan_0001",
"currency" => "USD",
"amount_in_cents" => 1000
"quantity" => 1
]]);
ChartMogul\SubscriptionEvent::destroyWithParams(['subscription_event' => [
"id" => "some_event_id"
]]);
ChartMogul\SubscriptionEvent::updateWithParams(['subscription_event' => [
"id" => "some_event_id",
"currency" => "EUR",
"amount_in_cents" => "100"
]]);
ChartMogul\PlanGroup::create([
"name" => "Bronze Plan",
"plans" => [$plan_uuid_1, $plan_uuid_2],
]);
ChartMogul\PlanGroup::retrieve($uuid);
$plan_groups = ChartMogul\PlanGroup::all([
'page' => 1
]);
$plan_group = ChartMogul\PlanGroup::all()->last();
$plan_group->destroy();
$plan_group = ChartMogul\PlanGroup::update(
["plan_group_uuid" => $plan_group->uuid],
[
"name" => "A new plan group name",
"plans" => [$plan_uuid_1, $plan_uuid_2]
]);
$plan_group_plans = ChartMogul\PlanGroups\Plan::all(
["plan_group_uuid" => $plan_group->uuid]
);
$plan = ChartMogul\Plan::all()->first();
$cus = ChartMogul\Customer::all()->first();
$line_item_1 = new ChartMogul\LineItems\Subscription([
'subscription_external_id' => "sub_0001",
'subscription_set_external_id' => 'set_0001',
'plan_uuid' => $plan->uuid,
'service_period_start' => "2015-11-01 00:00:00",
'service_period_end' => "2015-12-01 00:00:00",
'amount_in_cents' => 5000,
'quantity' => 1,
'discount_code' => "PSO86",
'discount_amount_in_cents' => 1000,
'tax_amount_in_cents' => 900,
'transaction_fees_currency' => "EUR",
'discount_description' => "5 EUR"
]);
$line_item_2 = new ChartMogul\LineItems\OneTime([
"description" => "Setup Fees",
"amount_in_cents" => 2500,
"quantity" => 1,
"discount_code" => "PSO86",
"discount_amount_in_cents" => 500,
"tax_amount_in_cents" => 450,
"transaction_fees_currency" => "EUR",
"discount_description" => "2 EUR"
]);
$transaction = new ChartMogul\Transactions\Payment([
"date" => "2015-11-05T00:14:23.000Z",
"result" => "successful"
]);
$invoice = new ChartMogul\Invoice([
'external_id' => 'INV0001',
'date' => "2015-11-01 00:00:00",
'currency' => 'USD',
'due_date' => "2015-11-15 00:00:00",
'line_items' => [$line_item_1, $line_item_2],
'transactions' => [$transaction]
]);
$ci = ChartMogul\CustomerInvoices::create([
'customer_uuid' => $cus->uuid,
'invoices' => [$invoice]
]);
sh
composer php
$ci = ChartMogul\CustomerInvoices::all([
'customer_uuid' => $cus->uuid,
'page' => 1,
'per_page' => 200
]);
php
$invoice = ChartMogul\Invoice::retrieve('inv_uuid');
php
ChartMogul\Invoice::updateStatus(
'ds_35542640-d9f1-11ed-9c30-7727168c74a5', // data_source_uuid
'inv_0001', // invoice_external_id
['status' => 'voided']
);
php
ChartMogul\Invoice::disable('inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9', true);
// Re-enable:
ChartMogul\Invoice::disable('inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9', false);
php
$lineItem = ChartMogul\LineItem::retrieve('li_592f4699-107b-41b9-b7bc-a2aa2ca7a67b');
php
$lineItem = ChartMogul\LineItem::update(
['line_item_uuid' => 'li_592f4699-107b-41b9-b7bc-a2aa2ca7a67b'],
['amount_in_cents' => 5000]
);
php
$lineItem = new ChartMogul\LineItem(['uuid' => 'li_592f4699-107b-41b9-b7bc-a2aa2ca7a67b']);
$lineItem->destroy();
php
ChartMogul\LineItem::disable('li_592f4699-107b-41b9-b7bc-a2aa2ca7a67b', true);
// Re-enable:
ChartMogul\LineItem::disable('li_592f4699-107b-41b9-b7bc-a2aa2ca7a67b', false);
php
$lineItem = ChartMogul\LineItem::retrieveByExternalId(
'ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba',
'il_1Srh42DZd9drsue4U2FQKjsb'
);
php
$lineItem = ChartMogul\LineItem::updateByExternalId(
'ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba',
'il_1Srh42DZd9drsue4U2FQKjsb',
['amount_in_cents' => 5000]
);
php
ChartMogul\LineItem::destroyByExternalId(
'ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba',
'il_1Srh42DZd9drsue4U2FQKjsb'
);
php
ChartMogul\Transactions\Refund::create([
"invoice_uuid" => $ci->invoices[0]->uuid,
"date" => "2015-12-25 18:10:00",
"result" => "successful"
]);
php
$transaction = ChartMogul\Transaction::retrieve('tr_0e4de894-83c3-44d8-b406-2b0f89e67fda');
php
$transaction = ChartMogul\Transaction::update(
['transaction_uuid' => 'tr_0e4de894-83c3-44d8-b406-2b0f89e67fda'],
['date' => '2026-02-01T00:00:00Z']
);
php
$transaction = new ChartMogul\Transaction(['uuid' => 'tr_0e4de894-83c3-44d8-b406-2b0f89e67fda']);
$transaction->destroy();
php
ChartMogul\Transaction::disable('tr_0e4de894-83c3-44d8-b406-2b0f89e67fda', true);
// Re-enable:
ChartMogul\Transaction::disable('tr_0e4de894-83c3-44d8-b406-2b0f89e67fda', false);
php
$transaction = ChartMogul\Transaction::retrieveByExternalId(
'ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba',
'ch_3St2vHDZd9drsue42v3rkVMC'
);
php
$transaction = ChartMogul\Transaction::updateByExternalId(
'ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba',
'ch_3St2vHDZd9drsue42v3rkVMC',
['date' => '2026-02-01T00:00:00Z']
);
php
$subscriptions = $cus->subscriptions();
php
$subscription = new ChartMogul\Subscription(["uuid" => $subsUUID])
// or use some existing instance of subsctiption, eg. fetched from Customer->subscriptions
$canceldate = '2016-01-01T10:00:00.000Z';
$subscription->cancel($canceldate);
php
$subscription = new ChartMogul\Subscription(["uuid" => $subsUUID])
$cancellationDates = ['2016-01-01T10:00:00.000Z', '2017-01-01T10:00:00.000Z']
$subscription->setCancellationDates($cancellationDates)
php
ChartMogul\Metrics::all([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
'interval' => 'month',
'geo' => 'GB',
'plans' => $plan->name,
'filters' => "currency~ANY~'USD'"
]);
php
ChartMogul\Metrics::mrr([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
'interval' => 'month',
'geo' => 'GB',
'plans' => $plan->name,
'filters' => "currency~ANY~'USD'"
]);
php
ChartMogul\Metrics::arr([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
'interval' => 'month'
]);
php
ChartMogul\Metrics::arpa([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
'interval' => 'month'
]);
php
ChartMogul\Metrics::asp([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
'interval' => 'month',
]);
php
ChartMogul\Metrics::customerCount([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
'interval' => 'month',
]);
php
ChartMogul\Metrics::customerChurnRate([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
]);
php
ChartMogul\Metrics::mrrChurnRate([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
]);
php
ChartMogul\Metrics::ltv([
'start-date' => '2015-01-01',
'end-date' => '2015-11-24',
]);
php
ChartMogul\Metrics\Customers\Subscriptions::all([
"customer_uuid" => $cus->uuid
]);
php
ChartMogul\Metrics\Customers\Activities::all([
"customer_uuid" => $cus->uuid
]);
php
ChartMogul\Metrics\Activities::all([
'start-date' => '2020-06-02T00:00:00Z',
'per-page' => 100
]);
**Create an Activities Export**