Server-side Integration

Documentation for Pairly API Server-side Integration

How it works

Server-side integration allows your brand greater control over UI decisions and payment flow from your customers. It works in the following steps:

  1. First your customer enters the checkout portal to make a purchase.
  2. Create an Unconfirmed Transaction: Your server sends your customer's purchase info (e.g. flight details or cruise specs) to Pairly. Then, Pairly makes the transaction and sends back the transaction id, carbon footprint, and cost of offsetting.
  3. Your server displays this information to your customer on your custom UI.
  4. If the customer chooses to offset, the offset cost is added to the payment total. Then, customer enters payment information and confirms payment to your servers.
  5. Confirm a Transaction: Upon confirmation from customer and receiving the payment, your server notifies us of the customer's decision using the transaction id from step 2.

Pairly records transactions logged by your service over time and sends an email confirmation to your customers. At the end of each billing cycle, Pairly invoices your business with the amount your customers contributed. If you have in house carbon footprint models for your business, we accommodate your estimates in our first API call.

Create an Unconfirmed Transaction

Use the transaction API to make an initial unconfirmed transaction, estimate carbon footprint, and get offset pricing.

Create a Transaction with Flight Info

Use our models to infer carbon footprint emitted on flights, get back estimations and best carbon offset prices

Request URL
POST https://api.pairly.me/v1/transaction/flight/

Request Body

  • flight_legs (required, array of Objects): legs of flight as a list
    • airline (required, string): flight airline carrier
    • flight_number (required, string): flight number
    • date (required, integer): date of flight in YYYYMMDD format
    • airport_code_type (optional, string): either "iata" or "icao", defaults to "iata"
    • origin_airport (required, string): code of origin airport, specify code type using airport_code_type
    • destination_airport (required, string): code of destination airport, specify code type using airport_code_type
    • cabin_class (optional, string): either "economy" or "premium", defaults to "economy"
  • currency (optional, string): requested currency code of price, defaults to "USD"
  • passenger_count (optional, integer > 0) = number of passengers, defaults to 1
  • email (optional, string): email of client
  • tag (optional, string): additional information to filter by like name of OTA site, company name, etc.
