Specifying redirect_url in Checkout API V2 example

I’m following the PHP example listed here: connect-api-examples/connect-examples/v2/php_checkout at master · square/connect-api-examples · GitHub

Where would the redirect_url be configured if I were to implement it in this example?

Per the documentation:
You can also configure a URL for customers to be redirected to, once they complete their purchase, to verify that the payment went through successfully.

I saw others referencing something like this:

However, it does not work and apache logs show $checkout as undefined.

:wave: With the php_checkout example you can set the redirectUrl by adding the following to the $checkout_request

$checkout_request->setRedirectUrl('https://yourCustomUrl.com'); the following in the in the :slightly_smiling_face:

Thank you! My Sandbox test card numbers are all showing as “Card verification failed” all of the sudden. I’m sure it’s unrelated.

What’s your application Id and what test value is this with?

AppID: sandbox-sq0idb-bbLNvihjO7yih6nM0gqUEA

I tried nearly every test account number here: https://developer.squareup.com/docs/testing/test-values

For the most part I’m testing with the Visa 4111 1111 1111 1111 CVV 111


I can’t seem to replicate this. What browser are you using?

It started working again without any changes (was using Firefox).

One last question:
I need to pass additional GET variables in the redirect URL. When I include the variables in the redirect URL it fails, assuming because of the URL formatting containing multiple ?'s.

I see there is a state variable in oauth implementations that may be capable of this. Is there something similar for V2? GET /oauth2/authorize - Square API Reference

EDIT: I just figured out I can probably do this by setting referenceid to a custom value and parsing that, but hopefully there’s a better way.

Currently passing additional variables in the redirect URL isn’t supported with the Checkout API. Using the reference_id is what you will want to use.