### Install ScalaPay NPM Package Source: https://github.com/scala-network/scalapay-merchant-npm/blob/master/README.md Use this command to install the scalapay package via npm. Ensure Node.js is installed. ```sh $ npm i scalapay ``` -------------------------------- ### Configure ScalaPay API Client Source: https://github.com/scala-network/scalapay-merchant-npm/blob/master/README.md Create a configuration file to export the initialized ScalaPay client. This allows for easy import in other modules. ```js var scalapay = require('scalapay'); var Scala = scalapay.login({ token: "MERCHANT_TOKEN" }); module.exports = Scala; ``` -------------------------------- ### Configure and Use ScalaPay Client Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Centralize client initialization in a configuration module and import it into application handlers to perform transfers and address generation. ```javascript // config/ScalaAPI.js - Create this configuration file const scalapay = require('scalapay'); const Scala = scalapay.login({ token: process.env.SCALAPAY_MERCHANT_TOKEN || 'YOUR_MERCHANT_TOKEN' }); module.exports = Scala; // payment-handler.js - Use the configured client const scala = require('./config/ScalaAPI'); // Process a customer payment refund function processRefund(customerEmail, amountInCents) { scala.transfer(customerEmail, amountInCents.toString(), function(error, result) { if (error) { console.error('Refund failed:', error); return; } console.log('Refund processed:', result); }); } // Generate payment address for checkout function createPaymentAddress(callback) { scala.generateAddress(function(error, result) { if (error) { return callback(error, null); } callback(null, result); }); } module.exports = { processRefund, createPaymentAddress }; ``` -------------------------------- ### Use Configured ScalaPay Client Source: https://github.com/scala-network/scalapay-merchant-npm/blob/master/README.md Import the configured ScalaPay client and use its methods like testAccess, generateAddress, and transfer. Handles potential errors for each call. ```js const scala = require('./config/ScalaAPI'); scala.testAccess(function(error, result) { if(error) console.log(error); else console.log(result); }); scala.generateAddress(function(error, result) { if(error) console.log(error); else console.log(result); }); scala.transfer("philip119@gmx.de","1337", function(error, result) { if(error) console.log(error); else console.log(result); }); ``` -------------------------------- ### Initialize ScalaPay API Client Source: https://github.com/scala-network/scalapay-merchant-npm/blob/master/README.md Initialize the ScalaPay client with your merchant token. This is the first step before making any API calls. ```js var scalapay = require('scalapay'); var scala = scalapay.login({ token : 'MERCHANT_TOKEN' }); ``` -------------------------------- ### Initialize ScalaPay Client Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Initializes the ScalaPay client with your merchant token. This must be called before any other API operations. ```javascript const scalapay = require('scalapay'); // Initialize the ScalaPay client with merchant credentials const scala = scalapay.login({ token: 'YOUR_MERCHANT_TOKEN' }); // The scala object now has access to all API methods: // - scala.testAccess() // - scala.generateAddress() // - scala.transfer() ``` -------------------------------- ### ScalaPay Merchant Initialization Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Initializes the ScalaPay client with your merchant token. This must be done before using any other API methods. ```APIDOC ## POST /api/login ### Description Initializes and returns a ScalaPay client instance configured with your merchant token. This is the entry point for all API operations. ### Method POST ### Endpoint /api/login ### Parameters #### Request Body - **token** (string) - Required - Your merchant token for authentication. ### Request Example ```json { "token": "YOUR_MERCHANT_TOKEN" } ``` ### Response #### Success Response (200) - **client** (object) - The initialized ScalaPay client object. #### Response Example ```json { "client": "[ScalaPay Client Object]" } ``` ``` -------------------------------- ### Test API Access Source: https://github.com/scala-network/scalapay-merchant-npm/blob/master/README.md Call the testAccess method to verify your merchant token and API connectivity. Handles potential errors. ```js scala.testAccess(function(error, result) { if(error){ console.log(error); } else console.log(result); }); ``` -------------------------------- ### Verify Merchant Token with testAccess Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Validates your merchant token against the ScalaPay API. Use this to confirm credentials before processing payments. Handles authentication errors. ```javascript const scalapay = require('scalapay'); const scala = scalapay.login({ token: 'YOUR_MERCHANT_TOKEN' }); scala.testAccess(function(error, result) { if (error) { console.error('Authentication failed:', error.message); // Handle invalid token or connection error return; } console.log('Token validated successfully'); console.log('API Response:', result); // Expected output on success: confirmation message from API }); ``` -------------------------------- ### Test Merchant Token Access Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Validates the configured merchant token against the ScalaPay API. Use this to verify credentials before performing payment operations. ```APIDOC ## GET /api/testAccess ### Description Validates the configured merchant token against the ScalaPay API. Returns an error if the token is invalid or not set. ### Method GET ### Endpoint /api/testAccess ### Parameters No parameters required. ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful token validation. #### Response Example ```json { "message": "Token validated successfully" } ``` ``` -------------------------------- ### Generate Integrated Payment Address Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Creates a new integrated address for receiving XLA cryptocurrency payments. Integrated addresses bundle a payment ID with the wallet address for easier payment identification. ```APIDOC ## POST /api/generateAddress ### Description Creates a new integrated address for receiving XLA cryptocurrency payments. This address includes a payment ID for easy transaction tracking. ### Method POST ### Endpoint /api/generateAddress ### Parameters No parameters required. ### Response #### Success Response (200) - **address** (string) - The newly generated integrated XLA address. - **payment_id** (string) - The unique payment ID associated with the address. #### Response Example ```json { "address": "Svk5...integratedAddress", "payment_id": "uniquePaymentId123" } ``` ``` -------------------------------- ### Generate Integrated Payment Address Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Creates a new integrated address for receiving XLA payments. This bundles a payment ID with the wallet address for easier transaction identification. ```javascript const scalapay = require('scalapay'); const scala = scalapay.login({ token: 'YOUR_MERCHANT_TOKEN' }); scala.generateAddress(function(error, result) { if (error) { console.error('Failed to generate address:', error.message); return; } console.log('New integrated address generated'); console.log('Address details:', result); // Result contains the integrated address for customer payments // Use this address to receive XLA payments from customers }); ``` -------------------------------- ### Transfer XLA to Address Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Sends XLA cryptocurrency from your merchant account. Supports transfers to ScalaPay registered emails or standard XLA wallet addresses. Amount is in units where 1 unit = 0.01 XLA. ```javascript const scalapay = require('scalapay'); const scala = scalapay.login({ token: 'YOUR_MERCHANT_TOKEN' }); // Transfer to a ScalaPay registered user by email scala.transfer('customer@example.com', '1000', function(error, result) { if (error) { console.error('Transfer failed:', error.message); return; } console.log('Transfer successful'); console.log('Transaction details:', result); // Amount 1000 = 10.00 XLA transferred }); ``` ```javascript // Transfer to a standard XLA wallet address scala.transfer('Svk5...walletAddress', '500', function(error, result) { if (error) { console.error('Transfer failed:', error.message); return; } console.log('Transfer of 5.00 XLA completed'); console.log('Result:', result); }); ``` -------------------------------- ### Transfer XLA Cryptocurrency Source: https://context7.com/scala-network/scalapay-merchant-npm/llms.txt Sends XLA cryptocurrency from your merchant account to a specified address. The recipient can be a standard XLA wallet address or a ScalaPay registered user email. The amount is specified in units where 1 unit equals 0.01 XLA. ```APIDOC ## POST /api/transfer ### Description Sends XLA cryptocurrency from your merchant account to a specified recipient. ### Method POST ### Endpoint /api/transfer ### Parameters #### Request Body - **recipient** (string) - Required - The recipient's XLA address or ScalaPay registered email. - **amount** (string) - Required - The amount of XLA to transfer, specified in units (1 unit = 0.01 XLA). ### Request Example ```json { "recipient": "customer@example.com", "amount": "1000" } ``` ### Response #### Success Response (200) - **transaction_id** (string) - The unique identifier for the completed transaction. - **status** (string) - The status of the transfer (e.g., 'completed', 'pending'). #### Response Example ```json { "transaction_id": "tx123abc", "status": "completed" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.