curl --location --request POST 'https://api.pairly.me/v1/transaction/flight/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "currency": "USD",
    "flight_legs":[
        {"airline": "American Airlines",
        "flight_number":"AA 123",
        "date":20220710,
        "origin_airport": "BOS",
        "destination_airport":"SFO",
        "airport_code_type": "iata",
        "cabin_class":"economy"
        },
         {"airline": "United Airlines",
        "flight_number":"UA 1234",
        "date":20220731,
        "origin_airport": "SFO",
        "destination_airport":"BOS",
        "airport_code_type": "iata",
        "cabin_class":"economy"
        }
    ]
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/flight/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "currency": "USD",
    "flight_legs":[
        {"airline": "American Airlines",
        "flight_number":"AA 123",
        "date":20220710,
        "origin_airport": "BOS",
        "destination_airport":"SFO",
        "airport_code_type": "iata",
        "cabin_class":"economy"
        },
         {"airline": "United Airlines",
        "flight_number":"UA 1234",
        "date":20220731,
        "origin_airport": "SFO",
        "destination_airport":"BOS",
        "airport_code_type": "iata",
        "cabin_class":"economy"
        }
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.pairly.me/v1/transaction/flight/',
  'headers': {
    'X-API-Key': '<YOUR_SECRET_KEY>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"currency":"USD","flight_legs":[{"airline":"American Airlines","flight_number":"AA 123","date":20220710,"origin_airport":"BOS","destination_airport":"SFO","airport_code_type":"iata","cabin_class":"economy"},{"airline":"United Airlines","flight_number":"UA 1234","date":20220731,"origin_airport":"SFO","destination_airport":"BOS","airport_code_type":"iata","cabin_class":"economy"}]})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response Body

  • id (string): id of transaction
  • company (string): id of your company
  • project (string): id of project for offsetting
  • activity_description (string): description of flight
  • activity_type (string): type of footprint, e.g. "flight"
  • estimate_mass_kilograms (integer): estimated mass of carbon footprint in kg
  • estimate_price_cents (integer): price of offsetting in cents
  • currency (string): currency code of price in response
  • consumer_impact (string): a sentence describing the impact of the carbon footprint for consumers
  • tag (string): the tag for the transaction
{
    "id": "57a070c4-1a44-40d3-8711-163916222e03",
    "company": "db0d45d8-3cac-49b5-a8d0-f88907f9ddb1",
    "project": "53f9956f-bfd4-47bc-81dd-935259d55d9a",
    "activity_description": "flight booked on Your Brand",
    "activity_type": "flight",
    "estimate_mass_kilograms": 1181,
    "estimate_price_cents": 2613,
    "currency": "USD",
    "consumer_impact":"That’s the same impact as leaving a light bulb on for 6 years."
}

Create a Transaction with Ferry Info

Use our models to infer carbon footprint emitted on ferry, get back estimations and best carbon offset prices

Request URL
POST https://api.pairly.me/v1/transaction/ferry/

Request Body

  • ferry (required, Object): ferry ship data
    • trip_length_hours (required, decimal): the length of the journey in hours
    • ship_passenger_capacity (optional, integer): the number of passengers onboard the ferry, defaults to 200
    • ship_vehicle_capacity (optional, integer): the number of passengers onboard the ferry, defaults to 50
    • gross_tonnage (optional, integer): the gross tonnage of the ship, defaults to 2000
  • currency (optional, string): requested currency code of price, defaults to "USD"
  • passenger_count (optional, integer > 0) = number of passengers, defaults to 1
  • vehicle_count (optional, integer >= 0) = number of passengers, defaults to 0
  • email (optional, string): email of client
  • tag (optional, string): additional information to filter by like name of OTA site, company name, etc.
curl --location --request POST 'https://api.pairly.me/v1/transaction/ferry/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "currency": "USD",
    "ferry": {
        "trip_length_hours": 24,
        "ship_passenger_capacity": 306,
        "ship_vehicle_capacity": 50,
        "gross_tonnage": 3000
    },
    "passenger_count": 2,
    "vehicle_count": 1
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/ferry/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "currency": "USD",
    "ferry": {
        "trip_length_hours": 24,
        "ship_passenger_capacity": 306,
        "ship_vehicle_capacity": 50,
        "gross_tonnage": 3000
    },
    "passenger_count": 2,
    "vehicle_count": 1
}',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("X-API-Key", "<YOUR_SECRET_KEY>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"currency":"USD","ferry":{"trip_length_hours":24,"ship_passenger_capacity":306,"ship_vehicle_capacity":50,"gross_tonnage":3000},"passenger_count":2,"vehicle_count":1});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.pairly.me/v1/transaction/ferry/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Response Body

  • id (string): id of transaction
  • company (string): id of your company
  • project (string): id of project for offsetting
  • activity_description (string): description of ferry
  • activity_type (string): type of footprint, e.g. "ferry"
  • estimate_mass_kilograms (integer): estimated mass of carbon footprint in kg
  • estimate_price_cents (integer): price of offsetting in cents
  • currency (string): currency code of price in response
  • consumer_impact (string): a sentence describing the impact of the carbon footprint for consumers
  • tag (string): the tag for the transaction
{
    "id": "04c7472d-1db0-4f99-aaa6-0870ac6dac58",
    "company": "db0d05d8-3cac-49b5-a8d0-f88907f9ddb1",
    "project": "53f9956f-bfd4-47bc-81dd-935b59d55d9b",
    "activity_description": "ferry booked on Your Brand",
    "activity_type": "ferry",
    "estimate_mass_kilograms": 37,
    "estimate_price_cents": 109,
    "currency": "USD",
    "consumer_impact": "That’s the same impact as leaving a light bulb on for 1 year."
}

Create a Transaction with Cruise Info

Use our models to infer carbon footprint emitted on cruise, get back estimations and best carbon offset prices

Request URL
POST https://api.pairly.me/v1/transaction/cruise/

Request Body

  • cruise (required, Object): cruise ship data
    • trip_length_hours (required, decimal): the length of the journey in hours
    • ship_capacity (optional, integer): the number of passengers onboard the cruise, defaults to 1000
    • gross_tonnage (optional, integer): the gross tonnage of the ship, defaults to 10000
  • currency (optional, string): requested currency code of price, defaults to "USD"
  • passenger_count (optional, integer > 0) = number of passengers, defaults to 1
  • email (optional, string): email of client
  • tag (optional, string): additional information to filter by like name of OTA site, company name, etc.
curl --location --request POST 'https://api.pairly.me/v1/transaction/cruise/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "currency": "USD",
    "cruise": {
        "trip_length_hours": 168,
        "ship_capacity": 306,
        "gross_tonnage": 8539
    }
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/cruise/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "currency": "USD",
    "cruise": {
        "trip_length_hours": 168,
        "ship_capacity": 306,
        "gross_tonnage": 8539
    }
}',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("X-API-Key", "<YOUR_SECRET_KEY>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"currency":"USD","cruise":{"trip_length_hours":168,"ship_capacity":306,"gross_tonnage":8539}});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.pairly.me/v1/transaction/cruise/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Response Body

  • id (string): id of transaction
  • company (string): id of your company
  • project (string): id of project for offsetting
  • activity_description (string): description of cruise
  • activity_type (string): type of footprint, e.g. "cruise"
  • estimate_mass_kilograms (integer): estimated mass of carbon footprint in kg
  • estimate_price_cents (integer): price of offsetting in cents
  • currency (string): currency code of price in response
  • consumer_impact (string): a sentence describing the impact of the carbon footprint for consumers
  • tag (string): the tag for the transaction
{
    "id": "0fb5c4b6-ca3c-44fc-a68c-dc5dd12806fc",
    "company": "db0d05d8-3cac-49b5-a8d0-f88907f9ddb1",
    "project": "53f9956f-bfd4-47bc-81dd-935b59d55d9b",
    "activity_description": "cruise booked on Your Brand",
    "activity_type": "cruise",
    "estimate_mass_kilograms": 1153,
    "estimate_price_cents": 1759,
    "currency": "USD",
    "consumer_impact": "That’s the same impact as leaving a light bulb on for 6 years."
}

