### Installing UniPayment SDK using npm Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This snippet demonstrates how to install the UniPayment SDK as a dependency in a Node.js project using the npm package manager. This is the recommended method for integrating the SDK into your application. ```Bash npm install unipayment-sdk ``` -------------------------------- ### Installing UniPayment SDK via npm Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This snippet demonstrates how to install the UniPayment SDK using the npm package manager. This is the recommended method for integrating the SDK into a Node.js project, simplifying dependency management. ```bash npm install unipayment-sdk ``` -------------------------------- ### UniPayment SDK Configuration File Example Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This JSON snippet illustrates the structure of the `configuration.json` file required for initializing the UniPayment SDK. It includes essential API credentials such as `apiHost`, `clientId`, `clientSecret`, `appId`, and `apiVersion`. ```json { "apiHost": "https://api.unipayment.io", "clientId": "your client id", "clientSecret": "you client secret", "appId": "your app id", "apiVersion": "1.0" } ``` -------------------------------- ### Running Project Tests (Bash) Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This command executes the test suite defined in the `package.json` file of the UniPaymentClient.Node project. It's used to verify the functionality and correctness of the project after setup. ```bash npm test ``` -------------------------------- ### Example Response for Create Invoice API Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This JSON snippet provides an example of the successful response received after calling the `createInvoice` API. It includes details such as `invoice_id`, `order_id`, `price_amount`, `price_currency`, `status`, and the `invoice_url` for payment. ```JSON { "msg": "", "code": "OK", "data": { "app_id": "df01ae1f-8c31-4ecd-8ab1-9e31289d4823", "payment_method_type": "UNKNOWN", "invoice_id": "88144dSLPujPsUJYakkJdx", "order_id": "ORDER_1721023791051", "price_amount": 2.0, "price_currency": "USD", "network": null, "address": null, "pay_amount": 0.0, "pay_currency": null, "exchange_rate": 0.0, "paid_amount": 0.0, "refunded_price_amount": 0.0, "create_time": "2024-07-15T06:09:54", "expiration_time": "2024-07-15T06:29:54", "confirm_speed": "Medium", "status": "New", "error_status": "None", "invoice_url": "https://sandbox.api.unipayment.com/i/88144dSLPujPsUJYakkJdx" } } ``` -------------------------------- ### Example UniPayment Create Invoice Response JSON Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This JSON snippet provides an example of the response received after successfully creating an invoice via the UniPayment API. It includes details such as `invoice_id`, `order_id`, `price_amount`, `status`, and the `invoice_url` for payment. ```json { "msg": "", "code": "OK", "data": { "app_id": "df01ae1f-8c31-4ecd-8ab1-9e31289d4823", "payment_method_type": "UNKNOWN", "invoice_id": "88144dSLPujPsUJYakkJdx", "order_id": "ORDER_1721023791051", "price_amount": 2.0, "price_currency": "USD", "network": null, "address": null, "pay_amount": 0.0, "pay_currency": null, "exchange_rate": 0.0, "paid_amount": 0.0, "refunded_price_amount": 0.0, "create_time": "2024-07-15T06:09:54", "expiration_time": "2024-07-15T06:29:54", "confirm_speed": "Medium", "status": "New", "error_status": "None", "invoice_url": "https://sandbox.api.unipayment.com/i/88144dSLPujPsUJYakkJdx" } } ``` -------------------------------- ### Example UniPayment IPN Notification JSON Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This JSON snippet illustrates the structure of an Instant Payment Notification (IPN) sent by UniPayment. It contains details about the event, such as `ipn_type`, `event` (e.g., `invoice_expired`), `invoice_id`, `order_id`, and the current `status` of the invoice. ```json { "ipn_type": "invoice", "event": "invoice_expired", "app_id": "cee1b9e2-d90c-4b63-9824-d621edb38012", "invoice_id": "3Q7fyLnB2YNhUDW1fFNyEz", "order_id": "20", "price_amount": 6.0, "price_currency": "SGD", "network": null, "address": null, "pay_currency": null, "pay_amount": 0.0, "exchange_rate": 0.0, "paid_amount": 0.0, "confirmed_amount": 0.0, "refunded_price_amount": 0.0, "create_time": "2022-09-12T03:36:03", "expiration_time": "2022-09-12T03:41:03", "status": "Expired", "error_status": "None", "ext_args": null, "transactions": null, "notify_id": "8ccd2b61-226b-48e5-99b8-acb1f350313e", "notify_time": "2022-09-12T03:56:10.5852752Z" } ``` -------------------------------- ### Example UniPayment IPN Notification Payload Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This JSON snippet illustrates the structure of an Instant Payment Notification (IPN) payload sent by UniPayment. It contains critical information about the payment event, such as `ipn_type`, `event`, `invoice_id`, `order_id`, `status`, and timestamps, allowing merchants to update their order statuses. ```JSON { "ipn_type": "invoice", "event": "invoice_expired", "app_id": "cee1b9e2-d90c-4b63-9824-d621edb38012", "invoice_id": "3Q7fyLnB2YNhUDW1fFNyEz", "order_id": "20", "price_amount": 6.0, "price_currency": "SGD", "network": null, "address": null, "pay_currency": null, "pay_amount": 0.0, "exchange_rate": 0.0, "paid_amount": 0.0, "confirmed_amount": 0.0, "refunded_price_amount": 0.0, "create_time": "2022-09-12T03:36:03", "expiration_time": "2022-09-12T03:41:03", "status": "Expired", "error_status": "None", "ext_args": null, "transactions": null, "notify_id": "8ccd2b61-226b-48e5-99b8-acb1f35013e", "notify_time": "2022-09-12T03:56:10.5852752Z" } ``` -------------------------------- ### Cloning UniPaymentClient.Node Repository using Git Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This command clones the `UniPaymentClient.Node` project repository from GitHub to your local machine. This is the first step to set up the project for development or testing. ```bash git clone https://github.com/UniCryptoLab/UniPaymentClient.Node.git ``` -------------------------------- ### Running Tests for UniPaymentClient.Node Project with npm Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This command executes the test suite defined in the `package.json` file of the `UniPaymentClient.Node` project. It's used to verify the functionality and correctness of the project's code. ```bash npm test ``` -------------------------------- ### Cloning UniPaymentClient.Node Repository (Bash) Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This command clones the UniPaymentClient.Node project source code from its GitHub repository. It's the first step to setting up the project locally for development or testing. ```bash git clone https://github.com/UniCryptoLab/UniPaymentClient.Node.git ``` -------------------------------- ### UniPayment SDK Configuration File Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This JSON snippet illustrates the structure of the `configuration.json` file required to initialize the UniPayment SDK. It includes essential API credentials such as `apiHost`, `clientId`, `clientSecret`, `appId`, and `apiVersion`. ```JSON { "apiHost": "https://api.unipayment.io", "clientId": "your client id", "clientSecret": "you client secret", "appId": "your app id", "apiVersion": "1.0" } ``` -------------------------------- ### Initializing UniPayment SDK Modules in Node.js Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This Node.js snippet shows how to import and destructure the various API modules (BeneficiaryAPI, BillingAPI, CommonAPI, ExchangeAPI, PaymentAPI, WalletAPI) from the `unipayment-sdk` package. These modules are then used to interact with specific UniPayment API functionalities. ```Node.js const {BeneficiaryAPI, BillingAPI, CommonAPI, ExchangeAPI, PaymentAPI, WalletAPI} = require('unipayment-sdk'); ``` -------------------------------- ### Creating an Invoice with UniPayment SDK in JavaScript Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This JavaScript snippet demonstrates how to create a new invoice using the `BillingAPI` from the UniPayment SDK. It generates a unique `order_id` and sets parameters like `price_amount`, `price_currency`, and `app_id`, then handles the API response or error. ```javascript const {v4: uuidv4} = require('uuid'); const {BillingAPI} = require('unipayment-sdk'); const billingAPI = new BillingAPI(configuration); const createInvoiceRequest = { 'app_id': configuration.appId, 'order_id': uuidv4(), 'price_amount': 1.00, 'price_currency': 'USD', 'lang': 'en', 'ext_args': 'Merchant Pass Through Data' }; billingAPI.createInvoice(createInvoiceRequest).then(response => { printResponse(response); assert.equal(response.data.code === 'OK', true); done(); }).catch(error => { done(); console.log(error); }) ``` -------------------------------- ### Importing UniPayment SDK Modules in Node.js Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This Node.js snippet shows how to import various API modules from the `unipayment-sdk` package using CommonJS `require`. It provides access to different functionalities like Beneficiary, Billing, Common, Exchange, Payment, and Wallet APIs. ```nodejs const {BeneficiaryAPI, BillingAPI, CommonAPI, ExchangeAPI, PaymentAPI, WalletAPI} = require('unipayment-sdk'); ``` -------------------------------- ### Creating an Invoice with UniPayment SDK in JavaScript Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This JavaScript snippet demonstrates how to create a new payment invoice using the `BillingAPI` of the UniPayment SDK. It generates a unique `order_id` using `uuidv4` and sets parameters like `app_id`, `price_amount`, `price_currency`, and `lang` before sending the request. The response is then processed to check for success. ```JavaScript const {v4: uuidv4} = require('uuid'); const {BillingAPI} = require('unipayment-sdk'); const billingAPI = new BillingAPI(configuration); const createInvoiceRequest = { 'app_id': configuration.appId, 'order_id': uuidv4(), 'price_amount': 1.00, 'price_currency': 'USD', 'lang': 'en', 'ext_args': 'Merchant Pass Through Data' }; billingAPI.createInvoice(createInvoiceRequest).then(response => { printResponse(response); assert.equal(response.data.code === 'OK', true); done(); }).catch(error => { done(); console.log(error); }) ``` -------------------------------- ### Handling UniPayment IPN with SDK in JavaScript Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This JavaScript snippet demonstrates how to verify an Instant Payment Notification (IPN) received from UniPayment using the `CommonAPI`. It passes the raw notification payload to `checkIpn` and asserts the response for successful verification. ```javascript const {CommonAPI} = require('unipayment-sdk'); const commonAPI = new CommonAPI(configuration); const notify = 'notify from unipayment' commonAPI.checkIpn(notify).then(response => { printResponse(response); assert.equal(response.data.code === 'OK', true); assert.equal(response.data.msg === 'IPN is verified.', true) done(); }).catch(error => { done(); console.log(error); }) ``` -------------------------------- ### Handling Instant Payment Notifications (IPN) in JavaScript Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This JavaScript snippet demonstrates how to verify an Instant Payment Notification (IPN) received from UniPayment using the `CommonAPI`. The `checkIpn` method validates the incoming `notify` payload, ensuring its authenticity and integrity. This is crucial for securely processing payment status updates. ```JavaScript const {CommonAPI} = require('unipayment-sdk'); const commonAPI = new CommonAPI(configuration); const notify = 'notify from unipayment' commonAPI.checkIpn(notify).then(response => { printResponse(response); assert.equal(response.data.code === 'OK', true); assert.equal(response.data.msg === 'IPN is verified.', true) done(); }).catch(error => { done(); console.log(error); }) ``` -------------------------------- ### Verifying Webhook Signatures with UniPayment SDK (JavaScript) Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/README.md This snippet demonstrates how to verify a webhook's HMAC signature using the `WebhookSignatureUtil` from the `unipayment-sdk`. It requires the raw JSON payload, a secret key, and the signature to be verified. The `isValid` method returns a boolean indicating the signature's validity. ```javascript const {WebhookSignatureUtil} = require('unipayment-sdk'); //Use raw json payload (no formatting or pretty print) const payload = 'json payload'; const secretKey = 'your secret key'; const signature = 'signature to verify'; const valid = WebhookSignatureUtil.isValid($payload, $secretKey, $signature); ``` -------------------------------- ### Verifying Webhook Signature with UniPayment SDK in JavaScript Source: https://github.com/unicryptolab/unipaymentclient.node/blob/v2.x.x/unipaymentsdk/README.md This snippet demonstrates how to verify the 'hmac_signature' from a webhook request header using the `WebhookSignatureUtil` from the `unipayment-sdk`. It requires the raw JSON payload, a secret key, and the signature to be verified. The `isValid` method returns a boolean indicating the signature's validity. ```javascript const {WebhookSignatureUtil} = require('unipayment-sdk'); //Use raw json payload (no formatting or pretty print) const payload = 'json payload'; const secretKey = 'your secret key'; const signature = 'signature to verify'; const valid = WebhookSignatureUtil.isValid($payload, $secretKey, $signature); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.