### Run Example Script Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Execute the example script from your terminal to see the 'Get Txids of Invoices' functionality in action. ```bash node ./examples/get_payment_txid.js ``` -------------------------------- ### Run Payment Link Example Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Execute the provided example script for creating a payment link. ```bash node ./examples/create_payment_link.js ``` -------------------------------- ### Run Address Generation Example Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Execute the provided example script for address generation. ```bash node ./examples/create_address.js ``` -------------------------------- ### Install Paykassa SDK Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Use npm to install the required SDK package. ```bash npm i paykassa-api-sdk ``` -------------------------------- ### Run IPN Check Example Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Execute the provided example script for checking transaction IPNs. ```bash node ./examples/processing_ipn_for_transaction.js ``` -------------------------------- ### MerchantApi - Get Payment URL Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Creates a payment order and returns a URL for redirecting customers to a hosted payment page. ```APIDOC ## POST /merchant/get-payment-url ### Description Creates a payment order and returns a URL where customers can complete their payment. ### Request Body - **orderId** (string) - Required - Unique identifier for the order - **amount** (string) - Required - Payment amount - **system** (System) - Required - Blockchain network - **currency** (Currency) - Required - Cryptocurrency - **comment** (string) - Optional - Payment description ### Response #### Success Response (200) - **url** (string) - Hosted payment page URL - **method** (string) - HTTP method for the payment form - **params** (object) - Form parameters for the payment request ``` -------------------------------- ### Get a merchant balance Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Retrieves the current balance for a merchant account. Supports querying balances by specific system and currency constants. ```js import dotenv from 'dotenv'; dotenv.config(); import { CheckBalanceRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, PsCurList, System } from 'paykassa-api-sdk/lib/struct.js'; import { PaymentApi } from 'paykassa-api-sdk/lib/payment.js'; const testMode = false; const paymentApi = new PaymentApi( process.env.API_ID, process.env.API_PASSWORD ).setTest(testMode); const request = new CheckBalanceRequest().setShopId(process.env.MERCHANT_ID); paymentApi .checkBalance(request) .then((response) => { for (const v of PsCurList) { console.log('Balance', v, '=', response.getRawData()[v]); } console.log(''); console.log( "Balance by constant value 'binancesmartchain_bep20_btc' = ", response.getBalance(System.BINANCESMARTCHAIN_BEP20, Currency.BTC) ); }) .catch((error) => { console.error('Error:', error.toString()); }); ``` ```bash node ./examples/get_merchant_balance.js ``` -------------------------------- ### MerchantApi - Get Payment URL Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Creates a payment order and returns a URL for customers to complete their payment, useful for redirecting users to a hosted payment page. Requires order details, amount, system, and currency. ```javascript import { GetPaymentUrlRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, System } from 'paykassa-api-sdk/lib/struct.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; const merchantApi = new MerchantApi( process.env.MERCHANT_ID, process.env.MERCHANT_PASSWORD ).setTest(false); const request = new GetPaymentUrlRequest() .setOrderId('ORDER-67890') .setAmount('0.005') .setSystem(System.BITCOIN) .setCurrency(Currency.BTC) .setComment('Subscription payment'); merchantApi .getPaymentUrl(request) .then((response) => { console.log('Payment URL:', response.getUrl()); console.log('HTTP Method:', response.getMethod()); console.log('Form Params:', response.getParams()); // Redirect customer to response.getUrl() }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### Get Txids of Invoices with Node.js SDK Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Use this snippet to retrieve transaction IDs for a given list of invoice IDs. Ensure environment variables for API credentials and merchant ID are set. The response is processed to log each txid or indicate if an invoice was not found. ```javascript import dotenv from 'dotenv'; dotenv.config(); import { GetTxidsOfInvoicesRequest } from 'paykassa-api-sdk/lib/dto.js'; import { PaymentApi } from 'paykassa-api-sdk/lib/payment.js'; const testMode = false; const paymentApi = new PaymentApi( process.env.API_ID, process.env.API_PASSWORD ).setTest(testMode); const invoices = [ '37433236', '32531999', //for test not found '37433238', '37433220', '37433196', ]; const request = new GetTxidsOfInvoicesRequest() .setShopId(process.env.MERCHANT_ID) .setInvoices(invoices); paymentApi .getTxidsOfInvoices(request) .then((response) => { for (const i of invoices) { if (response.isReady(i)) { for (const tx of response.getRawData()[i]) { console.log('Invoice %s: %s', i, tx); } } else { console.log('Invoice is not found: %s', i); } } }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### PaymentApi: Check Merchant Balance Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Retrieves the current balance for all supported cryptocurrency pairs on your merchant account. You can iterate through all pairs or get a specific balance by system and currency. ```javascript import { CheckBalanceRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, PsCurList, System } from 'paykassa-api-sdk/lib/struct.js'; import { PaymentApi } from 'paykassa-api-sdk/lib/payment.js'; const paymentApi = new PaymentApi( process.env.API_ID, process.env.API_PASSWORD ).setTest(false); const request = new CheckBalanceRequest().setShopId(process.env.MERCHANT_ID); paymentApi .checkBalance(request) .then((response) => { // Iterate all supported currency pairs for (const pair of PsCurList) { const balance = response.getRawData()[pair]; if (balance && parseFloat(balance) > 0) { console.log('Balance', pair, '=', balance); } } // Get specific balance by system and currency constants const btcBalance = response.getBalance(System.BINANCESMARTCHAIN_BEP20, Currency.BTC); console.log('BSC BEP20 BTC Balance:', btcBalance); const usdtBalance = response.getBalance(System.TRON_TRC20, Currency.USDT); console.log('TRON TRC20 USDT Balance:', usdtBalance); }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### MerchantApi - Check Transaction IPN Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Validates and retrieves details of an incoming transaction notification (IPN). Call this when your IPN endpoint receives a callback to verify payment and get transaction details. Responds with 'success' to prevent repeated notifications. ```javascript import { CheckTransactionRequest } from 'paykassa-api-sdk/lib/dto.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; const merchantApi = new MerchantApi( process.env.MERCHANT_ID, process.env.MERCHANT_PASSWORD ).setTest(false); // Use the private_hash from the IPN callback const request = new CheckTransactionRequest().setPrivateHash( '607e40c901bd3df89464ea7394b0b46eb7a876c14c5bcc705da4d1703d5274c4' ); merchantApi .checkTransaction(request) .then((response) => { console.log('Order ID:', response.getOrderId()); console.log('Transaction:', response.getTransaction()); console.log('Txid:', response.getTxid()); console.log('Amount:', response.getAmount()); console.log('Fee:', response.getFee()); console.log('System:', response.getSystem()); console.log('Currency:', response.getCurrency()); console.log('From Address:', response.getAddressFrom()); console.log('To Address:', response.getAddress()); console.log('Confirmations:', response.getConfirmations(), '/', response.getRequiredConfirmations()); console.log('Status:', response.getStatus()); console.log('Explorer Link:', response.getExplorerTransactionLink()); if (response.getStatus() === 'yes') { // Payment confirmed - credit customer account console.log('Credit amount:', response.getAmount(), response.getCurrency()); } // Respond to IPN to prevent repeated notifications console.log(response.getOrderId() + '|success'); }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Prepare the environment configuration file from the provided template. ```bash cp ./.env.example ./.env ``` -------------------------------- ### Access Supported Cryptocurrencies and Networks Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Lists constants for supported currencies, blockchain systems, and transaction priorities. ```javascript import { Currency, System, TransactionPriority } from 'paykassa-api-sdk/lib/struct.js'; // Available currencies const currencies = { BTC: Currency.BTC, ETH: Currency.ETH, LTC: Currency.LTC, DOGE: Currency.DOGE, DASH: Currency.DASH, BCH: Currency.BCH, XRP: Currency.XRP, TRX: Currency.TRX, XLM: Currency.XLM, BNB: Currency.BNB, USDT: Currency.USDT, USDC: Currency.USDC, ADA: Currency.ADA, EOS: Currency.EOS, SHIB: Currency.SHIB, TON: Currency.TON }; // Available blockchain networks const systems = { BITCOIN: System.BITCOIN, // '11' ETHEREUM: System.ETHEREUM, // '12' LITECOIN: System.LITECOIN, // '14' DOGECOIN: System.DOGECOIN, // '15' DASH: System.DASH, // '16' BITCOIN_CASH: System.BITCOIN_CASH, // '18' RIPPLE: System.RIPPLE, // '22' TRON: System.TRON, // '27' STELLAR: System.STELLAR, // '28' BINANCECOIN: System.BINANCECOIN, // '29' TRON_TRC20: System.TRON_TRC20, // '30' BINANCESMARTCHAIN_BEP20: System.BINANCESMARTCHAIN_BEP20, // '31' ETHEREUM_ERC20: System.ETHEREUM_ERC20, // '32' TON: System.TON // '33' }; // Transaction priority for UTXO chains (Bitcoin, Litecoin, Dogecoin, Dash) const priorities = { LOW: TransactionPriority.LOW, MEDIUM: TransactionPriority.MEDIUM, HIGH: TransactionPriority.HIGH }; ``` -------------------------------- ### Handle API Exceptions Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Demonstrates wrapping API calls in try-catch blocks to distinguish between ApiException and general network errors. ```javascript import { ApiException } from 'paykassa-api-sdk/lib/error.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; import { GenerateAddressRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, System } from 'paykassa-api-sdk/lib/struct.js'; const merchantApi = new MerchantApi('invalid_id', 'invalid_password'); const request = new GenerateAddressRequest() .setOrderId('test-order') .setSystem(System.BITCOIN) .setCurrency(Currency.BTC); try { const response = await merchantApi.generateAddress(request); console.log('Address:', response.getWallet()); } catch (error) { if (error instanceof ApiException) { console.error('API Error:', error.message); // Handle specific API errors (auth failure, invalid params, etc.) } else { console.error('Network/System Error:', error.message); // Handle connection issues, timeouts, etc. } } ``` -------------------------------- ### Create Payment Link Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Generate a URL for a payment order to redirect the user to the payment gateway. ```javascript import dotenv from 'dotenv'; dotenv.config(); import { GetPaymentUrlRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, System } from 'paykassa-api-sdk/lib/struct.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; const testMode = false; const merchantApi = new MerchantApi( process.env.MERCHANT_ID, process.env.MERCHANT_PASSWORD ).setTest(testMode); const request = new GetPaymentUrlRequest() .setOrderId('1005000') .setAmount('110') .setSystem(System.BITCOIN) .setCurrency(Currency.BTC) .setComment('test comment'); merchantApi .getPaymentUrl(request) .then((response) => { console.log('Url: ', response.getUrl()); }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### Check an IPN of an order Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Verifies the status of a payment using a private hash. Ensure you confirm the credit to avoid repeated IPN notifications. ```js import dotenv from 'dotenv'; dotenv.config(); import { CheckPaymentRequest } from 'paykassa-api-sdk/lib/dto.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; const testMode = false; const merchantApi = new MerchantApi( process.env.MERCHANT_ID, process.env.MERCHANT_PASSWORD ).setTest(testMode); const request = new CheckPaymentRequest().setPrivateHash( '72ea64dae378eeeebc9dc8f2d79c89ac2c0bd6f6e2c4ab7b3aa08655dd2e34e4' ); merchantApi .checkPayment(request) .then((response) => { console.log('Order ID in your system:', response.getOrderId()); console.log('Transaction Number:', response.getTransaction()); console.log('Amount:', response.getAmount()); console.log('System:', response.getSystem()); console.log('Currency:', response.getCurrency()); console.log('Wallet:', response.getAddress()); console.log('Tag:', response.getTag()); console.log('Partial?', response.isPartial() ? 'yes' : 'no'); if (response.isPartial()) { console.log( 'Verify the amount: ', response.getSystem(), response.getAmount(), response.getCurrency() ); } else { console.log( 'You can credit this amount: ', response.getSystem(), response.getAmount(), response.getCurrency() ); } //You should confirm that you’ve credited the funds to avoid repeated IPNs. console.log(response.getOrderId() + '|success'); }) .catch((error) => { console.error('Error:', error.toString()); }); ``` ```bash node ./examples/processing_ipn_for_order.js ``` -------------------------------- ### Generate Deposit Address Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Create a new deposit address for a specific order using the Merchant API. ```javascript import dotenv from 'dotenv'; dotenv.config(); import { GenerateAddressRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, System } from 'paykassa-api-sdk/lib/struct.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; const testMode = false; const merchantApi = new MerchantApi( process.env.MERCHANT_ID, process.env.MERCHANT_PASSWORD ).setTest(testMode); const request = new GenerateAddressRequest() .setOrderId('1005000') .setSystem(System.TON) .setCurrency(Currency.USDT) .setComment('test comment'); merchantApi .generateAddress(request) .then((response) => { let ext = ''; if (response.getIsTag()) { ext = ' ' + response.getTagName() + ': ' + response.getTag(); } console.log('Invoice ID: ', response.getInvoiceId()); console.log('Wallet: ', response.getWallet(), ext); if (testMode) { console.log('Test URL: ', response.getUrl()); } }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### Send money Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Initiates a payment transfer. Note that the transaction ID (txid) may not be immediately available, requiring the invoice ID to be saved. ```js import dotenv from 'dotenv'; dotenv.config(); import { MakePaymentRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, System, TransactionPriority, } from 'paykassa-api-sdk/lib/struct.js'; import { PaymentApi } from 'paykassa-api-sdk/lib/payment.js'; const testMode = true; const paymentApi = new PaymentApi( process.env.API_ID, process.env.API_PASSWORD ).setTest(testMode); const request = new MakePaymentRequest() .setShopId(process.env.MERCHANT_ID) .setAmount('0.05') .setSystem(System.TON) .setCurrency(Currency.TON) .setNumber('EQBkmfJlIjxZqB8xndrlDX05gGLKFPy84PKT4NRcmWy0PCaL') .setComment('test_transfer'); request.setTag('100501'); //Ripple, Stellar, TON request.setPriority(TransactionPriority.MEDIUM); //Bitcoin, Litecoin, Dogecoin, Dash, BitcoinCash paymentApi .makePayment(request) .then((response) => { console.log( 'Status txid is not ready! Safe the invoice id %s to get the txid later', response.getSystem(), response.getAmountPay(), response.getCurrency(), response.getNumber(), response.getTxid() ); if (response.getPaymentId() === response.getTxid()) { console.log( 'Status txid is not ready! Safe the invoice id %s to get the txid later', response.getTransaction() ); } console.log('Deducted amount is %s', response.getAmount()); console.log('Address link is %s', response.getExplorerAddressLink()); console.log( 'Transaction link is %s', response.getExplorerTransactionLink() ); }) .catch((error) => { console.error('Error:', error.toString()); }); ``` ```bash node ./examples/send_money.js ``` -------------------------------- ### MerchantApi - Generate Deposit Address Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Generates a unique cryptocurrency deposit address for a customer order, linked to a specific order ID. ```APIDOC ## POST /merchant/generate-address ### Description Generates a unique cryptocurrency deposit address for a customer order. This address is linked to your order ID and will trigger an IPN notification when funds are received. ### Request Body - **orderId** (string) - Required - Unique identifier for the order - **system** (System) - Required - Blockchain network (e.g., TON) - **currency** (Currency) - Required - Cryptocurrency (e.g., USDT) - **comment** (string) - Optional - Payment description ### Response #### Success Response (200) - **invoiceId** (string) - Unique invoice identifier - **wallet** (string) - Generated deposit address - **isTag** (boolean) - Indicates if a tag/memo is required - **tag** (string) - Tag or memo value if required ``` -------------------------------- ### PaymentApi - Check Merchant Balance Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Retrieves the current balance for all supported cryptocurrency pairs on your merchant account. ```APIDOC ## PaymentApi - Check Merchant Balance ### Description Retrieves the current balance for all supported cryptocurrency pairs on your merchant account. ### Method POST ### Endpoint /payment/check_balance ### Parameters #### Request Body - **shop_id** (string) - Required - Your merchant ID. ### Request Example ```json { "shop_id": "YOUR_MERCHANT_ID" } ``` ### Response #### Success Response (200) - **rawData** (object) - An object containing balances for all supported currency pairs. The keys are currency pair strings (e.g., "BTC_USD"), and the values are the balance amounts. - **getBalance**(system, currency) - Method to get the balance for a specific system and currency. #### Response Example ```json { "rawData": { "BTC_USD": "1.5", "ETH_USDT": "10.2", "TON_TON": "50.0" } } ``` ``` -------------------------------- ### PaymentApi - Send Cryptocurrency Payment Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Sends cryptocurrency from your merchant balance to an external wallet address. Supports transaction priority for UTXO-based chains and memo/tag for networks that require it. ```APIDOC ## PaymentApi - Send Cryptocurrency Payment ### Description Sends cryptocurrency from your merchant balance to an external wallet address. Supports transaction priority for UTXO-based chains and memo/tag for networks that require it. ### Method POST ### Endpoint /payment/make ### Parameters #### Request Body - **shop_id** (string) - Required - Your merchant ID. - **amount** (string) - Required - The amount to send. - **system** (string) - Required - The cryptocurrency system (e.g., TON, BTC). - **currency** (string) - Required - The currency of the amount (e.g., TON, BTC). - **number** (string) - Required - The recipient's wallet address. - **comment** (string) - Optional - A comment for the transaction. - **tag** (string) - Optional - Memo or tag required for certain networks (e.g., Ripple, Stellar, TON). - **priority** (string) - Optional - Transaction priority for UTXO-based chains (e.g., LOW, MEDIUM, HIGH). ### Request Example ```json { "shop_id": "YOUR_MERCHANT_ID", "amount": "0.05", "system": "TON", "currency": "TON", "number": "EQBkmfJlIjxZqB8xndrlDX05gGLKFPy84PKT4NRcmWy0PCaL", "comment": "Withdrawal request #4521", "tag": "100501", "priority": "MEDIUM" } ``` ### Response #### Success Response (200) - **payment_id** (string) - The unique identifier for the payment. - **transaction** (string) - The transaction identifier. - **txid** (string) - The transaction ID on the blockchain. - **amount_pay** (string) - The actual amount paid, including fees. - **amount** (string) - The amount deducted from your balance. - **number** (string) - The recipient's address. - **shop_commission_amount** (string) - The amount of commission paid to the shop. - **shop_commission_percent** (string) - The percentage of commission paid to the shop. - **explorer_address_link** (string) - Link to the recipient address on a block explorer. - **explorer_transaction_link** (string) - Link to the transaction on a block explorer. #### Response Example ```json { "payment_id": "pay12345", "transaction": "tx12345", "txid": "0xabc123", "amount_pay": "0.051", "amount": "0.05", "number": "EQBkmfJlIjxZqB8xndrlDX05gGLKFPy84PKT4NRcmWy0PCaL", "shop_commission_amount": "0.001", "shop_commission_percent": "2", "explorer_address_link": "https://explorer.com/address/...". "explorer_transaction_link": "https://explorer.com/tx/0xabc123" } ``` ``` -------------------------------- ### PaymentApi: Send Cryptocurrency Payment Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Sends cryptocurrency from your merchant balance to an external wallet address. Supports transaction priority for UTXO-based chains and memo/tag for networks that require it. ```javascript import { MakePaymentRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, System, TransactionPriority } from 'paykassa-api-sdk/lib/struct.js'; import { PaymentApi } from 'paykassa-api-sdk/lib/payment.js'; const paymentApi = new PaymentApi( process.env.API_ID, process.env.API_PASSWORD ).setTest(false); const request = new MakePaymentRequest() .setShopId(process.env.MERCHANT_ID) .setAmount('0.05') .setSystem(System.TON) .setCurrency(Currency.TON) .setNumber('EQBkmfJlIjxZqB8xndrlDX05gGLKFPy84PKT4NRcmWy0PCaL') .setComment('Withdrawal request #4521') .setTag('100501') // Required for Ripple, Stellar, TON .setPriority(TransactionPriority.MEDIUM); // For Bitcoin, Litecoin, Dogecoin, Dash paymentApi .makePayment(request) .then((response) => { console.log('Payment ID:', response.getPaymentId()); console.log('Transaction:', response.getTransaction()); console.log('Txid:', response.getTxid()); console.log('Amount Paid:', response.getAmountPay(), response.getCurrency()); console.log('Amount Deducted:', response.getAmount()); console.log('To Address:', response.getNumber()); console.log('Commission:', response.getShopCommissionAmount(), '(', response.getShopCommissionPercent(), '%)'); console.log('Address Explorer:', response.getExplorerAddressLink()); console.log('Transaction Explorer:', response.getExplorerTransactionLink()); // Txid may not be ready immediately if (response.getPaymentId() === response.getTxid()) { console.log('Txid pending - save transaction ID:', response.getTransaction()); } }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### MerchantApi - Generate Deposit Address Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Generates a unique cryptocurrency deposit address for a customer order. This address is linked to your order ID and will trigger an IPN notification when funds are received. Handles memo/tag for networks like XRP, XLM, and TON. ```javascript import { GenerateAddressRequest } from 'paykassa-api-sdk/lib/dto.js'; import { Currency, System } from 'paykassa-api-sdk/lib/struct.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; const merchantApi = new MerchantApi( process.env.MERCHANT_ID, process.env.MERCHANT_PASSWORD ).setTest(false); const request = new GenerateAddressRequest() .setOrderId('ORDER-12345') .setSystem(System.TON) .setCurrency(Currency.USDT) .setComment('Payment for Order #12345'); merchantApi .generateAddress(request) .then((response) => { console.log('Invoice ID:', response.getInvoiceId()); console.log('Wallet Address:', response.getWallet()); console.log('System:', response.getSystem()); console.log('Currency:', response.getCurrency()); // Handle memo/tag for networks that require it (XRP, XLM, TON) if (response.getIsTag()) { console.log(response.getTagName() + ':', response.getTag()); } }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### Retrieve Blockchain Transaction IDs for Invoices Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Fetches transaction IDs for a list of invoice IDs. Use this to track outgoing payments when the transaction ID is not immediately available. ```javascript import { GetTxidsOfInvoicesRequest } from 'paykassa-api-sdk/lib/dto.js'; import { PaymentApi } from 'paykassa-api-sdk/lib/payment.js'; const paymentApi = new PaymentApi( process.env.API_ID, process.env.API_PASSWORD ).setTest(false); const invoices = ['37433236', '32531999', '37433238', '37433220', '37433196']; const request = new GetTxidsOfInvoicesRequest() .setShopId(process.env.MERCHANT_ID) .setInvoices(invoices); paymentApi .getTxidsOfInvoices(request) .then((response) => { for (const invoiceId of invoices) { if (response.isReady(invoiceId)) { const txids = response.getRawData()[invoiceId]; for (const txid of txids) { console.log('Invoice', invoiceId, '-> Txid:', txid); } } else { console.log('Invoice', invoiceId, '-> Not found or pending'); } } }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### Check Transaction IPN Source: https://github.com/paykassa-dev/nodejs-api-sdk/blob/master/README.md Verify the status of a transaction using its private hash to confirm payment receipt. ```javascript import dotenv from 'dotenv'; dotenv.config(); import { CheckTransactionRequest } from 'paykassa-api-sdk/lib/dto.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; const testMode = false; const merchantApi = new MerchantApi( process.env.MERCHANT_ID, process.env.MERCHANT_PASSWORD ).setTest(testMode); const request = new CheckTransactionRequest().setPrivateHash( '607e40c901bd3df89464ea7394b0b46eb7a876c14c5bcc705da4d1703d5274c4' ); merchantApi .checkTransaction(request) .then((response) => { console.log(response); console.log('Order ID in your system:', response.getOrderId()); console.log('Transaction Number:', response.getTransaction()); console.log('Txid:', response.getTxid()); console.log('Amount:', response.getAmount()); console.log('Fee:', response.getFee()); console.log('System:', response.getSystem()); console.log('Currency:', response.getCurrency()); console.log('Address from:', response.getAddressFrom()); console.log('Address:', response.getAddress()); console.log('Tag:', response.getTag()); console.log('Confirmations:', response.getConfirmations()); console.log('Required confirmations:', response.getRequiredConfirmations()); console.log('Status:', response.getStatus()); // The applied amount may differ from the received amount if partial payment mode is enabled. // Default is 'no'. if (response.getStatus() === 'yes') { console.log( 'You can credit this amount: ', response.getSystem(), response.getAmount(), response.getCurrency() ); // your code... } //You should confirm that you’ve credited the funds to avoid repeated IPNs. console.log(response.getOrderId() + '|success'); }) .catch((error) => { console.error('Error:', error.toString()); }); ``` -------------------------------- ### MerchantApi - Check Payment IPN Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Validates and retrieves details of an order payment notification. Use this for payment link orders created via getPaymentUrl(). ```APIDOC ## MerchantApi - Check Payment IPN ### Description Validates and retrieves details of an order payment notification. Use this for payment link orders created via getPaymentUrl(). ### Method POST ### Endpoint /merchant/check_payment ### Parameters #### Request Body - **private_hash** (string) - Required - The private hash of the payment. ### Request Example ```json { "private_hash": "72ea64dae378eeeebc9dc8f2d79c89ac2c0bd6f6e2c4ab7b3aa08655dd2e34e4" } ``` ### Response #### Success Response (200) - **order_id** (string) - The ID of the order. - **transaction** (string) - The transaction identifier. - **amount** (string) - The amount of the payment. - **system** (string) - The cryptocurrency system used for the payment. - **currency** (string) - The currency of the payment. - **address** (string) - The payment address. - **tag** (string) - The tag associated with the payment (if applicable). - **is_partial** (boolean) - Indicates if the payment was partial. #### Response Example ```json { "order_id": "12345", "transaction": "tx12345", "amount": "0.05", "system": "TON", "currency": "TON", "address": "EQBkmfJlIjxZqB8xndrlDX05gGLKFPy84PKT4NRcmWy0PCaL", "tag": "100501", "is_partial": false } ``` ``` -------------------------------- ### MerchantApi - Check Transaction IPN Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Validates and retrieves details of an incoming transaction notification using a private hash. ```APIDOC ## POST /merchant/check-transaction ### Description Validates and retrieves details of an incoming transaction notification. Call this when your IPN endpoint receives a callback to verify the payment. ### Request Body - **privateHash** (string) - Required - The private_hash received from the IPN callback ### Response #### Success Response (200) - **orderId** (string) - Associated order ID - **txid** (string) - Blockchain transaction ID - **amount** (string) - Payment amount - **status** (string) - Payment status (e.g., 'yes' for confirmed) - **explorerTransactionLink** (string) - Link to the transaction on the blockchain explorer ``` -------------------------------- ### MerchantApi: Check Payment IPN Source: https://context7.com/paykassa-dev/nodejs-api-sdk/llms.txt Validates and retrieves details of an order payment notification for payment link orders. Ensure to confirm receipt to stop IPN retries. ```javascript import { CheckPaymentRequest } from 'paykassa-api-sdk/lib/dto.js'; import { MerchantApi } from 'paykassa-api-sdk/lib/merchant.js'; const merchantApi = new MerchantApi( process.env.MERCHANT_ID, process.env.MERCHANT_PASSWORD ).setTest(false); const request = new CheckPaymentRequest().setPrivateHash( '72ea64dae378eeeebc9dc8f2d79c89ac2c0bd6f6e2c4ab7b3aa08655dd2e34e4' ); merchantApi .checkPayment(request) .then((response) => { console.log('Order ID:', response.getOrderId()); console.log('Transaction:', response.getTransaction()); console.log('Amount:', response.getAmount()); console.log('System:', response.getSystem()); console.log('Currency:', response.getCurrency()); console.log('Address:', response.getAddress()); console.log('Tag:', response.getTag()); console.log('Is Partial Payment:', response.isPartial() ? 'yes' : 'no'); if (response.isPartial()) { console.log('Partial payment received - verify amount manually'); } else { console.log('Full payment received - credit:', response.getAmount(), response.getCurrency()); } // Confirm receipt to stop IPN retries console.log(response.getOrderId() + '|success'); }) .catch((error) => { console.error('Error:', error.toString()); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.