The Spraggs, a family of midwesterners from the fictional city of Apex who have made money through somewhat shady financial dealings, arrive in New York City at the prompting of their beautiful, ambitious, but socially-naive daughter, Undine. She marries Ralph Marvell, a member of an old New York family that no longer enjoys significant wealth. Before her wedding, Undine encounters an acquaintance from Apex named Elmer Moffatt, a character with "a genuine disdain for religious piety and social cant", as the scholar Elaine Showalter observes. Undine begs him not to do anything that will endanger her wedding to Ralph. Elmer agrees.
Although Ralph dotes on Undine, his finances do not permit the extravagant lifestyle Undine desires, and she feels that her in-laws scorn her. When she becomes pregnant, she is disconsolate; and she neglects her son, Paul, after he is born. Alone in Europe, Undine begins an affair with the nouveau riche Peter Van Degen, who is married to Ralph's cousin, Clare. She then divorces Ralph in the hope of marrying Peter, but this does not work out: Peter seems to want nothing more to do with Undine, and Clare will not grant him a divorce anyway. As a divorcee, Undine loses her high position in society, and spends a few years living in North Dakota, New York, and Paris, scheming to scramble up the social ladder again.
In Paris, a French count, Raymond de Chelles, falls in love with Undine. They desire to get married, but, as a Catholic, Raymond cannot marry a divorcée. To procure enough money to bribe the Pope to annul Undine's previous marriage, Undine blackmails Ralph. Having been awarded custody of their son, but allowing him to live with Ralph (it was inconvenient for her to raise him in Europe), she demands that the boy be sent to her. It is clear that she will let him remain with Ralph only if he sends her a large sum of money. Ralph does not have sufficient funds of his own, so he borrows money from friends and family and invests it in one of Elmer Moffatt's business deals. The deal does not go through in time to meet Undine's deadline, and Moffat also informs Ralph that he had once eloped with Undine and then was divorced from her—the secret she feared that New York society would discover. Shocked, and also distraught at the thought of losing his son, Ralph commits suicide. Undine is able to marry Raymond as a widow, though this would not be possible if Raymond knew of her first marriage to Moffat.
Undine is soon dissatisfied with Raymond, too. The de Chelles are hidebound aristocrats, their wealth tied up in land and art and antiques that they will not consider selling, and Undine cannot adjust to the staid customs of upper-class French society. She also resents having to spend most of her time in the country because her husband cannot pay for expensive stays, entertainment, and shopping trips in Paris. Ultimately, she divorces Raymond in order to remarry Elmer Moffatt, who by now has made a fortune. Now, married to the crass midwestern businessman who was best suited to her in the first place, Undine finally has everything she ever desired. Still, it is clear that she wants even more: in the last paragraph of the novel, she imagines what it would be like to be an ambassador's wife – a position closed to her owing to her divorces.

Question: What did Ralph have to do if he was to keep his son with him?
Answer: Pay Undine a huge amount of money.