Hello everyone!
I’m taking the first steps to integrate Square into my website. I am using SDK PHP and createPaymentLink API.
To confirm the payment I am using webhooks.
I get two types of webhooks: order.updated and payment.updated.
In order.updated the order arrives with “OPEN” state after simulating the payment in the sandbox
According to the documentation there is a final state called “COMPLETED” but in the sandbox it never arrives.
My question is: if I receive a webhook with “OPEN” state in the order, is it enough to confirm that the payment was made? What has to happen for it to go from OPEN to COMPLETED?
Thank you very much!
Payments from payment links won’t automatically complete an order. Ideally you’ll want to look for a payment_id
in the order.updated
event. Once there’s a payment_id
you can call the GetPayment with the ID to get the result of the payment.
OKAY! I’m testing with the payment.* webhooks. Initially the status is “APPROVED” and then an update arrives and it changes to “COMPLETED”
In the API documentation it says that the possible statuses are: APPROVED, PENDING, COMPLETED, CANCELED, or FAILED
What would be the state with which I make sure that the payment was made? Only with COMPLETED?
With the payments webhooks once a payment is COMPLETED that’s the final settled state of the payment. At that point you can either use the payload of the webhook to pull any additional information from the payment or use the IDs in the payload to call our APIs.
I’m also just getting started with the createPaymentLink API, but I wasn’t using webhooks, I was relying on the redirectURL option that is sent with the create payment request. I’m getting the checkout link URL in the response to the create payment request, and I’m redirecting the user from my site to the checkout link on the Square server. When the payment is completed, I am assuming that they’ll be redirected to my redirectURL that is specified with the order ID.
But my question is… Would the user be redirected back to my site for any reason other than the payment was complete? I’m assuming that if the payment fails, the user just stays on the checkout link page until the payment is completed successfully, and then they’re redirected back to my site with the redirectURL I specify. But is it possible for a user to be redirected back to my redirectURL by Square without a successful payment?
Also, is there a way to specify a “back to {my site}” link on the checkout link page? It seems like the only way a user can go back to my site from the checkout link page is to use the back button. I would think there would be a way to add a link to the payment page that would let the user go back to my site just by clicking on a link in case the buyer changes their mind and isn’t ready to pay.
With the payment link a redirect will only happen once a payment is successful. If a payment is unsuccessful the customer checkout page will display an error/decline and will allow the customer to reattempt payment.
At this time there isn’t a redirect button or link that’s shown on the checkout page for the customer to be redirected to your site.
Ok, thank you, I just wanted to confirm that if square redirects someone to my confirmation page specified by the redirectURL, that I can be sure that they paid successfully because that is where I enable their account for the features they paid for.
Also, you should definitely submit a request to the developers to add a simple link back to the original site where the person came. I don’t think I’ve ever used a payment integration where the user leaves the original site to pay for something and doesn’t have a way to get back to the original site without submitting a payment. A simple link back to whatever the referring website was would suffice, but a better solution would be to let the create payment link request include an additional variable called “cancelUrl”, just like it does with the “redirectUrl”, and on the payment link page display a link to the cancelUrl that is submitted with simple text like, “If you’d like to cancel your payment and return to {SITE NAME}, click here”.
We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team.