'Generate the shasign for incoming or outgoing communications., when using the SHA-256
signature.
: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_sha256(self, inout, values):

    def escapeVal(val):
        return val.replace('\\', '\\\\').replace(':', '\\:')
    def signParams(parms):
        signing_string = ':'.join(map(escapeVal, (parms.keys() + parms.values())))
        hm = hmac.new(hmac_key, signing_string, hashlib.sha256)
        return base64.b64encode(hm.digest())
    assert (inout in ('in', 'out'))
    assert (self.provider == 'adyen')
    if (inout == 'in'):
        keys = ['merchantReference', 'paymentAmount', 'currencyCode', 'shipBeforeDate', 'skinCode', 'merchantAccount', 'sessionValidity', 'merchantReturnData', 'shopperEmail', 'shopperReference', 'allowedMethods', 'blockedMethods', 'offset', 'shopperStatement', 'recurringContract', 'billingAddressType', 'deliveryAddressType', 'brandCode', 'countryCode', 'shopperLocale', 'orderData', 'offerEmail', 'resURL']
    else:
        keys = ['authResult', 'merchantReference', 'merchantReturnData', 'paymentMethod', 'pspReference', 'shopperLocale', 'skinCode']
    hmac_key = binascii.a2b_hex(self.adyen_skin_hmac_key.encode('ascii'))
    raw_values = {k: values.get(k.encode('ascii'), '') for k in keys if (k in values)}
    raw_values_ordered = OrderedDict(sorted(raw_values.items(), key=(lambda t: t[0])))
    return signParams(raw_values_ordered)
