The surprise ending of "The Gift of the Magi" comes when Jim tells Della that he sold his watch in order to raise enough money to buy her a Christmas present, an expensive set of tortoise-shell combs for her long hair. This is especially important because it resolves Della's main problem. She wants Jim to love her. After she takes the radical step of selling her hair to raise money to buy him a platinum watch fob, she is afraid she might lose his love.
Jim was never late. Della doubled the fob chain in her hand and sat on the corner of the table near the door that he always entered. Then she heard his step on the stair away down on the first flight, and she turned white for just a moment. She had a habit for saying little silent prayers about the simplest everyday things, and now she whispered: “Please God, make him think I am still pretty.”
The fact that Jim has sold his treasured gold pocket-watch is not merely an ironic surprise twist; it gives Della assurance that Jim really loves her. He has made a sacrifice for her which is commensurate with the sacrifice she made for him. The surprise ending is so crucial to the story that it seems impossible for the reader to think of any other ending. It leaves the reader with a bittersweet feeling which is very appropriate to a Christmas story. In fact, the whole idea of giving presents is almost essential to a Christmas story. (In Charles Dickens' famous tale "A Christmas Carol," Scrooge buys a big goose for the Cratchit family and gives his clerk a raise.) The presents people give at Christmas are only symbols of love. It is the love that is all important. So the sympathetic reader's reaction to the ending would be a mixture of smiles and tears. That is what O. Henry says early in the story.
There was clearly nothing to do but flop down on the shabby little couch and howl. So Della did it. Which instigates the moral reflection that life is made up of sobs, sniffles, and smiles, with sniffles predominating.