Create a Transaction with Car Info

Use our models to infer carbon footprint emitted on a car, get back estimations and best carbon offset prices

Request URL
POST https://api.pairly.me/v1/transaction/car/

Request Body

  • car (required, Object): cruise ship data
    • make (optional, string): the make of the car
    • model (optional, string): the model of the car
  • distance_m (required, integer > 0): distance traveled in meters
  • currency (optional, string): requested currency code of price, defaults to "USD"
  • email (optional, string): email of client
  • tag (optional, string): additional information to filter by like name of OTA site, company name, etc.
curl --location --request POST 'https://api.pairly.me/v1/transaction/car/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "distance_m": 500000,
    "car": {
        "make": "toyota",
        "model": "camry"
    }
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/car/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "distance_m": 500000,
    "car": {
        "make": "toyota",
        "model": "camry"
    }
}',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("X-API-Key", "<YOUR_SECRET_KEY>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"distance_m":500000,"car":{"make":"toyota","model":"camry"}});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.pairly.me/v1/transaction/car/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Response Body

  • id (string): id of transaction
  • company (string): id of your company
  • project (string): id of project for offsetting
  • activity_description (string): description of car trip
  • activity_type (string): type of footprint, e.g. "car"
  • estimate_mass_kilograms (integer): estimated mass of carbon footprint in kg
  • estimate_price_cents (integer): price of offsetting in cents
  • currency (string): currency code of price in response
  • consumer_impact (string): a sentence describing the impact of the carbon footprint for consumers
  • tag (string): the tag for the transaction
{
    "id": "65bf9e90-5743-426d-86a1-f0e50595f3ad",
    "company": "db0d05d8-3cac-49b5-a8d0-f88907f9ddb1",
    "project": "53f9956f-bfd4-47bc-81dd-935b59d55d9b",
    "activity_description": "car trip booked on Your Brand",
    "activity_type": "car",
    "estimate_mass_kilograms": 120,
    "estimate_price_cents": 217,
    "currency": "USD",
    "consumer_impact": "That’s the same impact as leaving a light bulb on for 1 year."
}

Create a Transaction with Shipping Info

Use our models to infer carbon footprint emitted on shipping, get back estimations and best carbon offset prices

Request URL
POST https://api.pairly.me/v1/transaction/shipping/

Request Body

  • transportation_method (required, string): method of transportation, must be one of ['air', 'road', 'sea', 'rail']
  • mass_g (required, integer > 0): mass shipped in grams
  • distance_m (required, integer > 0): distance traveled in meters
  • currency (optional, string): requested currency code of price, defaults to "USD"
  • email (optional, string): email of client
  • tag (optional, string): additional information to filter by like name of OTA site, company name, etc.
