### Install EuPlătesc Package using npm or yarn Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Instructions for installing the EuPlătesc Node.js library using either npm or yarn package managers. This is the first step to integrating EuPlătesc payments into your application. ```sh npm install euplatesc ``` ```sh yarn add euplatesc ``` -------------------------------- ### Configure EuPlatesc Client Constructor Options Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Provides an example of initializing the EuPlatesc client with a comprehensive set of configuration options, including merchant ID, secret key, test mode, user key, and user API. These parameters are crucial for API authentication and functionality. ```ts import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: process.env.EUPLATESC_MERCHANT_ID, secretKey: process.env.EUPLATESC_SECRET_KEY, testMode: 'true' === process.env.EUPLATESC_TEST_MODE, userKey: process.env.EUPLATESC_USER_KEY, userApi: process.env.EUPLATESC_USER_API }); ``` -------------------------------- ### Get Captured Total - TypeScript Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Retrieves the total captured amount for a specified period and merchant IDs. Requires merchant ID, secret key, user key, and user API for client instantiation. Accepts optional merchant IDs, start date, and end date. ```typescript import epClient from './lib/epClient'; const params = { mids: '4484xxxxxxxxx,4484xxxxxxxxx', // or just "4484xxxxxxxxx" from: new Date('2022-02-13'), to: new Date('2022-03-22') }; console.log(await epClient.getCapturedTotal(params)); ``` -------------------------------- ### Check Merchant Configuration with EuPlatesc Node.js Source: https://context7.com/vladutilie/euplatesc/llms.txt Verifies and retrieves merchant configuration details, including status, supported features, and installment options. Requires merchantId and secretKey for instantiation. Can check the current merchant or a specific one by providing a merchant ID. ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key' }); // Check current merchant const merchantInfo = await epClient.checkMid(); // Check specific merchant const specificMerchant = await epClient.checkMid('other-merchant-id'); if ('name' in merchantInfo) { console.log(`Merchant: ${merchantInfo.name}`); console.log(`URL: ${merchantInfo.url}`); console.log(`CUI: ${merchantInfo.cui}`); console.log(`Status: ${merchantInfo.status}`); // 'test' or 'live' console.log(`Recurring: ${merchantInfo.recuring}`); // 'N', 'Y', or 'YA' console.log(`Template: ${merchantInfo.tpl}`); // 'tpl-v15', 'tpl-v17', 'tpl-v21' console.log(`Rate mode: ${merchantInfo.rate_mode}`); // 'C' or 'EP' // Available installments by bank console.log('Available installments:'); if (merchantInfo.rate_apb) console.log(` Alpha Bank: ${merchantInfo.rate_apb}`); if (merchantInfo.rate_btrl) console.log(` Banca Transilvania: ${merchantInfo.rate_btrl}`); if (merchantInfo.rate_brdf) console.log(` BRD: ${merchantInfo.rate_brdf}`); if (merchantInfo.rate_rzb) console.log(` Raiffeisen: ${merchantInfo.rate_rzb}`); } else { console.error(`Merchant check failed: ${merchantInfo.error}`); } ``` -------------------------------- ### GET /getCapturedTotal Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Retrieves the total captured amount for a specified period. Requires EuPlătesc client instantiation with userKey and userApi. ```APIDOC ## GET /getCapturedTotal ### Description Retrieves the total captured amount for a specified period. Requires EuPlătesc client instantiation with userKey and userApi. ### Method GET ### Endpoint /getCapturedTotal ### Parameters #### Query Parameters - **mids** (string) - Optional - Separated merchant IDs by commas. If empty, it will set up the merchant ID from client initialization. - **from** (Date) - Optional - The date from which the filter starts to search totals. - **to** (Date) - Optional - The date to which the filter ends to search totals. *If `from` and `to` are empty, it will look for the total in the last month.* ### Request Example ```ts const params = { mids: '4484xxxxxxxxx,4484xxxxxxxxx', from: new Date('2022-02-13'), to: new Date('2022-03-22') }; console.log(await epClient.getCapturedTotal(params)); ``` ### Response #### Success Response (200) - **success** (object) - An object containing captured totals by currency. - **EUR** (string) - Captured total in EUR. - **GBP** (string) - Captured total in GBP. - **RON** (string) - Captured total in RON. - **USD** (string) - Captured total in USD. #### Response Example ```json { "success": { "EUR": "xxx", "GBP": "xxx", "RON": "xxx", "USD": "xxx" } } ``` ``` -------------------------------- ### Get Customer's Saved Cards Source: https://context7.com/vladutilie/euplatesc/llms.txt Retrieves saved cards (Click2Pay wallet) for a customer ID. Does not require userKey/userApi. ```APIDOC ## GET /v1/cards/saved ### Description Retrieves saved cards (Click2Pay wallet) for a customer ID. Does not require userKey/userApi. ### Method GET ### Endpoint `/v1/cards/saved` ### Parameters #### Query Parameters - **clientId** (string) - Required - The unique identifier for the customer. - **mid** (string) - Optional - The merchant ID. Uses the default merchant ID if not specified. ### Request Example ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key' }); const clientId = 'customer-123'; const mid = 'optional-merchant-id'; // Uses default if not specified const savedCards = await epClient.getSavedCards(clientId, mid); if ('cards' in savedCards) { console.log(`Customer has ${savedCards.cards.length} saved cards:`); savedCards.cards.forEach(card => { console.log(` Card ID: ${card.id}`); console.log(` Masked: ${card.mask}`); // e.g., '479032xxxxxx4512' console.log(` BIN: ${card.bin}`); console.log(` Last 4: ${card.last4}`); console.log(` Expires: ${card.exp}`); // e.g., '23-10' console.log(` Card Art URL: ${card.cardart}`); }); } else { console.error(`Failed to get cards: ${savedCards.error} (code: ${savedCards.ecode})`); } ``` ### Response #### Success Response (200) - **cards** (array) - An array of saved card objects. - **id** (string) - The unique identifier for the saved card. - **mask** (string) - The masked card number (e.g., '479032xxxxxx4512'). - **bin** (string) - The Bank Identification Number (BIN) of the card. - **last4** (string) - The last 4 digits of the card number. - **exp** (string) - The expiration date of the card (e.g., '23-10'). - **cardart** (string) - The URL to the card art image. #### Error Response (400) - **error** (string) - Error message. - **ecode** (string) - Error code. ``` -------------------------------- ### Get Settlement Invoices with EuPlatesc Source: https://context7.com/vladutilie/euplatesc/llms.txt Retrieves a list of settlement invoices within a specified date range. If no dates are provided, it defaults to the last three months. The API returns up to 100 records. Requires the EuPlatesc client and optionally 'from' and 'to' date objects. ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key', userKey: 'your-user-key', userApi: 'your-user-api' }); // Get invoices for specific date range const invoices = await epClient.getInvoiceList({ from: new Date('2024-01-01'), to: new Date('2024-03-31') }); // Get invoices for last 3 months (default) const recentInvoices = await epClient.getInvoiceList(); if ('success' in invoices) { invoices.success.forEach(invoice => { console.log(`Invoice: ${invoice.invoice_number}`); console.log(` Date: ${invoice.invoice_date}`); console.log(` Amount (no VAT): ${invoice.invoice_amount_novat} ${invoice.invoice_currency}`); console.log(` Amount (with VAT): ${invoice.invoice_amount_vat} ${invoice.invoice_currency}`); console.log(` Transactions: ${invoice.transactions_number}`); console.log(` Total amount: ${invoice.transactions_amount}`); console.log(` Transferred: ${invoice.transferred_amount}`); }); } else { console.error(`Failed to get invoices: ${invoices.error}`); } ``` -------------------------------- ### GET /getCardArt Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Retrieves card art data for a given transaction EPID. Requires EuPlătesc client instantiation with userKey and userApi. ```APIDOC ## GET /getCardArt ### Description Retrieves card art data for a given transaction EPID. Requires EuPlătesc client instantiation with userKey and userApi. ### Method GET ### Endpoint /getCardArt ### Parameters #### Query Parameters - **epId** (string) - Required - The EPID of the transaction. ### Request Example ```ts const epId = '15F124618DA2E299CBEFA787A09464352946F422'; console.log(await epClient.getCardArt(epId)); ``` ### Response #### Success Response (200) - **success** (object) - An object containing card art details. - **bin** (string) - The Bank Identification Number (BIN) of the card. - **last4** (string) - The last four digits of the card number. - **exp** (string) - The expiration date of the card (YYMM format). - **cardart** (string) - Base64 encoded image data of the card art. #### Response Example ```json { "success": { "bin": "4xxxxx", "last4": "xxxx", "exp": "yymm", "cardart": "*BASE64 ENCODED IMAGE*" } } ``` ``` -------------------------------- ### Generate EuPlătesc Payment URL with TypeScript Source: https://context7.com/vladutilie/euplatesc/llms.txt Shows how to generate a secure EuPlătesc payment URL using TypeScript. This function supports various parameters for basic payments, including amount, currency, invoice ID, and order description. It also details how to include billing and shipping information, set callback URLs, and configure recurring or installment payments. ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key' }); // Basic payment const basicPayment = epClient.paymentUrl({ amount: 99.99, currency: 'RON', invoiceId: 'INV-2024-001', orderDescription: 'Premium subscription - 1 month' }); console.log(basicPayment.paymentUrl); // Output: https://secure.euplatesc.ro/tdsprocess/tranzactd.php?amount=99.99&curr=RON&... // Full payment with billing, shipping, and callbacks const fullPayment = epClient.paymentUrl({ amount: 249.50, currency: 'EUR', invoiceId: 'ORD-12345', orderDescription: 'Electronics order #12345', // Billing details billingFirstName: 'Ion', billingLastName: 'Popescu', billingCompany: 'Acme SRL', billingAddress: 'Strada Victoriei 123', billingCity: 'București', billingState: 'Sector 1', billingZip: '010101', billingCountry: 'Romania', billingPhone: '+40721234567', billingEmail: 'ion.popescu@email.ro', // Shipping details shippingFirstName: 'Ion', shippingLastName: 'Popescu', shippingAddress: 'Strada Victoriei 123', shippingCity: 'București', shippingCountry: 'Romania', // Callback URLs silentUrl: 'https://yoursite.ro/api/euplatesc/callback', successUrl: 'https://yoursite.ro/payment/success', failedUrl: 'https://yoursite.ro/payment/failed', backToSite: 'https://yoursite.ro/cart', // Additional options lang: 'ro', // 'ro' | 'en' | 'fr' | 'de' | 'it' | 'es' | 'hu' channel: 'CC,OP', // Payment channels: CC (card), OP (online payment), C2P, MASTERPASS valability: new Date('2024-12-31T23:59:59') // Payment link expiration }); // Recurring payment setup const recurringPayment = epClient.paymentUrl({ amount: 29.99, currency: 'RON', invoiceId: 'SUB-001', orderDescription: 'Monthly subscription', frequency: { days: 30, // Charge every 30 days expiresAt: new Date('2025-12-31') // Recurring end date } }); // Installments payment const installmentPayment = epClient.paymentUrl({ amount: 1500.00, currency: 'RON', invoiceId: 'INV-INST-001', orderDescription: 'Laptop - 12 installments', rate: 'btrl-12', // Bank code and installment count filterRate: 'apb-3-4,btrl-5-6-12' // Filter available installments }); ``` -------------------------------- ### Get Invoice List with EuPlătesc Client Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Retrieves a list of invoices from EuPlătesc, with optional date filtering. If no dates are provided, it defaults to the last three months. The method returns a maximum of 100 records. Requires merchant ID, secret key, userKey, and userApi for client instantiation. ```typescript import epClient from './lib/epClient'; const from = new Date('2022-08-24'); const to = new Date('2022-09-14'); console.log(await epClient.getInvoiceList({ from, to })); ``` -------------------------------- ### GET /getSavedCards Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Retrieves a list of saved cards for a specific customer. ```APIDOC ## GET /getSavedCards ### Description Retrieves a list of saved cards for a specific customer. ### Method GET ### Endpoint /getSavedCards ### Parameters #### Query Parameters - **clientId** (string) - Required - The ID of the customer. - **mid** (string) - Optional - Merchant ID. If empty, it will set up the merchant ID from client initialization. ### Request Example ```ts const clientId = '1'; const mid = '4484xxxxxxxxx'; console.log(await epClient.getSavedCards(clientId, mid)); ``` ### Response #### Success Response (200) - **cards** (array) - An array of saved card objects. - **id** (string) - The unique identifier for the saved card. - **bin** (string) - The Bank Identification Number (BIN) of the card. - **last4** (string) - The last four digits of the card number. - **mask** (string) - The masked card number. - **exp** (string) - The expiration date of the card (MM-YY format). - **cardart** (string) - URL to the card art image. #### Response Example ```json { "cards": [ { "id": "xxxxxx", "bin": "479032", "last4": "4512", "mask": "479032xxxxxx4512", "exp": "23-10", "cardart": "https://secure.euplatesc.ro/tdsprocess/images/ca8_small/1698962c052c3c6e40468363636304b23070222638c5f7071d415372b5119ba6.jpg" } ] } ``` ``` -------------------------------- ### Get Invoice Transaction Details Source: https://context7.com/vladutilie/euplatesc/llms.txt Retrieves all transactions associated with a specific settlement invoice. Requires merchant ID, secret key, user key, and user API for initialization. ```APIDOC ## GET /v1/invoice/transactions ### Description Retrieves all transactions associated with a specific settlement invoice. ### Method GET ### Endpoint `/v1/invoice/transactions` ### Parameters #### Query Parameters - **invoiceNumber** (string) - Required - The invoice number for which to retrieve transactions. ### Request Example ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key', userKey: 'your-user-key', userApi: 'your-user-api' }); const invoiceNumber = 'FPS12345678'; const transactions = await epClient.getInvoiceTransactions(invoiceNumber); if ('success' in transactions) { transactions.success.forEach(tx => { console.log(`EPID: ${tx.epid}`); console.log(` Invoice ID: ${tx.invoice_id}`); console.log(` Amount: ${tx.amount}`); console.log(` Commission: ${tx.commission}`); console.log(` Installments: ${tx.installments}`); console.log(` Type: ${tx.type}`); // 'capture' | 'refund' | 'chargeback' }); } else { console.error(`Failed to get transactions: ${transactions.error}`); } ``` ### Response #### Success Response (200) - **success** (array) - An array of transaction objects. - **epid** (string) - The EuPlatesc transaction ID. - **invoice_id** (string) - The associated invoice ID. - **amount** (string) - The transaction amount. - **commission** (string) - The transaction commission. - **installments** (string) - The number of installments. - **type** (string) - The transaction type ('capture', 'refund', 'chargeback'). #### Error Response (400) - **error** (string) - Error message. - **ecode** (string) - Error code. ``` -------------------------------- ### Get Invoice Transactions with EuPlătesc Client Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Fetches the transaction list for a specific invoice using the EuPlătesc client. Requires merchant ID, secret key, userKey, and userApi for client instantiation. The method takes the settlement invoice number as input. ```typescript import epClient from './lib/epClient'; const invoice = 'FPSxxxxxxxx'; console.log(await epClient.getInvoiceTransactions(invoice)); ``` -------------------------------- ### Get Invoice Transactions - TypeScript Source: https://context7.com/vladutilie/euplatesc/llms.txt Retrieves all transactions associated with a specific settlement invoice. Requires merchant and user credentials. Outputs transaction details or an error message. ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key', userKey: 'your-user-key', userApi: 'your-user-api' }); const invoiceNumber = 'FPS12345678'; const transactions = await epClient.getInvoiceTransactions(invoiceNumber); if ('success' in transactions) { transactions.success.forEach(tx => { console.log(`EPID: ${tx.epid}`); console.log(` Invoice ID: ${tx.invoice_id}`); console.log(` Amount: ${tx.amount}`); console.log(` Commission: ${tx.commission}`); console.log(` Installments: ${tx.installments}`); console.log(` Type: ${tx.type}`); // 'capture' | 'refund' | 'chargeback' }); } else { console.error(`Failed to get transactions: ${transactions.error}`); } ``` -------------------------------- ### Get Captured Totals by Currency Source: https://context7.com/vladutilie/euplatesc/llms.txt Retrieves the total captured amounts grouped by currency for a date range. Defaults to last month if no dates are specified. ```APIDOC ## GET /v1/totals/captured ### Description Retrieves the total captured amounts grouped by currency for a date range. Defaults to last month if no dates specified. ### Method GET ### Endpoint `/v1/totals/captured` ### Parameters #### Query Parameters - **mids** (string) - Optional - Multiple merchant IDs (comma-separated). - **from** (Date) - Optional - Start date for the period. - **to** (Date) - Optional - End date for the period. ### Request Example ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key', userKey: 'your-user-key', userApi: 'your-user-api' }); // Get totals for specific date range and merchant IDs const totals = await epClient.getCapturedTotal({ mids: '4484xxx,4484yyy', from: new Date('2024-01-01'), to: new Date('2024-01-31') }); // Get totals for current merchant, last month const currentTotals = await epClient.getCapturedTotal(); if ('success' in totals) { console.log('Captured totals by currency:'); if (totals.success.RON) console.log(` RON: ${totals.success.RON}`); if (totals.success.EUR) console.log(` EUR: ${totals.success.EUR}`); if (totals.success.USD) console.log(` USD: ${totals.success.USD}`); if (totals.success.GBP) console.log(` GBP: ${totals.success.GBP}`); } else { console.error(`Failed to get totals: ${totals.error}`); } ``` ### Response #### Success Response (200) - **success** (object) - An object where keys are currency codes (e.g., RON, EUR) and values are the total captured amounts. #### Error Response (400) - **error** (string) - Error message. - **ecode** (string) - Error code. ``` -------------------------------- ### Get Card Art Data - TypeScript Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Fetches card art data for a given EPID. Requires merchant ID, secret key, user key, and user API for client instantiation. The EPID is a mandatory string parameter. ```typescript import epClient from './lib/epClient'; const epId = '15F124618DA2E299CBEFA787A09464352946F422'; console.log(await epClient.getCardArt(epId)); ``` -------------------------------- ### Get Customer's Saved Cards - TypeScript Source: https://context7.com/vladutilie/euplatesc/llms.txt Retrieves saved cards (Click2Pay wallet) for a customer ID. Does not require userKey/userApi, only merchantId and secretKey. Outputs a list of saved cards or an error message. ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key' }); const clientId = 'customer-123'; const mid = 'optional-merchant-id'; // Uses default if not specified const savedCards = await epClient.getSavedCards(clientId, mid); if ('cards' in savedCards) { console.log(`Customer has ${savedCards.cards.length} saved cards:`); savedCards.cards.forEach(card => { console.log(` Card ID: ${card.id}`); console.log(` Masked: ${card.mask}`); // e.g., '479032xxxxxx4512' console.log(` BIN: ${card.bin}`); console.log(` Last 4: ${card.last4}`); console.log(` Expires: ${card.exp}`); // e.g., '23-10' console.log(` Card Art URL: ${card.cardart}`); }); } else { console.error(`Failed to get cards: ${savedCards.error} (code: ${savedCards.ecode})`); } ``` -------------------------------- ### Get Captured Totals by Currency - TypeScript Source: https://context7.com/vladutilie/euplatesc/llms.txt Retrieves the total captured amounts grouped by currency for a specified date range and merchant IDs. Defaults to the last month if no dates are provided. Requires merchant and user credentials. Outputs currency totals or an error message. ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key', userKey: 'your-user-key', userApi: 'your-user-api' }); // Get totals for specific date range and merchant IDs const totals = await epClient.getCapturedTotal({ mids: '4484xxx,4484yyy', // Multiple merchant IDs (comma-separated) from: new Date('2024-01-01'), to: new Date('2024-01-31') }); // Get totals for current merchant, last month const currentTotals = await epClient.getCapturedTotal(); if ('success' in totals) { console.log('Captured totals by currency:'); if (totals.success.RON) console.log(` RON: ${totals.success.RON}`); if (totals.success.EUR) console.log(` EUR: ${totals.success.EUR}`); if (totals.success.USD) console.log(` USD: ${totals.success.USD}`); if (totals.success.GBP) console.log(` GBP: ${totals.success.GBP}`); } else { console.error(`Failed to get totals: ${totals.error}`); } ``` -------------------------------- ### Initialize EuPlătesc Client with TypeScript Source: https://context7.com/vladutilie/euplatesc/llms.txt Demonstrates how to create a new EuPlătesc client instance using TypeScript. It covers basic configuration with only merchant ID and secret key, and full configuration including test mode, user key, and user API for advanced operations. Dependencies include the 'euplatesc' package. ```typescript import { EuPlatesc } from 'euplatesc'; // Basic configuration (payments only) const epClient = new EuPlatesc({ merchantId: process.env.EUPLATESC_MERCHANT_ID, // Required: from EuPlătesc Panel > Integrations secretKey: process.env.EUPLATESC_SECRET_KEY // Required: from EuPlătesc Panel > Integrations }); // Full configuration (all features including captures, refunds, reports) const epClientFull = new EuPlatesc({ merchantId: process.env.EUPLATESC_MERCHANT_ID, secretKey: process.env.EUPLATESC_SECRET_KEY, testMode: process.env.NODE_ENV !== 'production', // Optional: uses sandbox when true userKey: process.env.EUPLATESC_USER_KEY, // Optional: from Panel > Settings > User settings userApi: process.env.EUPLATESC_USER_API // Optional: from Panel > Settings > User settings }); // Access client properties console.log(epClient.merchantId); // Your merchant ID console.log(epClient.testMode); // boolean ``` -------------------------------- ### Initialize EuPlatesc Client in Node.js Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Demonstrates how to instantiate the EuPlatesc client with necessary credentials, such as merchant ID and secret key, loaded from environment variables. This client is then used to interact with the EuPlatesc API. ```ts // ./src/lib/epClient.js import { EuPlatesc } from 'euplatesc'; export default epClient = new EuPlatesc({ merchantId: process.env.EUPLATESC_MERCHANT_ID, secretKey: process.env.EUPLATESC_SECRET_KEY }); ``` -------------------------------- ### Constructor - Initialize EuPlătesc Client Source: https://context7.com/vladutilie/euplatesc/llms.txt Initializes a new EuPlătesc client instance using merchant credentials. Supports basic and full configurations, including test mode and advanced user credentials. ```APIDOC ## Constructor - Initialize EuPlătesc Client ### Description Creates a new EuPlătesc client instance with your merchant credentials. The `merchantId` and `secretKey` are required, while `testMode`, `userKey`, and `userApi` are optional. Test mode automatically uses sandbox credentials for development. ### Method `new EuPlatesc(options)` ### Parameters #### Constructor Options - **merchantId** (string) - Required - Your merchant ID from the EuPlătesc Panel. - **secretKey** (string) - Required - Your secret key from the EuPlătesc Panel. - **testMode** (boolean) - Optional - If true, uses sandbox credentials for development. Defaults to `process.env.NODE_ENV !== 'production'`. - **userKey** (string) - Optional - Your user key for advanced operations (captures, refunds, reports). - **userApi** (string) - Optional - Your user API key for advanced operations. ### Request Example ```typescript import { EuPlatesc } from 'euplatesc'; // Basic configuration (payments only) const epClient = new EuPlatesc({ merchantId: process.env.EUPLATESC_MERCHANT_ID, secretKey: process.env.EUPLATESC_SECRET_KEY }); // Full configuration (all features including captures, refunds, reports) const epClientFull = new EuPlatesc({ merchantId: process.env.EUPLATESC_MERCHANT_ID, secretKey: process.env.EUPLATESC_SECRET_KEY, testMode: process.env.NODE_ENV !== 'production', userKey: process.env.EUPLATESC_USER_KEY, userApi: process.env.EUPLATESC_USER_API }); ``` ### Response Returns an instance of the `EuPlatesc` client. #### Success Response - **EuPlatesc Client Instance** (object) - An initialized client object with accessible properties like `merchantId` and `testMode`. ``` -------------------------------- ### Use EuPlatesc Client Methods in Node.js Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Shows how to import and use the initialized EuPlatesc client to call API methods, such as `checkMid`. It illustrates both callback-based and async-await patterns for handling API responses. ```ts // ./src/index.js import epClient from './lib/epClient'; epClient.checkMid().then((midInfo) => console.log(midInfo)); // Also it can be used with async-await: // await epClient.checkMid() ``` -------------------------------- ### EuPlatesc Constructor Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Initializes the EuPlatesc client with merchant credentials and optional settings for test mode, user key, and user API. ```APIDOC ## Constructor ### Description Initializes the EuPlatesc client with merchant credentials and optional settings. ### Method `new EuPlatesc(options)` ### Parameters #### Request Body - **merchantId** (string) - Required - The merchant ID. - **secretKey** (string) - Required - The secret key. - **testMode** (boolean) - Optional - Whether the module is in test mode or not. Default: `false`. - **userKey** (string) - Optional - The user key. - **userApi** (string) - Optional - The user API. ### Request Example ```javascript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: process.env.EUPLATESC_MERCHANT_ID, secretKey: process.env.EUPLATESC_SECRET_KEY, testMode: 'true' === process.env.EUPLATESC_TEST_MODE, userKey: process.env.EUPLATESC_USER_KEY, userApi: process.env.EUPLATESC_USER_API }); ``` ### Response N/A (Constructor does not return a value directly, but initializes an object.) ``` -------------------------------- ### Get Transaction Status Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Retrieves the status of a specific transaction using either its epId or invoiceId. If both are provided, epId takes precedence. ```typescript import epClient from './lib/epClient'; const params = { epId: '15F124618DA2E299CBEFA787A09464352946F422' // invoiceId: 'FPS12145601' }; console.log(await epClient.getStatus(params)); ``` -------------------------------- ### EuPlătesc Payment Initiation Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Initiates a payment by generating a secure payment URL. This URL redirects the user to the EuPlătesc payment page to complete the transaction. ```APIDOC ## POST /payment/initiate ### Description Initiates a payment transaction and returns a URL to the EuPlătesc payment page. ### Method POST ### Endpoint /payment/initiate ### Parameters #### Query Parameters - **c2pCid** (string) - Optional - Unique ID of the enrolled card used for C2P wallet. - **lang** ('ro' | 'en' | 'fr' | 'de' | 'it' | 'es' | 'hu') - Optional - Preselect the language of the payment page. If not sent, the language will be chosen based on the client's IP. ### Request Body (Not specified in the provided text, assumed to be empty or handled by query parameters) ### Request Example (Not specified in the provided text) ### Response #### Success Response (200) - **paymentUrl** (string) - The URL to the secure EuPlătesc payment page. #### Response Example ```json { "paymentUrl": "https://secure.euplatesc.ro/tdsprocess/tranzactd.php?amount=..." } ``` #### Type ```typescript { paymentUrl: string; } ``` ``` -------------------------------- ### EuPlătesc Get Transaction Status Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Retrieves the status of a specific transaction using either its EuPlătesc ID (epId) or its invoice ID. ```APIDOC ## GET /transaction/status ### Description Gets the status of a transaction. You have to pass either `epId` or `invoiceId` as a param object. If both are passed, the `epId` field has priority. ### Method GET ### Endpoint /transaction/status ### Parameters #### Query Parameters - **epId** (string) - Required - The ID of the transaction. - **invoiceId** (string) - Required - The ID of the transaction's invoice. ### Request Example ```json { "epId": "15F124618DA2E299CBEFA787A09464352946F422" // "invoiceId": "FPS12145601" } ``` ### Response #### Success Response (200) - **success** (string) - A string containing transaction details if successful. The exact format of this string is detailed in the example. #### Response Example ```json { "success": "[{merch_id: \"4484xxxxxxxxx\", invoice_id: \"00000\", ep_id:\"0000000000000000000000000000000000000000\", action: \"0\", message: \"Approved\", captured: \"0\", refunded: \"0\", masked_card: \"444444xxxxxx4444\", card_expire: \"mm-yy\", name_on_card: \"Test\", email: \"test@test.com\", timestamp: \"2014-11-26 10:11:48\", tran_type: \"Normal\", recurent_exp: \"\", recurent_cancel_date: \"\" }]" } ``` #### Error Response - **error** (string) - An error message if the status retrieval fails. - **ecode** (string) - An error code associated with the failure. #### Type ```typescript { success: string; } | { error: string; ecode: string; } ``` ``` -------------------------------- ### Capture Partial Amount with TypeScript Source: https://context7.com/vladutilie/euplatesc/llms.txt Captures a partial amount of an authorized transaction, useful when the final order amount differs from the initial authorization. Requires userKey and userApi credentials. ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key', userKey: 'your-user-key', userApi: 'your-user-api' }); const epId = '15F124618DA2E299CBEFA787A09464352946F422'; const captureAmount = 75.50; // Capture only 75.50 from original authorization const result = await epClient.partialCapture(epId, captureAmount); if ('success' in result) { console.log(`Partially captured ${captureAmount}`); // result: { success: '1' } } else { console.error(`Partial capture failed: ${result.error || result.message}`); // result: { error: 'Error message', ecode: '01' } } ``` -------------------------------- ### Get Card Art Image Source: https://context7.com/vladutilie/euplatesc/llms.txt Retrieves card art (card design image) for a transaction. Returns BIN, last 4 digits, expiration, and a base64-encoded card image. ```APIDOC ## GET /v1/card/art ### Description Retrieves card art (card design image) for a transaction. Returns BIN, last 4 digits, expiration, and a base64-encoded card image. ### Method GET ### Endpoint `/v1/card/art` ### Parameters #### Query Parameters - **epId** (string) - Required - The EuPlatesc transaction ID (EPID). ### Request Example ```typescript import { EuPlatesc } from 'euplatesc'; const epClient = new EuPlatesc({ merchantId: 'your-merchant-id', secretKey: 'your-secret-key', userKey: 'your-user-key', userApi: 'your-user-api' }); const epId = '15F124618DA2E299CBEFA787A09464352946F422'; const cardArt = await epClient.getCardArt(epId); if ('success' in cardArt) { console.log(`Card BIN: ${cardArt.success.bin}`); console.log(`Last 4: ${cardArt.success.last4}`); console.log(`Expiration: ${cardArt.success.exp}`); // Format: YYMM // Display card art image (base64) const imgSrc = `data:image/jpeg;base64,${cardArt.success.cardart}`; // Use imgSrc in or save to file } else { console.error(`Failed to get card art: ${cardArt.error} (code: ${cardArt.ecode})`); } ``` ### Response #### Success Response (200) - **success** (object) - **bin** (string) - The Bank Identification Number (BIN) of the card. - **last4** (string) - The last 4 digits of the card number. - **exp** (string) - The expiration date of the card (Format: YYMM). - **cardart** (string) - A base64-encoded string of the card art image. #### Error Response (400) - **error** (string) - Error message. - **ecode** (string) - Error code. ``` -------------------------------- ### Refund Transaction with EuPlatesc Client (TypeScript) Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Initiates a refund for a transaction, which can be a full or partial refund. The EuPlatesc client needs to be configured with userKey and userApi. The method requires the transaction ID, the refund amount, and an optional reason, returning a success or error object. ```typescript import epClient from './lib/epClient'; const epId = '15F124618DA2E299CBEFA787A09464352946F422'; const amount = 123.78; const reason = 'Refund reason.'; console.log(await epClient.refund(epId, amount, reason)); ``` -------------------------------- ### Generate EuPlatesc Payment URL (TypeScript) Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Generates a payment URL for EuPlatesc. Requires the 'epClient' module. Accepts an object with payment details like amount, currency, and invoice ID. Returns a string representing the payment URL. ```typescript import epClient from './lib/epClient'; const data = { amount: 12.34, currency: 'USD', invoiceId: 'invoice id', orderDescription: 'The description of the order' }; console.log(epClient.paymentUrl(data)); ``` -------------------------------- ### Get Saved Cards - TypeScript Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Retrieves a list of saved cards for a specific customer. Requires the client ID and optionally a merchant ID. If the merchant ID is omitted, it defaults to the one used during client initialization. ```typescript import epClient from './lib/epClient'; const clientId = '1'; const mid = '4484xxxxxxxxx'; console.log(await epClient.getSavedCards(clientId, mid)); ``` -------------------------------- ### EuPlatesc Test Card Scenarios in TypeScript Source: https://context7.com/vladutilie/euplatesc/llms.txt Provides a collection of test card numbers for various payment scenarios in test mode. These include approved, authentication failed, insufficient funds, declined, expired card, and invalid response scenarios for both Visa and Mastercard. ```typescript // Test cards for different scenarios const testCards = { approved: { number: '4000640000000005', exp: '24/01', cvv: '123', name: 'Test' }, authFailed: { number: '4111111111111111', exp: '24/01', cvv: '123', name: 'Test' }, insufficientFunds: { number: '4444333322221111', exp: '24/01', cvv: '123', name: 'Test' }, declined: { number: '4000020000000000', exp: '24/01', cvv: '123', name: 'Test' }, expiredCard: { number: '4400000000000008', exp: '24/01', cvv: '123', name: 'Test' }, invalidResponse: { number: '4607000000000009', exp: '24/01', cvv: '123', name: 'Test' }, // Mastercard test cards masterApproved: { number: '5500000000000004', exp: '24/01', cvv: '123', name: 'Test' }, masterAuthFailed: { number: '5454545454545454', exp: '24/01', cvv: '123', name: 'Test' }, masterInsufficient: { number: '5555555555554444', exp: '24/01', cvv: '123', name: 'Test' } }; ``` -------------------------------- ### Partial Capture Transaction with EuPlatesc Client (TypeScript) Source: https://github.com/vladutilie/euplatesc/blob/main/README.md Performs a partial capture of a transaction, allowing a portion of the authorized amount to be captured. The EuPlatesc client must be instantiated with userKey and userApi. This method takes the transaction ID and the amount to capture, returning a success or error object. ```typescript import epClient from './lib/epClient'; const epId = '15F124618DA2E299CBEFA787A09464352946F422'; const amount = 123.78; console.log(await epClient.partialCapture(epId, amount)); ```