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

Relate quote to orders #1866

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b57879b
Relate quote to orders
lexerom Apr 10, 2024
211c65c
Update openapi/components/schemas/QuoteCreateOrder.yaml
lexerom Apr 11, 2024
e93a22d
Update quotes with order items properties
lexerom Apr 22, 2024
719d314
Merge branch 'use-order-for-quotes' of github.com:Rebilly/api-definit…
lexerom Apr 22, 2024
326c28d
Add readonly for create quote
lexerom Apr 22, 2024
1a14746
Fix trial conversion
lexerom Apr 22, 2024
d21bf37
Move properties to order
lexerom Apr 23, 2024
7ce9329
Add trial conversion
lexerom Apr 23, 2024
08d51e1
Change property names
lexerom Apr 24, 2024
47c5536
fix quoteItemId
lexerom Apr 24, 2024
7f3eb13
Set default quantity to 1
lexerom Apr 24, 2024
f0f5fab
Refactor quote items, add type instead of action
lexerom Apr 25, 2024
f270d1b
Remove unused file
lexerom Apr 25, 2024
db5ee53
Fix trial conversion
lexerom Apr 25, 2024
9ca53fc
Remove required section from storefront
lexerom Apr 25, 2024
1600ecc
Remove embedded for quote order item
lexerom Apr 25, 2024
2d8ee8b
Update openapi/components/schemas/QuoteCreateOrder.yaml
lexerom Apr 25, 2024
c34e4a0
Merge branch 'main' into use-order-for-quotes
lexerom May 8, 2024
e50cb34
Rename order to orderChanges
lexerom May 8, 2024
44fdc30
Make orderId required, remove readOnly
lexerom May 9, 2024
2eb6b0a
Merge branch 'main' into use-order-for-quotes
lexerom May 9, 2024
79cebb1
Apply suggestions from code review
lexerom May 11, 2024
55a8baf
Merge branch 'main' into use-order-for-quotes
lexerom May 14, 2024
f6c612e
Apply suggestions
lexerom May 14, 2024
d15bf5f
Merge branch 'use-order-for-quotes' of github.com:Rebilly/api-definit…
lexerom May 14, 2024
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
6 changes: 3 additions & 3 deletions openapi/components/schemas/Quote.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
discriminator:
propertyName: action
propertyName: type
mapping:
create: ./QuoteCreateOrder.yaml
creation: ./QuoteCreateOrder.yaml
change: ./QuoteChangeOrder.yaml
reactivate: ./QuoteReactivateOrder.yaml
reactivation: ./QuoteReactivateOrder.yaml
trial-only-conversion: ./QuoteTrialConversionOrder.yaml
oneOf:
- $ref: ./QuoteCreateOrder.yaml
Expand Down
201 changes: 30 additions & 171 deletions openapi/components/schemas/QuoteChangeOrder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ title: QuoteChangeOrder
required:
- websiteId
- customerId
- items
- action
- subscriptionId
- order
- type
properties:
id:
readOnly: true
Expand All @@ -15,16 +14,7 @@ properties:
example: qt_0YV7DES3WPC5J8JD8QTVNZBZNZ
type:
description: |-
Specifies the type of the quote.
A quote can be a subscription or a one-time purchase.
type: string
readOnly: true
enum:
- subscription-order
- one-time-order
action:
description: |-
Action of the quote for change order items.
Type of the quote for change order items.
When a quote is accepted, quote items are applied to the related order.
type: string
enum:
Expand Down Expand Up @@ -59,11 +49,6 @@ properties:
- organization
isFulfilled:
type: boolean
subscriptionId:
description: ID of the related subscription.
type: string
maxLength: 50
example: ord_0YV7DES3WPC5J8JD8QTVNZBZNZ
invoiceId:
type: string
description: ID of the payment invoice.
Expand Down Expand Up @@ -92,147 +77,31 @@ properties:
$ref: ./WebsiteId.yaml
customerId:
$ref: ./CustomerId.yaml
items:
type: array
description: Items included in the quote.
minItems: 1
items:
type: object
required:
- plan
- quantity
properties:
id:
description: ID of the quote item.
readOnly: true
type: string
example: qti_0YV7DES3WPC5J8JD8QTVNZBZNZ
quantity:
description: Number of product units in the specified plan.
type: integer
minimum: 1
plan:
description: Plan details.
oneOf:
- $ref: ./OriginalPlan.yaml
- $ref: ./FlexiblePlan.yaml
description:
type: string
description: Description of the quote item.
example: Charge per approved transaction with DCC
default: ''
maxLength: 255
priceDescription:
type: string
description: |-
Price description of the quote item.
This value is only used for metered billing items.
example: 50% of the markup for approved transactions
default: ''
maxLength: 255
usageLimits:
type:
- 'object'
- 'null'
default: null
description: |-
Specifies the soft and hard usage limit thresholds for an item with a metered billing plan.
This value is ignored when the plan is not metered.
properties:
softLimit:
type: object
description: |-
Defines thresholds for notification purposes.
For example, to notify the customer that their usage is near the hard limit of their metered billing plan.
This notification informs the customer so that they can upgrade their plan before the hard limit is reached.
When the reported usage reaches 75%, 90%, and 100% of the configured limit a specific event is fired.
To notify the customer, a webhook and notification can be configured for this event.
This field is useful for accounting and customer success purposes.
The usage of metered billing plans can still be reported if the soft limit is reached.
minProperties: 1
maxProperties: 1
properties:
quantity:
type: integer
description: Usage limit quantity.
minimum: 1
amount:
type: number
format: double
description: Usage limit amount in the currency of the order.
minimum: 0.01
hardLimit:
type: object
description: |-
Defines a limit where the customer can no longer use the service.
Hard limits are used in addition to soft limits.
When a soft limit is reached,
a customer may receive a notification
but the service can still be provided up to the hard limit value so that the customer can upgrade their plan.
When the reported usage reaches the configured limit,
a specific event is triggered.
To notify the customer in the merchant system,
or block a service,
a webhook and notification can be configured for this event.
When the total usage reaches the hard limit quantity,
or amount values,
metered billing plan usages can no longer be reported.
minProperties: 1
maxProperties: 1
properties:
quantity:
type: integer
description: Usage limit quantity.
minimum: 1
amount:
type: number
format: double
description: Usage limit amount in the currency of the order.
minimum: 0.01
createdTime:
$ref: ./CreatedTime.yaml
updatedTime:
$ref: ./UpdatedTime.yaml
_embedded:
type: object
description: Embedded objects that are requested by the `expand` query parameter.
readOnly: true
properties:
product:
type: object
renewalPolicy:
description: Specifies if the subscription retains its current `renewalTime` or resets it to a newly calculated `renewalTime`.
type: string
enum:
- reset
- retain
prorated:
description: |-
Specifies whether to give a pro rata credit for the amount of time remaining between the `effectiveTime` and the end of the current period.

