Independent verification and solution:
The square-shaped keychains cost (5/12) × (4/7) = 5/21 of the original money. The star-shaped keychains cost 3/7 = 9/21, so the total expenditures on star-shaped and square-shaped keychains are in the ratio 9 : 5. This is a money ratio, not necessarily a ratio of numbers of keychains.
Only if the two shapes have the same unit price can we conclude that the number of star-shaped keychains is 15 × 9/5 = 27 and the total is 27 + 15 = 42. Different unit prices allow other counts; for example, with $630 at first, $270 is spent on stars and $150 on 15 squares. There could be 30 stars at $9 each, giving 45 keychains altogether. Both this and the equal-price case satisfy the printed spending information.
The original question therefore lacks the price relationship needed for a determinate answer. Do not grade 42 as uniquely established.