English prepositions are endlessly tricky.
"With" means that the object accompanies something else, or is used as a means to accomplish something else. Note these are two very distinct meanings. "I assembled this bookcase with Bob." Bob worked with me on the project. We built it together. "I assembled this bookcase with a screwdriver." The screwdriver was used as a tool.
"For" indicates purpose, or it can mean approval or support. "This screwdriver is for Phillips-head screws." I am describing it's purpose. "Senator Jones is for new gun laws." He favors or supports such laws.
"In" can mean, located on the interior of, like, "A new battery is in the cell phone." It can also identify a unit of measure, a language, etc. "The length is given in inches." "The book is written in German." It can describe a condition. "Sally and I are deeply in love, and deeply in debt."
"By" can be used for a means of accomplishing something. "We paid by credit card." "We travelled by car." It can indicate passage past a place. "We passed by your house." "We drove by the grocery store." Adjacency. "The barn is by the house."
There are other shades of meaning for all the above.
So in these cases:
The product may be purchased WITH U.S. dollars.
The thing you are using to buy the product is U.S. dollars, so you are buying it WITH dollars.
The product may be purchased FOR 40 dollars.
This is the amount required to accomplish the purpose of making this purchase.
You could make logical arguments why other prepositions would work in each case, but these are the ones normally used by native speakers.
Note other related sentences:
All prices are given IN US dollars.
This was the currency used to express the price.
I paid WITH a credit card.
A credit card was the tool or means of payment. But
I paid BY credit card.
A different way of saying that this was the mechanism. But WITH indicates a specific object, so an article is required, while BY indicates a more general concept, so no article is used. But:
I paid WITH cash.
I paid IN cash.
Both valid.
The p