New to working with payment processing so I’m a bit confused. Working in Sandbox mode.
I’m working on adding createPayment api to my backend and deploying it to firebase functions.
when I run the request in postman using: ```
https://connect.squareupsandbox.com/v2/payments
everything works just fine.
when i replace it with my firebase deployed endpoint: https://us-central1-ai-email-maker.cloudfunctions.net/createPayment
using the same authorization, headers, and body i always get a 401 error.
const baseUrl = “https://connect.squareupsandbox.com”;
// Construct the API endpoint and request payload
const endpoint = "/v2/payments";
const url = baseUrl + endpoint;
const requestData = {
idempotency_key: idempotencyKey,
source_id: sourceId,
amount_money: {
amount,
currency,
},
autocomplete: true,
accept_partial_authorization: false,
};
// Make a POST request to create a payment
const fetchOptions = {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
"Square-Version": "2023-08-16",
},
body: JSON.stringify(requestData),
};
const apiResponse = await fetch(url, fetchOptions);
const responseData = await apiResponse.json();
i also have my accessToken just left it out for security reasons.