// In your backend route handler after creating checkout session
app.post('/deposit', async (req, res) => {
try {
// Make request to Soap API to create checkout session
const user = { soap_customer_id: 'cus_LzgkjLVrNPnHqp6gUsK8TBtQPq4kf6R1' } // your signed in user
const response = await fetch('https://api-sandbox.paywithsoap.com/api/v1/checkouts', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SOAP_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
customer_id: user.soap_customer_id,
type: 'deposit'
})
});
const checkoutSession = await response.json();
// Return the client_secret to the frontend
res.json({
url: checkoutSession.url
});
} catch (error) {
res.status(500).json({ error: error.message });
}
});