def process_request(request, client):
        # type: (Dict, ConnectClient) -> Dict
        """  This method processes the Fulfillment Requests in Pending status for change subscription action.
            If vendor system does not support the change in the subscription check the request details
            to reject the request with proper message. """

        # Get the existing subscription Id saved as fulfilment parameter to Prepare the body/payload for the Vendor API
        # to update the subscription
        # Saving the Subscription ID from Vendor system is encouraged to be able to map the subscription in Connect with
        # the subscription in Vendor system
        # The Subscription ID can be saved in a fulfillment parameter
        # This external_subscription_id from Vendor platform might be required to call the Vendor API to change
        # the subscription
        external_subscription_id = Utils.get_param_value(
            request, 'fulfillment', 'subscription_id')

        # TODO: Add code to Update/Change the subscription in vendor system by calling the Vendor API
        # to update/change subscription
        # api_client = APIClient(api_url='',
        #                        api_key='')
        # change_payload = {}
        # api_client.change_subscription(change_payload, external_subscription_id)

        # When successful, approve the fulfillment request with the following code:
        return Utils.approve_fulfillment_request(request, client)
    def process_request(request, client):
        # type: (Dict, ConnectClient) -> Dict
        """ This method processes the Fulfillment Requests in Pending status for purchase subscription action """

        # Create the subscription in vendor system by calling the Vendor API to create subscription
        # TODO: implement the Vendor API call to create the subscription in Vendor portal
        # The following is the Mock API and client to create subscription
        # api_client = APIClient(api_url='',
        #                        api_key='')
        # data = {}
        # subscription_info = api_client.create_subscription(data=data)

        # The response of create subscription Vendor API might have some information that needs to be saved in
        # the fulfillment parameter of the subscription request in Connect
        # With this response complete the request fulfillment parameters to be able to approve the request
        Purchase._save_fulfillment_parameters(request, client)

        return Utils.approve_fulfillment_request(request, client)
    def process_request(request, client):
        # type: (Dict, ConnectClient) -> Dict
        """ This method processes the Fulfillment Requests in Pending status for resume subscription action """

        # Get the subscription Id from the request that needs to be resumed
        # Saving the Subscription ID from Vendor system is encouraged to be able to map the subscription in Connect
        # with the subscription in Vendor system
        # The Subscription ID can be saved in a fulfillment parameter
        # This external_subscription_id from Vendor platform might be required to call the Vendor API
        # to resume the suspended subscription
        external_subscription_id = Utils.get_param_value(request, 'fulfillment', 'subscription_id')

        # TODO: Add code to Resume the subscription in vendor system by calling the Vendor API
        # to resume subscription
        # api_client = APIClient(api_url='',
        #                        api_key='')
        # resume_payload = {}
        # api_client.resume_subscription(resume_payload, external_subscription_id)

        # When successful, approve the fulfillment request with the following code:
        return Utils.approve_fulfillment_request(request, client)
示例#4
0
    def process_request(request, client):
        # type: (Dict, ConnectClient) -> Dict
        """ This method approves or rejects the Fulfillment Requests in Pending status
        for cancel subscription action. """

        # Get the fulfillment parameter values from the subscription that needs to be cancelled
        # Saving the Subscription ID from Vendor system is encouraged to be able to map the Connect subscription
        # with the subscription in Vendor system. The Subscription ID can be saved in a fulfillment parameter.
        # Here 'subscription_id' is an example of Connect product fulfillment parameter id.
        # This external_subscription_id from Vendor platform might be required to call the Vendor API
        # to cancel the subscription
        external_subscription_id = Utils.get_param_value(
            request, 'fulfillment', 'subscription_id')

        # TODO: Add your code to Cancel the subscription in vendor system by calling the Vendor API
        # api_client = APIClient(api_url='',
        #                        api_key='')
        # cancel_payload = {}
        # api_client.cancel_subscription(cancel_payload, external_subscription_id)

        # When successful, approve the fulfillment request with the following code:
        return Utils.approve_fulfillment_request(request, client)