Hi,
I've worked with Square before, and I can produce the script you're after. From my understanding, you would like one script that calls their checkout form and populates the values, and a second script that takes the outcome of the payment (success/failure) as well as the payment reference etc, put into an array. If there's anything extra, please feel free to contact me and we can discuss your project further.
Thanks,
Dan