question

matiasmassaccesi avatar image
matiasmassaccesi asked David Marginian Deactivated edited

v1/orders/orderID/pay - getting error 401

Hello, I'm having an issue with ecommerce api.


I'm developing a custom website store for my client using clover, it's not an app.


First, I'm creating an order with POST v1/orders and it works perfectly, I'm storing the order's id and then I try to pay for that order with a credit card source and I'm getting error 401. I'm using nodejs as backend. But the most stranger thing is that if I use Postman or clover's api doc's simulator using the same credentials it works perfectly.


I've created API tokens credentials on my sandbox account for Iframe integration, public token on frontend and private token as authorization bearer token


Endpoint used: https://scl-sandbox.dev.clover.com/v1/orders/orderId/pay


Can you please help me with this? I need to finish it asap


Thank you!


Orders
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated commented

Are you making the v1/orders/{orderId}/pay call from your backend/server or from a web browser? In a private/moderators only post can you send me the request url and request body that is failing?

6 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

matiasmassaccesi avatar image matiasmassaccesi commented ·

From my nodejs backend server, I'm creating the order and immediately paying it but pay endpoint doens't work. How can I create a private/moderators only post? Sorry but I don't know how to do it

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ matiasmassaccesi commented ·

Select the Viewable by all users link under the submit button and select viewable by moderator and original poster.

1 Like 1 ·
David Marginian avatar image David Marginian ♦♦ David Marginian ♦♦ commented ·

I don't see an order/pay request for the order you provided. Are you sure that is the correct order?

0 Likes 0 ·
Show more comments
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

Update:

Issue with developers code, the requests weren't even making it to our servers.


Original:

I understand the order was created, there is a record of that in our logs. There is not a record of you attempting to pay for it. Please make the pay request so I can look at the error in the logs.

That being said, I do see a few 409 responses (not 401s) with the error: invalid request, order_already_paid, for other orders for your merchant. Maybe that is the issue, and you are misreading the response. Obviously, you can't pay for an order twice. You may want to consider using idempotency keys to avoid this - https://docs.clover.com/docs/ecommerce-accepting-payments#using-idempotency-keys.

4 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

Nope, I only see the successful request. I checked at our front-end proxy and we only received a single request.

0 Likes 0 ·
matiasmassaccesi avatar image matiasmassaccesi David Marginian ♦♦ commented ·

How can I get a more descriptive error? To know what is missing or something, because I copy and paste every credential to postman en it works. Also I'm having no troubles to create the order, it only fails when I pay it

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ matiasmassaccesi commented ·

As I said, the requests don't even appear to be making it to our front-end, so there is nothing I can help you with. We actually have to receive and process the request to return you a meaningful response. I have no idea what your code is doing, but if things work from Postman there is clearly a problem with it.

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community