seatgeek / api-support

A support channel for the SeatGeek Platform
9 stars 10 forks source link

Seatgeek Checkout API Integration #113

Open svs22121990 opened 3 years ago

svs22121990 commented 3 years ago

Hi,

We are fetching the events data using the Seatgeek events API.

We want to integrate Checkout process on our website.

Getting the Information Necessary to Render a Checkout Form GET /listings/{listing_id}?event_id=123&quantity=1&country=US&state=NY

We are trying the render the checkout page using the above API. Can you guide us how to fetch the listing id for a event ? We cannot get it from the events api.

When we try to authenticate the API using below method The authentication code can be calculated as such, where client_secret is the SeatGeek API client secret that corresponds to the passed client id:

    hmac_signature = BASE64( HMAC_SHA1( client_secret, UPPERCASE( method ) + "\n" + path + "\n" + body ) )

Our Code const Checkout = ({ match }) => { const eventid = match.params.eventid; const [ events, setEvents ] = useState(null); const body=""; const hmacDigest = Base64.stringify(hmacSHA1( client_secret,"POST" + "\n/" + match.url + "\n" + body)); console.log(hmacDigest); useEffect(() => { const fetchPrismicData = async () => { try { const eventsDoc = await fetch("https://api.seatgeek.com/2/listings/123456?event_id="+eventid,{ method: 'POST', headers: { 'Authorization': 'SG '+client_id+':'+hmacDigest, 'Access-Control-Allow-Origin':'*' } }) .then(res => res.json().then(events => setEvents(events)));

        } catch (error) {
            console.error(error);
        }
    }

    fetchPrismicData();
  }, []);

We get an 403 unauthrorized error as a response.

Regards,