curl --location --request POST 'https://api.pairly.me/v1/transaction/shipping/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "mass_g": 1000000,
    "distance_m": 3000000,
    "transportation_method": "air"
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/shipping/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "mass_g": 1000000,
    "distance_m": 3000000,
    "transportation_method": "air"
}',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("X-API-Key", "<YOUR_SECRET_KEY>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"mass_g":1000000,"distance_m":3000000,"transportation_method":"air"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.pairly.me/v1/transaction/shipping/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Response Body

  • id (string): id of transaction
  • company (string): id of your company
  • project (string): id of project for offsetting
  • activity_description (string): description of shipping
  • activity_type (string): type of footprint, e.g. "shipping"
  • estimate_mass_kilograms (integer): estimated mass of carbon footprint in kg
  • estimate_price_cents (integer): price of offsetting in cents
  • currency (string): currency code of price in response
  • consumer_impact (string): a sentence describing the impact of the carbon footprint for consumers
  • tag (string): the tag for the transaction
{
    "id": "4da71249-afec-4e33-bf02-c6e065e7b175",
    "company": "b8c016d2-4d06-4147-a353-2797f8e29846",
    "project": "53f9956f-bfd4-47bc-81dd-935b59d55d9b",
    "activity_description": "shipping booked on GTT",
    "activity_type": "shipping",
    "estimate_mass_kilograms": 2172,
    "estimate_price_cents": 3377,
    "currency": "USD",
    "consumer_impact": "That’s the same impact as leaving a light bulb on for 11 years."
}

Create a Transaction with CO2 Info

For brands that have in house estimators or already calculated a CO2 footprint, use this endpoint to make an unconfirmed transaction and get back the best carbon offset prices

Request URL
POST https://api.pairly.me/v1/transaction/

Request Body

  • activity_description (required, string): description of activity emitted CO2
  • activity_type (required, string): type of footprint, e.g. "flight"
  • estimate_mass_kilograms (required, integer): estimated mass of carbon footprint in kg
  • currency (optional, string): requested currency code of price, defaults to "USD"
  • tag (optional, string): additional information to filter by like name of OTA site, company name, etc.