In addition, if the `renewalTime` is retained, by setting the `renewalPolicy` to `retain`,
a pro rata debit occurs for the amount between the `effectiveTime` and the `renewalTime` as a percentage of the normal period length.
type: boolean
effectiveTime:
description: |-
Date from which the renewal time for `reset` operations and proration calculations are made.
If this field is omitted, this value defaults to the time of quote acceptance.
type:
- 'string'
- 'null'
format: date-time
keepTrial:
description: |-
Specifies if the subscription order must retain its active trial.
This field is only applicable if `renewalPolicy` is set to `retain`.
type: boolean
default: false
interimOnly:
type: boolean
default: true
description: |-
Specifies if the quotation invoice must include interim items only.
If this value is set to `false`, all upcoming items are included.
order:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right this object is the same across all the files? If so, we need it to be extracted and reused as it's quite big and hard to manage otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved similar code of items into files.

type: object
description: Related order properties.
properties:
id:
description: ID of the related order.
readOnly: true
type: string
maxLength: 50
example: ord_0YV7DES3WPC5J8JD8QTVNZBZNZ
items:
type: array
description: Items included in the quote.
minItems: 1
items:
$ref: ./QuoteChangeOrderItem.yaml
autopay:
type: boolean
default: false
description: |-
Specifies if payment attempts for the related subscription are made automatically.
If autopay is enabled, the payment is retrieved from the customer on the renewal date using the payment instrument that is set at `paymentInstrumentId`,
or the default payment instrument on the subscription.
shipping:
$ref: ./Shipping.yaml
vykhrystiuk marked this conversation as resolved.
Show resolved Hide resolved
usageSettings:
type: array
default: []
Expand Down Expand Up @@ -264,7 +133,7 @@ properties:
example: plan_0YV7DENSVGDBW9S71XZNNYYQ0Y
invoicePreview:
type: object
description: Preview of the quote invoice.
description: Preview of the quote invoices.
readOnly: true
properties:
currency:
Expand Down Expand Up @@ -413,14 +282,6 @@ properties:
- 'number'
- 'null'
format: double
autopay:
type:
- 'boolean'
- 'null'
description: |-
Specifies if payment attempts for the related subscription are made automatically.
If autopay is enabled, the payment is retrieved from the customer on the renewal date using the payment instrument that is set at `paymentInstrumentId`,
or the default payment instrument on the subscription.
paymentTerms:
description: Payment terms for the customer which are displayed on the quote.
type: string
Expand Down Expand Up @@ -481,8 +342,6 @@ properties:
- 'null'
description: Printed name of the organization.
default: null
shipping:
$ref: ./Shipping.yaml
tax:
$ref: ./Taxes.yaml
couponIds:
Expand Down Expand Up @@ -525,7 +384,7 @@ properties:
type: object
website:
type: object
subscription:
order:
type: object
invoice:
type: object
39 changes: 39 additions & 0 deletions openapi/components/schemas/QuoteChangeOrderItem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
allOf:
- $ref: ./QuoteOrderItem.yaml
- type: object
properties:
renewalPolicy:
description: Specifies if the subscription retains its current `renewalTime` or resets it to a newly calculated `renewalTime`.
type: string
default: retain
enum:
- reset
- retain
prorated:
description: |-
Specifies whether to give a pro rata credit for the amount of time remaining between the `effectiveTime` and the end of the current period.

In addition, if the `renewalTime` is retained, by setting the `renewalPolicy` to `retain`,
a pro rata debit occurs for the amount between the `effectiveTime` and the `renewalTime` as a percentage of the normal period length.
type: boolean
default: true
effectiveTime:
description: |-
Date from which the renewal time for `reset` operations and proration calculations are made.
If this field is omitted, this value defaults to the time of quote acceptance.
type:
- 'string'
- 'null'
format: date-time
keepTrial:
description: |-
Specifies if the subscription order must retain its active trial.
This field is only applicable if `renewalPolicy` is set to `retain`.
type: boolean
default: false
interimOnly:
type: boolean
default: true
description: |-
Specifies if the quotation invoice must include interim items only.
If this value is set to `false`, all upcoming items are included.
Loading