Question:
I am trying to access Wix Payments so that my external WebApp (hosted on Azure), linked in Velo, so that I can pay when I click on my buy button, it will connect to WIX payment and allow me to add CC info, name, etc that is required to make purchase.
Any assistance would be hugely appreciated
I created an API Token and tried the following:
import fetch from ‘node-fetch’;
const WIX_API_TOKEN = ‘[MY TOKEN HERE’;
const WIX_PAYMENTS_URL = ‘https://www.wixapis.com/payments/v3/transactions’;
// Function to create a transaction
async function createPaymentTransaction() {
try {
const response = await fetch(WIX_PAYMENTS_URL, {
method: ‘POST’,
headers: {
‘Authorization’: Bearer ${WIX_API_TOKEN}
,
‘Content-Type’: ‘application/json’,
},
body: JSON.stringify({
amount: 10.00, // Payment amount
currency: ‘USD’, // Currency
description: ‘Test Payment’,
buyerInfo: {
email: ‘test@example.com’,
name: ‘John Doe’
}
}),
});
if (!response.ok) {
throw new Error(`Error: ${response.statusText}`);
}
const result = await response.json();
console.log('Payment Transaction Result:', result);
} catch (error) {
console.error('Error creating payment transaction:', error);
}
}
// Call the function
createPaymentTransaction();