The American fintech Square has reached an agreement to buy the Australian firm Afterpay in an all-stock deal with an implied value of about $29 billion based on Square’s share price on July 30. Afterpay specializes in buy now, pay later (BNPL) services.