curl --location --request POST 'https://api.pairly.me/v1/transaction/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "activity_description": "shipping paper towels on amazon",
    "activity_type": "shipping",
    "estimate_mass_kilograms": 122,
    "currency": "USD"
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "activity_description": "shipping paper towels on amazon",
    "activity_type": "shipping",
    "estimate_mass_kilograms": 122,
    "currency": "USD"
}',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.pairly.me/v1/transaction/',
  'headers': {
    'X-API-Key': '<YOUR_SECRET_KEY>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"activity_description":"shipping paper towels on amazon","activity_type":"shipping","estimate_mass_kilograms":122,"currency":"USD"})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response Body

  • id (string): id of transaction
  • company (string): id of your company
  • project (string): id of project for offsetting
  • activity_description (string): description of purchase
  • activity_type (string): type of footprint, e.g. "flight"
  • estimate_mass_kilograms (integer): estimated mass of carbon footprint in kg
  • estimate_price_cents (integer): price of offsetting in cents
  • currency (string): currency code of price in response
  • consumer_impact (string): a sentence describing the impact of the carbon footprint for consumers
  • tag (string): the tag for the transaction
{
    "id": "e767b9a4-ab5d-423d-a6d7-9d3cf089f035",
    "company": "db0d05z8-3cac-49b5-a8d0-f88907f9ddb1",
    "project": "53f9956f-bfd4-47bc-81zd-935b59d55d9a",
    "activity_description": "shipping paper towels on amazon",
    "activity_type": "shipping",
    "estimate_mass_kilograms": 122,
    "estimate_price_cents": 270,
    "currency": "USD",
    "consumer_impact": "That’s the same impact as leaving a light bulb on for 1 year."
}

Confirm a Transaction

Use to confirm a customer's action on an unconfirmed transaction. All transactions should be confirmed through this endpoint regardless of how much the customer chooses to offset.

Patch a Transaction to Confirm

Request URL
PATCH https://api.pairly.me/v1/transaction/<transaction_id>/

Request Body

  • fraction_offset (required, decimal >= 0): fraction of carbon footprint offset, 1 designates offset entire footprint, 0 designates offset none of it
  • email (required, string): email of client
curl --location --request PATCH 'https://api.pairly.me/v1/transaction/<transaction_id>/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "fraction_offset": 1,
    "email": "[email protected]"
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/<transaction_id>/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PATCH',
  CURLOPT_POSTFIELDS =>'{
    "fraction_offset": 1,
    "email": "[email protected]"
}',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'PATCH',
  'url': 'https://api.pairly.me/v1/transaction/<transaction_id>/',
  'headers': {
    'X-API-Key': '<YOUR_SECRET_KEY>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"fraction_offset":1,"email":"[email protected]"})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response Body

  • id (string): id of transaction
  • user (string): id of user
  • company (string): id of your company
  • project (string): id of project for offsetting
  • activity_description (string): description of purchase
  • activity_type (string): type of footprint, e.g. "flight"
  • estimate_mass_kilograms (integer): estimated mass of carbon footprint in kg
  • estimate_price_cents (integer): price of offsetting in cents
  • currency (string): currency code of price in response
  • confirmed (boolean): true
  • offset_mass_kilograms (integer): kilograms of carbon offset, calculated by multiplying fraction_offset and estimate_mass_kilograms
  • total_paid_cents (integer): total amount paid / invoiced to customer for offset, calculated by multiplying fraction_offset and estimate_price_cents
{
    "id": "f2c3ccc9-2298-4cs0-a716-f86bfabc7567",
    "user": "be5032z6-432f-4eb0-aad5-3695edfe59d5",
    "company": "db0d05d8-3cac-49b5-a8d0-ff8907g9ddb1",
    "project": "53f9956f-bfd4-47bc-81dd-9a5b59d55d9a",
    "activity_description": "flight booked on Your Brand",
    "activity_type": "flight",
    "estimate_mass_kilograms": 1116,
    "estimate_price_cents": 2039,
    "currency": "GBP",
    "confirmed": true,
    "offset_mass_kilograms": 1116,
    "total_paid_cents": 2039
}

Get a Transaction

Get the details of a transaction (both confirmed and unconfirmed) by id

Request URL
GET https://api.pairly.me/v1/transaction/<transaction_id>/

curl --location --request GET 'https://api.pairly.me/v1/transaction/<transaction_id>/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/<transaction_id>/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.pairly.me/v1/transaction/<transaction_id>/',
  'headers': {
    'X-API-Key': '<YOUR_SECRET_KEY>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response Body

  • id (string): id of transaction
  • user (string): id of user
  • company (string): id of your company
  • project (string): id of project for offsetting
  • activity_description (string): description of purchase
  • activity_type (string): type of footprint, e.g. "flight"
  • estimate_mass_kilograms (integer): estimated mass of carbon footprint in kg
  • estimate_price_cents (integer): price of offsetting in cents
  • currency (string): currency code of price in response
  • confirmed (boolean): true if and only if the confirm transaction endpoint was called
  • offset_mass_kilograms (integer): kilograms of carbon offset, calculated by multiplying fraction_offset and estimate_mass_kilograms; if transaction is unconfirmed, defaults to 0
  • total_paid_cents (integer): total amount paid / invoiced to customer for offset, calculated by multiplying fraction_offset and estimate_price_cents; if transaction is unconfirmed, defaults to 0
{
    "id": "f2c3ccc9-2298-4cs0-a716-f86bfabc7567",
    "user": "be5032z6-432f-4eb0-aad5-3695edfe59d5",
    "company": "db0d05d8-3cac-49b5-a8d0-ff8907g9ddb1",
    "project": "53f9956f-bfd4-47bc-81dd-9a5b59d55d9a",
    "activity_description": "flight booked on Your Brand",
    "activity_type": "flight",
    "estimate_mass_kilograms": 1116,
    "estimate_price_cents": 2039,
    "currency": "GBP",
    "confirmed": true,
    "offset_mass_kilograms": 1116,
    "total_paid_cents": 2039
}

Delete a Transaction

Use to delete a transaction. This should only be used in the case of a refund or return by your customer.

Request URL
DELETE https://api.pairly.me/v1/transaction/<transaction_id>/

curl --location --request DELETE 'https://api.pairly.me/v1/transaction/<transaction_id>/' \
--header 'X-API-Key: <YOUR_SECRET_KEY>'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.pairly.me/v1/transaction/<transaction_id>/',
  CURLOPT_USERAGENT => 'curl/7.86.0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    'X-API-Key: <YOUR_SECRET_KEY>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://api.pairly.me/v1/transaction/<transaction_id>/',
  'headers': {
    'X-API-Key': '<YOUR_SECRET_KEY>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response Body
empty body