Securing PayEngine Webcomponents
Obtaining a new Merchant Session
const axios = require('axios');
const express = require('express');
const app = express();
// Replace with your actual API endpoint and any necessary authentication
const API_ENDPOINT = 'https://<PAYENGINE_HOST>/api/merchant'; // Example endpoint
const API_KEY = 'your_api_key'; // PayEngine API Key
const MERCHANT_ID = 'your_merchant_id'; // PayEngine assigned Merchant ID
app.post('/accessToken', async (req, res) => {
try {
const data = {
expires_in: 900,
// Setting scope to 'readonly' restricts actions like hiding the Refund button in the transaction widget
scope: 'readonly' // Optional.
};
const apiURL = `${API_ENDPOINT}/${MERCHANT_ID}/sessions`;
const response = await axios.post(apiURL, data, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${API_KEY}`,
},
});
// ... code to store session in the backend
res.json({
access_token: response.data.access_token,
expires_in: response.data.expires_in
});
} catch (error) {
// ERROR HANDLING AND RETRYING
}
});
Load PayEngine Library
Logout - Revoke Access Token
Last updated