'Given a data dict coming from stripe, verify it and find the related
transaction record.'

@api.model
def _stripe_form_get_tx_from_data(self, data):

    reference = data['metadata']['reference']
    if (not reference):
        error_msg = _('Stripe:    invalid    reply    received    from    provider,    missing    reference')
        _logger.error(error_msg, data['metadata'])
        raise ValidationError(error_msg)
    tx = self.search([('reference', '=', reference)])
    if (not tx):
        error_msg = (_('Stripe:    no    order    found    for    reference    %s') % reference)
        _logger.error(error_msg)
        raise ValidationError(error_msg)
    elif (len(tx) > 1):
        error_msg = (_('Stripe:    %s    orders    found    for    reference    %s') % (len(tx), reference))
        _logger.error(error_msg)
        raise ValidationError(error_msg)
    return tx[0]
