question

packya avatar image
packya asked jcy answered

Ecommerce /orders/orderid/pay method returns 401 Unauthorized error

I hit this API from the post man and receiving the unauthorized error, my app has read and write permission of the payment also, can anyone please help me to resolve this?

1723086884277.png

ecommerceDeveloper Pay API
1723086884277.png (107.0 KiB)
10 |2000

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

parquet76 avatar image
parquet76 answered packya commented

Clover has a documentation page on unauthorized/401 errors. Please search for it and read it. They also have an e-commerce page that lists the required permissions.

2 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.

packya avatar image packya commented ·

I have all the permissions as per the document and the token also working fine in other APIs.
Whether the app should be published to access the orders/orderId/pay method ?




1723092606493.png

0 Likes 0 ·
1723092606493.png (88.7 KiB)
packya avatar image packya commented ·

Here is my code

  const reqData =  {
        "ecomind": "moto",
        "customer": "customerId",
        "email": "customer_email",
        "expand": ["customer"]
      }
      const options = {
        method: 'POST',
        url: `https://scl.clover.com/v1/orders/${orderId}/pay`,
        headers: {
          'accept': 'application/json',
          'content-type': 'application/json',
          'authorization': 'Bearer <token>',
          "x-forwarded-for": "49.204.141.142"
        },
        data: reqData,
        httpsAgent: new https.Agent({
          rejectUnauthorized: false
        })
      };
      
      axios
        .request(options)


and here is my order response

{
    "id": "orderId",
    "object": "order",
    "amount": 4000,
    "currency": "USD",
    "created": 1723085129000,
    "customer": "customerId",
    "email": "customerEmail",
    "items": [
        {
            "type": "sku",
            "quantity": 1,
            "amount": 4000,
            "currency": "usd",
            "description": "Test item 6"
        },
        {
            "type": "tax",
            "description": "Taxes (included)"
        }
    ],
    "shipping": {
        "name": "Hemal",
        "address": {
            "line1": "Address line 1",
            "city": "",
            "state": "",
            "postal_code": "",
            "country": ""
        }
    },
    "status": "created"
}

Did I missed anything ?

0 Likes 0 ·
jcy avatar image
jcy answered

try Ecommerce API Tokens in dashboard setup

1723096682601.png


1723096682601.png (12.6 KiB)
10 |2000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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

Welcome to the
Clover Developer Community