# Orb

Automate the usage metering from Orb to all cloud marketplaces.

---

## Overview
If you're currently dependent on [Orb](https://www.withorb.com/) for your metering and billing services and are aiming to grow your presence in cloud marketplaces, Fours presents the perfect solution to bridge this transition. Through our no-code, fully automated integration, you can effortlessly measure usage within your existing Orb setup and allocate it to clients across various cloud marketplaces. This integration eliminates the necessity for migration or complex engineering work, ensuring a seamless and trouble-free process.

:::warning
This integration does not currently disambiguate between a buyer's [AWS Concurrent Agreements](/aws-marketplace/integration/#enable-concurrent-agreements) for the same product — usage can be attributed to the wrong agreement. If your product has Concurrent Agreements enabled, report usage through Fours directly instead. See [Usage Metering for AWS Concurrent Agreements](/metering/usage-metering/#usage-metering-for-aws-concurrent-agreements).
:::

## Create Integration
In your [Fours Console Integration](https://console.suger.io/settings?tab=integrations), you will see the **Orb** integration connection. Click the `Connect` button to create an integration with your Orb instance. This will open an dialog for you to input 

- **API Key**: The Orb API key can be issued in the Orb's console. Here is the [auth guidance](https://docs.withorb.com/essentials/postman#authentication).
- **Billing Mode**: `quantity`, `amount`, or `invoice`. If it is quantity, Fours fetch & report the billable metrics by quantity. If it is amount, Fours fetch & report the billable metrics by amount/cost. If it is invoice, Fours reports each issued Orb invoice's total to the cloud marketplace once. See [Billing Mode](#billing-mode) for details.

> <img src="https://imagedelivery.net/pNNvR2_tZYczcQ3leBU_1A/02abee15-1ee7-4fa2-1bb9-f36445c4de00/public" alt="Orb integration connection dialog with API key and billing mode" style="max-width:550px;width:100%;display:inline;margin:0 auto;box-shadow: 5px 5px 5px #eee" />

Once the integration process is finished, you can proceed by clicking the `VERIFY` button. This action triggers the Fours service to test the connection to the APIs of your Orb instance. If everything is configured correctly, the integration status will be updated as `VERIFIED`.

## Edit Integration

Editing an existing Orb integration is supported. Click the `Edit` button to open the dialog of editing Orb integration as shown below.

- **Enable Auto Report Usage**. You can choose to enable or disable the automatic usage report feature for Orb. Enabling this feature allows Fours to run a cron job **once a day** to retrieve the aggregated subscription usages, costs, or issued invoice totals from Orb and report them as UsageRecordGroups to the [Fours metering API](/metering/usage-metering/). On the other hand, disabling this feature means that no cron job will be scheduled for this purpose.

- **Enable Auto Report Credit**. Shown only when Billing Mode is `amount` and Auto Report Usage is enabled. When enabled, Fours nets out the prepaid Orb credits a buyer consumes. For each reporting window, Fours reads the credit Orb applied and subtracts it from the amount metered to the cloud marketplace. 

- **Billing Mode**: `quantity`, `amount`, or `invoice`. If it is quantity, Fours fetch the billable metrics by quantity. If it is amount, Fours fetch the billable metrics by amount/cost. If it is invoice, Fours reports each issued Orb invoice's total to the cloud marketplace once.

- **Plans**. All available price plans in your Orb instance. The `source dimension keys` with the price for each type of price plans can be found here.

- **Billable Metrics**. The full list of billable metrics fetched from Orb for all available Orb customers. It is auto fetched from Orb, not editable.

## Delete Integration

The Orb integration can be deleted like all other integrations. Once the deletion is triggered, all integration info including the API Key will be deleted immediately & permanently from Fours. No time window or methods to recover. 

## Billing Mode
There are three billing modes available for Fours-Orb integration: **quantity**, **amount**, and **invoice**.

- **quantity**: Fours fetches the per-period usage quantities of each billable metric from the Buyer's active Orb subscription and reports them to the mapped cloud marketplace dimensions.
- **amount**: Fours fetches the per-period subscription costs from Orb and reports them on the single source dimension key `orb` (unit price $1).
- **invoice**: Fours fetches each issued Orb invoice's total and reports them on the single source dimension key `orb`. See [Invoice Mode](#invoice-mode) below.

The following table details how to configure the source dimension keys in [metering dimension conversion](/metering/usage-metering/#metering-dimension-conversion) for the `quantity` and `amount` modes. 

|      | Price Example | `quantity` | `amount` |
| ---- | --- | ----------- | ---------- |
| Unit | <ul><li>`compute`: $0.02/unit</li><li>`storage`: $0.03/unit</li></ul> | <ul><li>`compute`: $0.02/unit</li><li>`storage`: $0.03/unit</li></ul>  | <ul><li>`orb`: $1/unit</li></ul> |
| Tiered | <ul><li>`compute`: $0.02/unit in range[0, 100)</li><li>`compute`: $0.01/unit in range[100, ∞)</li></ul> | <ul><li>`compute_tiered_0`: $0.02/unit</li><li>`compute_tiered_100`: $0.01/unit</li></ul> | <ul><li>`orb`: $1/unit</li></ul> |
| Bulk | <ul><li>`compute`: $0.03/unit up to 100</li><li>`compute`: $0.02/unit up to 200 </li><li>`compute`: $0.01/unit up to ∞ </li></ul> | <ul><li>`compute_bulk_100`: $0.03/unit</li><li>`compute_bulk_200`: $0.02/unit</li><li>`compute_bulk_0`: $0.01/unit</li></ul> | <ul><li>`orb`: $1/unit</li></ul> |
| Package | <ul><li>`compute`: $0.2 per 100 unit</li></ul> | <ul><li>`compute_package_100`: $0.2/unit</li></ul> | <ul><li>`orb`: $1/unit</li></ul> |
| BPS | | <ul><li>:no_entry_sign: not supported</li></ul> | <ul><li>`orb`: $1/unit</li></ul> |
| Matrix | <ul><li>`compute` `us-west-1` `gcp`: $0.01/unit</li><li>`compute` `us-west-1` `aws`: $0.02/unit</li><li>`compute` `us-west-2` `gcp`: $0.03/unit</li><li>`compute` `us-west-2` `aws`: $0.04/unit</li></ul> | <ul><li>`compute__matrix__us-west-1__gcp`: $0.01/unit</li><li>`compute__matrix__us-west-1__aws`: $0.02/unit</li><li>`compute__matrix__us-west-2__gcp`: $0.03/unit</li><li>`compute__matrix__us-west-2__aws`: $0.04/unit</li></ul> | <ul><li>`orb`: $1/unit</li></ul> |

:::warning
- If `quantity` is selected as the Billing Mode, please ensure all source dimension keys in your price plans have been mapped to their respective cloud marketplace dimensions in the [Metering Dimension Conversion](/metering/usage-metering/#metering-dimension-conversion).
- If `amount` or `invoice` is selected as the Billing Mode, please ensure the source dimension key `orb` is mapped to the cloud marketplace dimensions.
- Orb Auto Fetch & Report Job: In case any billable metrics from Orb cannot be successfully converted to metering dimensions in the cloud marketplace, it may result in the entire Orb auto fetch and report job failing.
- If you notice any discrepancies or missing usage reporting, please verify whether this is caused by incomplete mapping of billable metrics to cloud marketplace dimensions. If so, rectify the mapping accordingly to ensure accurate reporting.
:::

### Invoice Mode

In `invoice` mode, Fours reports issued Orb invoice totals.

During each sync run, Fours fetches the invoices of the connected Orb Customers from the last two calendar months and handles each invoice by its status:

- **Issued**: The invoice's total amount is reported to the cloud marketplace exactly once. After reporting, Fours stamps the Orb invoice with metadata `suger_usage_record_group_id`. 
- **Void**: If a voided invoice was previously reported, Fours automatically credits the reported amount back to the buyer's entitlement.
- **Draft / Paid / Synced**: Skipped. 

## Connect Orb Customer
To enable Fours to fetch and report the billable metrics of Orb Customers to the appropriate entitlements in Cloud Marketplace, you need to connect the Buyer in Fours with the corresponding Customer in Orb. Simply click the `Edit` button in the Buyer and add the corresponding Orb Customer ID. This setup only needs to be done once; afterward, Fours' service will automatically retrieve the latest billable metrics and report them to the correct Cloud Marketplace entitlements.
