'Generate the shasign for incoming or outgoing communications, when using the SHA-1
signature (deprecated by Adyen).
:param string inout: \'in\' (odoo contacting ogone) or \'out\' (adyen
contacting odoo). In this last case only some
fields should be contained (see e-Commerce basic)
:param dict values: transaction values
:return string: shasign'

@api.multi
def _adyen_generate_merchant_sig(self, inout, values):

    assert (inout in ('in', 'out'))
    assert (self.provider == 'adyen')
    if (inout == 'in'):
        keys = 'paymentAmount    currencyCode    shipBeforeDate    merchantReference    skinCode    merchantAccount    sessionValidity    shopperEmail    shopperReference    recurringContract    allowedMethods    blockedMethods    shopperStatement    merchantReturnData    billingAddressType    deliveryAddressType    offset'.split()
    else:
        keys = 'authResult    pspReference    merchantReference    skinCode    merchantReturnData'.split()
    def get_value(key):
        if values.get(key):
            return values[key]
        return ''
    sign = ''.join((('%s' % get_value(k)) for k in keys)).encode('ascii')
    key = self.adyen_skin_hmac_key.encode('ascii')
    return base64.b64encode(hmac.new(key, sign, hashlib.sha1).digest())
