V2/php_payment Sample code doesn't work

Hello all,

I have been trying to get the PHP Sample working (v2/php_payment).

But no matter which card # I use to test, it always returns payment success and I never see the transactions show up in my Sandbox Dashboard.

From the list of cards here: https://developer.squareup.com/docs/testing/test-values, it says that I can use 4000000000000002 to get a “declined error” back. But this card always generates success code instead of failing.

I need to make sure the success/fail works before I can further integrate this solution into my existing PHP app.

Is this list of Card #s no longer valid perhaps? How do I test success/fail using a fake card in the sandbox?

I have a working sandbox and my .env file is correct - I can use the php_checkout sample without issue and it records the transactions in the sandbox. The problem is with the php_payment sample code. I want to use this to keep users on my site and detect the success/fail of their payment (in order to activate memberships, etc on my site), rather than use the checkout which has no return logic.

Any help would be appreciated, thanks!

Also, it always defaults to US (ZIP Code not Postal Code) on this form, even though when I do a VIEW SOURCE I see the location enviromment is being properly detected:

window.currency =
  "CAD";
window.country =
  "CA";

It seems like the php_payment PHP API Sample may need a little review / tweaking in a few areas.

:wave: I was able to replicate the issue and the team is working on it. As for the localization our test card are US based. If you would like to see the Web Payments SDK display postal code you’ll need to enter a CAD card. You can do this by entering in a live CAD card but you won’t be able to process the payments. :slightly_smiling_face:

Thanks for the reply Bryan, am glad you were able to replicate the issue. Thought I was going crazy for a bit, i set up the sample 4 times and kept getting the same result.

Fair enough about the CAD card issue and ZIP/Postal code, I assume that will all work when we go live.

So yes, please advise when the php_payment sample is updated - as it stands, it does not actually put any transactions into the dashboard and just says everything is successful.

A fix for the issue has been deployed. If you get the updated example it works as expected and payments show in the Dashboard. :slightly_smiling_face:

Thank you, that was fast!

Confirmed as working now - I tested a declined card and also a valid card. The valid transaction showed up immediately in the sandbox dashboard.

Now, to figure out how to replace that default $1 value with an amount chosen in my app. Will have to figure out a way to pass that value to the payment form. But I think I can handle that :slight_smile: