def cancel(self,identity,params=None, headers=None):
path = self._sub_url_params('<STR_LIT>', {<EOL>'<STR_LIT>': identity,<EOL>})<EOL>if params is not None:<EOL><INDENT>params = {'<STR_LIT:data>': params}<EOL><DEDENT>response = self._perform_request('<STR_LIT:POST>', path, params, headers,<EOL>retry_failures=False)<EOL>return self._resource_for(response)<EOL>
Cancel a payment.

        Cancels the payment if it has not already been submitted to the banks.
        Any metadata supplied to this endpoint will be stored on the payment
        cancellation event it causes.

        This will fail with a `cancellation_failed` error unless the payment's
        status is `pending_submission`.

        Args:
              identity (string): Unique identifier, beginning with "PM".
              params (dict, optional): Request body.

        Returns:
              ListResponse of Payment instances