Kortjättarna Visa och Mastercard har nått en uppgörelse med amerikanska handlare som ger butiker större flexibilitet i hur de accepterar betalningar.