The Processor Template provides various files that allows configuring your API, connect your product and customize your request processing logic. The following table represents the Processor file structure:
File | Description |
processor.py | This is the main program; fetch the pending requests via Connect OpenAPI client |
config.json | API endpoint and Connect API token specification |
globals.py | Global constants configuration (e.g., Product ID and Activation Template) |
utils.py | Supporting functionalities |
cancel.py | Business logic to process the cancel subscription requests |
change.py | Business logic to process the change subscription requests ( items or their quantity adjustments) |
dynamic_validation.py | Validate the ordering parameters provided during order placement |
purchase.py | Business logic to process the purchase subscription requests |
report_usage.py | Helps upload the usage report files |
resume.py | Business logic to process the resume subscription requests |
suspend.py | Business logic to process the suspend subscription requests |
tier_fulfilment.py | The business logic to process the tier request (e.g., reseller account creation) |
The Processor uses unittest for testing operations. Test your project and your configuration by executing the following command from your specified Processor directory:
$ python -m unittest discover tests
The Processor Template repository also includes an example project that uses a Mock API Endpoint created in Apiary.io. Therefore, this allows emulating API requests from a Vendor system and preview provided use cases.
Apiary.io is a tool to design, document, and test APIs. Access the corresponding Community page article to learn more about Apiary API design tool.
The Mock API created via Apiary.io can be accessed by using the following link: https://vendorexample.docs.apiary.io/#
The example project covers the following use cases: Subscription Activation, Cancellation, Suspension, Resumption, Change.
The example project uses a product that is configured on the Connect platform as follows:
The parameter ID is used by the Processor to call the Connect API and provide the parameter value before approving a purchase request. Furthermore, it is used to retrieve the parameter value and successfully validate change request.