Getting Started
Creating a marketplace product
Install the q2-marketplace module by running
q2 upgrade -p marketplace
.
Note
This should also add the marketplace to your INSTALLED_ENTRYPOINTS list in your settings file.
After that you can run q2 -h
and any marketplace entrypoints will be visible, e.g. create_marketplace_product
and marketplace *
commands
Run
q2 create_marketplace_product {name_of_product}
. Pick which extensions are a part of this product.A
configuration/products.py
was created with your product name, which extensions are bundled with this product and a unique identifier assigned. Any extensions you picked now also inherit fromQ2MarketplaceMixin
, this handler will enforce that an active subscription is available before users are allowed to access your product.
Subscription Events
When a user purchases, cancels, or changes their subscription on the marketplace an event will be triggered. When you provisioned your product on the marketplace (via q2 create_marketplace_product
) an
HTTP handler was created for you under /marketplace/{name_of_product}/extension.py
. This handler has three default methods that must be implemented, and return a SubscriptionSuccess
or SubscriptionFailure
object.
cancel()
The users subscription will always successfully cancel regardless of what value or status_code returned, except for error code
DO_NOT_CANCEL
.
A SubscriptionEvent
is passed as an parameter in each of these methods.
See API reference for additional details.
- Marketplace Models
MarketplaceProduct
SubscriptionEvent
SubscriptionEvent.event
SubscriptionEvent.event_type
SubscriptionEvent.user_id
SubscriptionEvent.subscription_id
SubscriptionEvent.sso_user_id
SubscriptionEvent.product_identifier
SubscriptionEvent.extension_url
SubscriptionEvent.extension_name
SubscriptionEvent.created
SubscriptionEvent.processed
SubscriptionEvent.fi_name
SubscriptionEvent.from_json()
ErrorCode
ErrorCode.USER_ALREADY_EXISTS
ErrorCode.USER_NOT_FOUND
ErrorCode.ACCOUNT_NOT_FOUND
ErrorCode.MAX_USERS_REACHED
ErrorCode.UNAUTHORIZED
ErrorCode.OPERATION_CANCELLED
ErrorCode.CONFIGURATION_ERROR
ErrorCode.INVALID_RESPONSE
ErrorCode.PENDING
ErrorCode.FORBIDDEN
ErrorCode.BINDING_NOT_FOUND
ErrorCode.TRANSPORT_ERROR
ErrorCode.UNKNOWN_ERROR
ErrorCode.DO_NOT_CANCEL
SubscriptionResult
SubscriptionSuccess
SubscriptionFailure
Subscription Events in development
To trigger these subscription events in development, make sure your server is running, then open a new tab and run your choice of:
q2 marketplace invoke_subscribe
q2 marketplace invoke_cancel
q2 marketplace invoke_update