Get postal code from form

I’m using the Square credit card form to add a card on file, so I enter the cc number, expiration date, cvv, and zip code. But when I check the response, Square doesn’t return the zip code (only the last 4, etc.)

What do I do to get the zip code that I typed in the Square form if I want to store it in my database? I don’t think it’s a good idea to add another field for the zip code in my form because the user has to type it twice.

This is my code:
$billingAddress = new Address();


There are two options here and I’m not certain which you want so mentioning both.

If you already have the postal code from somewhere in your application, you can use it in SetPostalCode() so the Square Form displays the postcode as default and the customer doesn’t have to enter it again.

If you want to get the postal_code entered in the Square card form, I’m not certain but I think the entered postal code might be in the object returned from CreatePaymentRequest() - you should be able to see it in either the API Explorer or an object returned from a sandbox transaction. It might be under one of the address fields; in either case, if you dump that returned object you’ll see what’s in there.

If I got any of this wrong hopefully Bryan will correct me!