Let’s start with the easy part of definition of the idiom.

In the end = after considering everything

Cambridge dictionary

But the question deserves a bit more analysis:

At = used to show an exact position or particular place

Cambridge dictionary

Hence “at the end” refers particularly to “the end”. But the end of her asking is not defined by the previous sentence, so the meaning remains unclear.

In = during part or all of a period of time

Cambridge dictionary

So “in the end” refers to the period in which the buying ended and the book was bought. This phrase conveys the meaning correctly.