Get Checkout ID and Understand Order Status

We're thrilled to unveil two new endpoints designed to enhance your checkout experience. These additions allow you to monitor the status of your Checkout by initiating a checkout session and subsequently, track Order IDs via Checkout IDs.

Here are the 4 steps for you to achieve this:

  1. Create a Checkout Session: You can initialize a checkout session by sending a POST request to /checkouts. This will create a session where your application can redirect a user for payment.

Example Request:

curl --request POST  
     --url <https://sandbox.api.southpole.com/compensations/v1/checkouts>  
     --header 'accept: application/json'  
     --header 'authorization: Bearer <access token>'  
     --header 'content-type: application/json'  
     --data '  
{  
  "currency": "EUR",  
  "compensations": [  
    {  
      "intent": {  
        "unit": "t",  
        "quantity": "1"  
      },  
      "projectId": "1234567890"  
    }  
  ]  
}

Example Response:

{  
  "id": "1234567890",  
  "status": "OPEN",  
  "url": "<https://south-pole-staging.myshopify.com/xxxxxx%22>  
}
  1. Redirect User to Session URL: The previous step's response includes a URL (response.url). Redirect the user to this URL to proceed with the payment.
  2. Query Checkout Status: After the user has made the payment, you can query the status of the checkout by sending a GET request to /checkouts/.

Example Request:

curl --request GET  
     --url <https://sandbox.api.southpole.com/compensations/v1/checkouts/1234567890>  
     --header 'accept: application/json'  
     --header 'authorization: Bearer <access token>'

Example Response:

{  
  "id": "1234567890",  
  "status": "COMPLETED",  
  "url": "<https://south-pole-staging.myshopify.com/xxxxxx%22>,  
  "orderId": "1234567890123"  
}
  1. Retrieve Order and Certificate URL: Lastly, you can retrieve the order and certificate URL by sending a GET request to /orders/<checkout.orderId>. The certificate URL can be used to download the certificate as a PDF.

Example Request:

curl --request GET  
     --url <https://sandbox.api.southpole.com/compensations/v1/orders/1234567890123>  
     --header 'accept: application/json'  
     --header 'authorization: Bearer <access token>'

Example Response:

{  
  "compensations": [  
    {  
      "contribution": {  
        "amount": "60",  
        "currency": "EUR"  
      },  
      "projectId": "1234567890",  
      "volume": {  
        "quantity": "1",  
        "unit": "t"  
      }  
    }  
  ],  
  "consumer": {  
    "email": "[email protected]",  
    "company": "South Pole",  
    "firstName": "john",  
    "lastName": "does",  
    "address1": "Address",  
    "zip": "10717",  
    "city": "Berlin",  
    "country": "DEU"  
  },  
  "createdAt": "2023-06-08T11:24:16Z",  
  "id": "123456789",  
  "status": "COMPLETED",  
  "totalPrice": {  
    "amount": "60",  
    "currency": "EUR"  
  },  
  "totalVolume": {  
    "quantity": "1",  
    "unit": "t"  
  },  
  "updatedAt": "2023-06-08T11:24:24Z",  
  "certificateUrl": "<https://staging.api.southpole.com/certificates/v1/download?output=pdf&orderId=123456789&shopId=0&signature=xxx>"  
}

This simplified flow streamlines the checkout process, enhancing user experience and efficiency. Please let us know if you need any further guidance.