Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking #25

Open
wants to merge 6 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/3bb32b067ad376c4187d1419f04696de.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/4fe2422521ed4f389ed1b278885d2128.png
Binary file not shown.
Binary file removed assets/images/6527eb113932e234da6742fdf38cb686.png
Binary file not shown.
Binary file removed assets/images/80d036e1088147beba80fe9f5b5d4ca0.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/f62a01ef0bae9aa5e7b44d35f1b03d03.png
Binary file not shown.
67 changes: 66 additions & 1 deletion docs/Overview/Mocking.md
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
# Mocking
# Mocking
## What is Mocking?

If you look up the noun *mock* in the dictionary you will find that one of the
definitions of the word is *something made as an imitation*.

Mocking is primarily used in unit testing. An object under test may have
dependencies on other (complex) objects. To isolate the behaviour of the object
you want to replace the other objects with mocks that simulate the behaviour of
the real objects. This is useful if the real objects are impractical to
incorporate into the unit test.

In short, mocking is creating objects that simulate the behaviour of real
objects.

![Subscription Management Mocking Explanation](../../assets/images//3e5465a73ddbfdbad42facca42cf3642.png)

Classes are not isolated as they are using services and methods from other
classes, but in unit testing, we want to test methods of one class in isolation.

To do that we mock the services and methods from other classes and simulate the
real behaviour of them using some mocking frameworks and use those mocked
methods and services to do unit testing in isolation.

## What is a Mock API Server?

A mock API server or mock server API imitates a real API server by providing
realistic mock API responses to requests. They can be on your local machine or
the public Internet. Responses can be static or dynamic, and simulate the data
the real API would return, matching the schema with data types, objects, and
arrays.

<!-- theme: info -->
>**Why Use API Mocking?**
>
>A mock API server is useful during development and testing when live data is
either unavailable or unreliable. While designing an API, you can use mock APIs
to work concurrently on the front and back-end, as well as to gather feedback
from developers. Our Subscription Management Mocking API has details how you can use a mock API server so the absence of a real API doesn’t
hold you back.

## Subscription Management Mocking API

Subscription Management has three methods you can call from our Mocking API:

1. **RequestMocking**

Request the service to be mocked by utilizing the private key provided.

2. **AuthorizeMocking**

Allows further calls to the service to be mocked using provided private key.

3. **SetMock**

Sets the response which SubscriptionMgt_SM_TSL will reply with during the
test execution.

The SubscriptionMgt_SM_TSL codeunit contains all the code blocks for the
integration aspect of the Subscription Management app.

![your class in test image](../../assets/images/44b9953d50fb65ee43a61b91796b5bbe.png)
## See Also

- [Subscription Management Reference
Document](https://github.com/thetanz/smp-docs/blob/master/docs/References/SubscriptionMgt.md#mocking-api)
158 changes: 157 additions & 1 deletion docs/Overview/ProductSetup.md
Original file line number Diff line number Diff line change
@@ -1 +1,157 @@
# Product Setup
# Product Setup
## Pricing your Product

There are many options for you to explore and consider when pricing your
product. Pricing Models configure how the units of your product are priced, and
Usage Types configure how the units of your product are quantified. It is even
possible to add multiple pricing models, billing periods, and currencies to one
product.

The following sections describe these options in more detail and give guidance
on how to configure and combine the pricing you want.

## Pricing Models

When you are planning the product subscription and depending on how you want to
price each product unit, you can choose between several pricing models. The
pricing models available are **Standard**, **Volume**, **Package**, and
**Graduated**.

Here is a comparison of each pricing model:

| Standard | Volume | Package | Graduated |
|-------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Select **Standard** pricing if you charge the same price for each unit. | Select **Volume** pricing if you charge the same for each unit based on the total number of units sold. For example, you might charge 10.00 USD per unit for 50 units, and 7.00 USD per unit when the 50+ units total is reached. | Select **Package** pricing if you charge by a group of units or a package. For example, if you charge 50.00 USD for every 5 units. Purchases are rounded up by default, so a customer buying 8 units would pay 100.00 USD. | Select **Graduated** pricing if you use pricing tiers that may result in a different price for some units in an order. For example, you might charge 10.00 USD per unit for the first 100 units and then 5.00 USD per unit for the next 50. |

## Correlation of Pricing Models to Usage Types

Usage records provide **quantity** information that is used to track how many of
your products a customer is consuming.

With quantity information and the **pricing model** set up by the metered
billing plan, the invoices you send to your customers are accurate i.e. quantity
x price = invoiced amount.

## Licensed and Metered Usage Types

The available subscription options are built on [**Usage
Types**](https://stripe.com/docs/billing/subscriptions/model#licensed-and-metered).
These usage types are **licensed** usage and **metered** usage, and they
determine how much a customer is charged for the recurring purchase of your
products.

If you choose the **licensed** usage option, you are requiring that the quantity
of a product is set when the subscription is created or updated. This means that
for every billing period, the subscription charges the quantity x price for the
product.

With the **metered** usage option your customer is charged for the amount of
your product they have consumed. At the end of the billing period, the total
usage x price is used to calculate how much the customer owes.

When you create a new product, licensed usage is applied by default unless you
select the “**Usage is metered**” checkbox control.

![](../../assets/images/9871628bd51fc5dce267c2f08e33079c.png)

Making this selection then opens a “**Charge for metered usage by**” dropdown
control, where you can select the option that best suits your billing strategy.

![Graphical user interface, text, application Description automatically
generated](../../assets/images/086f6b3e60b869e1b8e771bb6b1849a0.png)

Important. A product has usage categorized as Licensed by default until the
“**Usage is metered**” checkbox control is selected, then the usage changes to
Metered.

## Configure your Product Pricing

The product setup user interface is contextually driven and the options
presented to you directly relate to your previous selections. Here is more
information on configuring each of the pricing options available.

### Standard Pricing

There are two methods of configuring the **standard** pricing model. Option 1 is
for a one-time purchase of your product.

![](../../assets/images/2502b6d534c72dbb602629d334d98de0.png)

Option 2 is for recurring purchases of your product

![](../../assets/images/5e059e10b895169df50f1ca5e79899e1.png)

You can select the billing period you want, and choose to meter the usage.

![](../../assets/images/907a2104ba010837b0c513fda5d07192.png)

Remember: metered billing lets you charge customers based on reported usage at
the end of each billing period.

### Volume Pricing

With **volume** pricing, the first unit and last unit columns are used to set
prices based on the total number of units sold.

Additional tiers can be added by using the **Add another tier** control.

![](../../assets/images/c50ff251d9f1a3eccd5457277cebe42f.png)

Hovering over the **Preview** control shows how your selections will impact the
pricing at the final price breakpoint.

![](../../assets/images/34cbdf708b9acc3a35612c9693ecf492.png)

As per standard pricing, the billing period can be selected, and product usage
metered.

### Package Pricing

In the same way as standard pricing, there are two methods of configuring the
**package** pricing model. Option 1 is for a one-time purchase of your product,
and Option 2 is for recurring purchases of your product

As per standard pricing, the billing period can be selected, and product usage
metered.

### Graduated Pricing

With **graduated** pricing, the first unit and last unit columns are used to set
a different price for some units in the order.

Additional tiers can be added by using the **Add another tier** control.

![](../../assets/images/b5325bf608cfdb3965d5266c1b7a1019.png)

Hovering over the **Preview** control shows how your selections will impact the
pricing at the final price breakpoint.

![](../../assets/images/029e875e267a37dc20b34c8a7bda234d.png)

### One Product – Many Options

As you create your products you can add multiple pricing models, billing
periods, and currencies to one product by selecting the **Add another price**
button

Below is a single product with multiple pricing attributes:

1. a price per unit per month in USD

2. a volume-based discount for 3 monthly purchases in USD, and

3. a price per unit per week in EUR

![](../../assets/images/a0785f85874387e330f0823f49c452a3.png)

There is no limit to the multiples that can be added to one product. You can
also add or edit the multiples later by accessing the product record on the
Products page of your dashboard and selecting the controls:

1. **+ Add another price**, or

2. **…** (the ellipses to open a sub-menu)

![](../../assets/images/b3cb0cd711fb9fb4c413f3d41a7c18cb.png)


154 changes: 0 additions & 154 deletions docs/Pricing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,160 +24,6 @@ Stripe has its own volume-based discount program. Please [contact the Stripe sal
## Open Source Discount
At Theta we are big fans and supporters of Open Source initiatives. In support of the Business Central Open Source community, we are offering a 57% discount, i.e. a transaction fee of 3%, to all publishers which have all apps available as open source. Please [contact our product team](mailto:app.billing@theta.co.nz?subject=SM%20for%20open%20source%20discount%20request) to get a service discount.

## Licensed and Metered Usage

The available subscription options are built on [**Usage
Types**](https://stripe.com/docs/billing/subscriptions/model#licensed-and-metered).
These usage types are **licensed** usage and **metered** usage, and they
determine how much a customer is charged for the recurring purchase of your
products.

If you choose the **licensed** usage option, you are requiring that the quantity
of a product is set when the subscription is created or updated. This means that
for every billing period, the subscription charges the quantity x price for the
product. For example, a customer with three users who subscribes to a 10 USD
per-user monthly service is charged 30 USD every month.

With the **metered** usage option your customer is charged for the amount of
your product they have consumed. At the end of the billing period, the total
usage x price is used to calculate how much the customer owes. For example, if a
broadband provider charges 0.50 USD per gigabyte (GB) used, and a customer uses
100 GBs, the customer is charged 50 USD.

When you create a new product, licensed usage is applied by default unless you
select the “**Usage is metered**” checkbox control.

![](../assets/images/9871628bd51fc5dce267c2f08e33079c.png)


Making this selection then opens a “**Charge for metered usage by**” dropdown
control, where you can select the option that best suits your billing strategy.

![](../assets/images/086f6b3e60b869e1b8e771bb6b1849a0.png)

<!-- theme: warning -->
>Important. A product has usage categorized as Licensed by default until the
“**Usage is metered**” checkbox control is selected, then the usage changes to
Metered.

## Pricing Models

When you are planning how to configure the product subscription and depending on
how you want to price each product unit, you can choose between several pricing
models. The pricing models available are **Standard**, **Volume**, **Package**,
and **Graduated**.

Here is a comparison of each pricing model:

| Standard | Volume | Package | Graduated |
|-------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Select **standard** pricing if you charge the same price for each unit. | Select **volume** pricing if you charge the same for each unit based on the total number of units sold. For example, you might charge 10.00 USD per unit for 50 units, and 7.00 USD per unit when the 50+ units total is reached. | Select **package** pricing if you charge by a group of units or a package. For example, if you charge 50.00 USD for every 5 units. Purchases are rounded up by default, so a customer buying 8 units would pay 100.00 USD. | Select **graduated** pricing if you use pricing tiers that may result in a different price for some units in an order. For example, you might charge 10.00 USD per unit for the first 100 units and then 5.00 USD per unit for the next 50. |

## How the Usage Types correlate to the Pricing Models

Usage records provide **quantity** information that is used to track how many of
your products a customer is consuming.

With quantity information and the **pricing model** set up by the metered
billing plan, the invoices you send to your customers are accurate i.e. quantity
x price = invoiced amount.

## Configuring the Pricing for your Product

The product setup user interface is contextually driven and the options you are
presented with directly relate to your previous selections. Here is more
information on configuring each of the pricing options available.

### Standard Pricing

There are two methods of configuring the standard pricing model. Option 1 is for
a one time purchase of your
product.

![](../assets/images/2502b6d534c72dbb602629d334d98de0.png)

Option 2 is for recurring purchases of your product

![](../assets/images/5e059e10b895169df50f1ca5e79899e1.png)

You can select the billing period you want, and also choose whether to meter the
usage.

![](../assets/images/907a2104ba010837b0c513fda5d07192.png)

<!-- theme: warning -->
>Remember: metered billing lets you charge customers based on reported usage at
the end of each billing period.

### Volume Pricing

The first unit and last unit columns are used to set prices based on the total
number of units sold. In the example below, the first 150 units are charged at
10.00 USD each, and when the 151 total is achieved, all units are charged at
7.00 USD each.

Additional tiers can be added by using the **Add another tier** control.
Hovering over the **Preview** control shows how your selections will impact the
pricing at the final price breakpoint.

![](../assets/images/4fe2422521ed4f389ed1b278885d2128.png)

As per Standard pricing, the billing period can be selected, and also metering
of the product usage.

### Package Pricing

There are two methods of configuring the package pricing model. Option 1 is for
a one time purchase of your product.

![](../assets/images/80d036e1088147beba80fe9f5b5d4ca0.png)

Option 2 is for recurring purchases of your product

![](../assets/images/6527eb113932e234da6742fdf38cb686.png)

As per Standard pricing, the billing period can be selected, and also metering
of the product usage.

### Graduated Pricing

The first unit and last unit columns are used to set a different price for some
units in the order. In the example below, the first 100 units are charged at
10.00 USD each, the next 50 units are charged at 8.00 USD each, and units over
151 are charged at 6.00 USD each.

Additional tiers can be added by using the **Add another tier** control.
Hovering over the **Preview** control shows how your selections will impact the
pricing at the final price breakpoint.

![](../assets/images/3bb32b067ad376c4187d1419f04696de.png)

## One Product - Multiple Pricing Models, Billing Periods, & Currencies

As you create your products you can add multiple pricing models, billing periods,
and currencies to one product by selecting the **Add another price** button.

In this example, there is:

1. a price per unit per month in USD

2. a volume-based discount for 3 monthly purchases in USD, and

3. a price per unit per week in EUR

![](../assets/images/1249ea853ffcf2193de4a4d3c7bf6e0a.png)

There is no limit to the multiples that can be added to one product, and you can
also add or edit the multiples later by accessing the product record and
selecting the controls:

1. **+ Add another price**, or

2. **…** (ellipses to open a sub-menu)

![](../assets/images/f62a01ef0bae9aa5e7b44d35f1b03d03.png)


## See Also
- [Getting Started](GettingStarted.md)
- [Security & Privacy](Overview/Security&Privacy.md)
Expand Down
Loading