🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

netopia-payment2

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netopia-payment2

The NETOPIA Payments package provides access to the NETOPIA Payments API V2 from applications written in server-side JavaScript.

0.1.6
latest
Source
npm
Version published
Weekly downloads
8
166.67%
Maintainers
0
Weekly downloads
 
Created
Source

NETOPIA Payments Package

The NETOPIA Payments package provides access to the NETOPIA Payments API V2 from applications written in server-side JavaScript.

Table of Contents

  • Installation
  • Usage
  • API Reference
  • Error Handling
  • Useful Links

Installation

Install the package with:

npm i netopia-payment2

or

yarn add netopia-payment2

Usage

The package needs to be configured with your account's API key and signature key, which are available in the NETOPIA Payments admin.

API Reference

Netopia Constructor

const { Netopia } = require("netopia-payment2");

const netopia = new Netopia({ apiKey, posSignature, isLive });

Creates a new instance of the Netopia class.

Note
API Key: NETOPIA Payments admin > Profile > Security
POS Signature: NETOPIA Payments admin > Point of sale > Technical settings

Parameter list
constructor paramsTypeDefaultDescriptionRequired
apiKeystringnullAPI key provided by NETOPIAYes
posSignaturestringnullSignature provided by NETOPIAYes
isLiveBooleanfalseUse for sandboxNo

Netopia Methods

createOrder

Creates a new order for payment.

const response = await netopia.createOrder(configData, paymentData, orderData);

Example:

const configData = {
  emailTemplate: "Email template",
  emailSubject: "Email subject",
  notifyUrl: "https://www.my.domain/my_notify_url",
  redirectUrl: "https://www.my.domain/my_redirect_url",
  cancelUrl: "https://www.my.domain/my_cancel_url",
  language: "ro",
};
const paymentData = {
    options: {
        "installments": 0,
        "bonus": 0,
        "split": [
            {
                posID: 0,
                amount: 0
            }
        ]
    },
    instrument: {
        "type": "card",
        "account": "9900004810225098",
        "expMonth": 12,
        "expYear": 2022,
        "secretCode": "111",
        "token": "",
        "clientID": ""
    },
    data: {
        "property1": "string",
        "property2": "string"
    }
};
const orderData = {
    ntpID: '',
    orderID: "XXXXXXX",
    description: "Some order description",
    amount: 0.1,
    currency: "RON",
    dateTime: "2023-09-27T15:48:17",
    products: {
        name: 'Product name'
        code: 'xxx',
        category: 'Category name',
        price: 10,
        vat: 19,
    },
    billing: {
        email: "user@example.com",
        phone: "+407xxxxxxxx",
        firstName: "First",
        lastName: "Last",
        city: "City",
        country: 642,
        countryName: "Country",
        state: "State",
        postalCode: "Zip",
        details: "",
    },
    shipping: {
        email: "user@example.com",
        phone: "+407xxxxxxxx",
        firstName: "First",
        lastName: "Last",
        city: "City",
        country: 642,
        countryName: "Country",
        state: "State",
        postalCode: "Zip",
        details: "",
    },
    installments: {
        selected: 0,
        available: [ 0 ];
    }
    data: {
        "property1": "string",
        "property2": "string"
    }
}

Note
The shippingData is optional

Parameter list

Fields for configData

FieldTypeDescriptionRequired
emailTemplatestringRequired only for custom notification emails; shared by NETOPIANo
emailSubjectstringNotification e-mail subject; mandatory if emailTemplate is presentYes
cancelUrlstringURL where NETOPIA will send payment result notificationsYes
notifyUrlstringURL on the merchant side where NETOPIA will send payment resultsYes
redirectUrlstringURL on the merchant side where 3-D Secure authentication response sentYes
languagestringLanguage for notifications; use ISO 639-1 codesYes

Fields for paymentData

FieldTypeDescription
optionsobjectPayment options information
installmentsintegerSet the installments number for the client to pay in
bonusintegerSet the loyalty points number for the client to use
splitarray[object]Split payments (will be available in future versions)
posIDintegerDestination POS
amountnumberAmount to be disbursed; should always be smaller than order amount
- Must be greater than or equal to 0
instrumentobjectPayment instrument information
typestringMandatory for all payment methods except token
accountstringMandatory for all payment methods except token
- If type is card, this is the card number
expMonthintegerExpiration month (mandatory if type is card)
expYearintegerExpiration year (mandatory if type is card)
secretCodestringCard security code (CVV/CVC) for card payments
- Must be less than or equal to 4 characters
tokenstringIf present, token overrides all other data
clientIDstringIf present, binding, etc.
dataAtributesPayment-specific information (customer browser and device data)

Fields for orderData

FieldTypeDescriptionRequired
ntpIDstringNETOPIA internal idNo
posSignaturestringMerchant POS identifier, available in your NETOPIA accountYes
- Must have between 0 and 64 characters
dateTimestringOrder registration dateYes
descriptionstringOrder descriptionYes
orderIDstringMerchant internal order idYes
amountnumberAmount to be paid (set to 0 for account verification)Yes
- Must be greater than or equal to 0
- Must be less than or equal to 100000
currencystringCurrency using ISO 4217 alpha codesYes
- Must have between 3 characters and 3 characters
billingobjectCustomer billing informationYes
emailstringCustomer email addressYes
phonestringCustomer phone numberYes
firstNamestringCustomer first nameYes
lastNamestringCustomer last nameYes
citystringCustomer cityYes
countryintegerCustomer country using ISO 3166-1 numeric codesYes
countryNamestringCustomer country nameYes
statestringCustomer stateYes
postalCodestringCustomer postal codeYes
detailsstringCustomer address details, interphoneYes
shippingobjectCustomer shipping informationNo
productsarray[object]Array of product objectsNo
installmentsobjectNo
selectedintegerAvailableNo
availablearray[integer]Array of integersNo
dataAtributesCustom merchant parameters related to the orderNo

Response

Example:

{
    code: 200,
    message: 'You send your request successfully',
    data: {
        customerAction: {},
        error: { code: '101', message: 'Redirect user to payment page' },
        payment: {
            amount: 0.1,
            currency: 'RON',
            ntpID: '1234567',
            operationDate: '0001-01-01T00:00:00',
            paymentURL: 'https://secure-sandbox.netopia-payments.com/ui/card?p=XXXXX-XXXX-XXXX',
            status: 1
        }
    }
}

getStatus

Get status of an order.

const response = await netopia.getStatus(ntpID);
Parameter list
FieldTypeDescriptionRequired
ntpIDstringNETOPIA internal id you received in your start responseYes

Response

Example:

{
  "code": 200,
  "message": "Successfully get payment status",
  "data": {
    "bnpl": {
      "oney": {}
    },
    "config": {
      "emailTemplate": "Comanda platita",
      "language": "ro",
      "notifyUrl": "https://www.my.domain/my_notify_url",
      "redirectUrl": "https://www.my.domain/my_redirect_url",
      "cancelUrl": "https://www.my.domain/my_cancel_url"
    },
    "customerAction": {},
    "error": {
      "code": "00",
      "message": "Approved"
    },
    "merchant": {
      "merchantName": "Test test",
      "posID": 00000,
      "posName": "NETOPIA Test",
      "posType": 0,
      "posUrl": "https://www.my.domain/",
      "qrType": 1,
      "showCancel": false
    },
    "order": {
      "amount": 0.1,
      "billing": {
        "email": "user@example.com",
        "phone": "+407xxxxxxxx",
        "firstName": "First",
        "lastName": "Last",
        "city": "City",
        "country": 642,
        "countryName": "Country",
        "state": "State",
        "postalCode": "Zip",
        "details": ""
      },
      "shipping": {
        "email": "user@example.com",
        "phone": "+407xxxxxxxx",
        "firstName": "First",
        "lastName": "Last",
        "city": "City",
        "country": 642,
        "countryName": "Country",
        "state": "State",
        "postalCode": "Zip",
        "details": ""
      },
      "currency": "RON",
      "dateTime": "2023-09-27T15:48:17",
      "description": "produse diverse",
      "installments": {
        "selected": 0
      },
      "ntpID": "XXXXX",
      "orderID": "000000",
      "posSignature": "XXXX-XXXX-XXXX-XXXX-XXXX"
    },
    "payment": {
      "allowedMethods": [
        "card"
      ],
      "amount": 0.1,
      "binding": {
        "expireMonth": 0,
        "expireYear": 0
      },
      "currency": "RON",
      "instrument": {
        "country": 0
      },
      "ntpID": "2010313",
      "operationDate": "2024-11-06T10:38:44",
      "options": {
        "bonus": 0,
        "installments": 1
      },
      "rrn": "XXXxxxxx",
      "status": 3
    }
  }
}

verifyAuth

Verify-auth use is only for the transactions with 3DS cards and after you have authorize end-point response.

const response = await netopia.verifyAuth(authenticationToken, ntpID, formData);
Parameter list
FieldTypeDescriptionRequired
authenticationTokenstringThe authentication token you received in your start responseYes
ntpIDstringNETOPIA internal id you received in your start responseYes
formDataobject3-D Secure authentication response; all data received in your redirectUrl is mandatory and should not be alteredYes

Response

Example:

{
    "status": 1,
    "code": 200,
    "message": "Successfully verify authentication ",
    "data": {
        "error": {
        "code": "00",
        "message": "Approved"
        },
        "payment": {
        "amount": 10,
        "currency": "RON",
        "data": {
            "AuthCode": "1XXX",
            "BIN": "990000",
            "ISSUER": "Netopia",
            "ISSUER_COUNTRY": "642",
            "RRN": "XXXxxxx"
        },
        "ntpID": "1234567",
        "status": 3,
        "token": "NTY1Mzq4mwb4nynMLEfcwrA0MnEUJ/19Pk9doJWe5PWxoLhQC++W/Eqh6h/wB1KCDVSiBCkaWYtFzWyFoP6YbS"
        }
    }
}

IPN Constructor

const { Ipn } = require("netopia-payment2"); // ES5

const netopiaIpn = new Ipn({
  posSignature,
  posSignatureSet,
  hashMethod,
  alg,
  publicKeyStr,
});

Creates a new instance of the Ipn class.

Parameter list
constructor paramsTypeDefaultDescriptionRequired
posSignaturestringnullSignature provided by NETOPIAYes
posSignatureSetarraynullAll POS Signatures provided by NETOPIAYes
hashMethodstring'sha512'Hash method usedNo
algstring'RS512'AlgorithmNo
publicKeystringnullPublic Key provided by NETOPIAYes

Ipn Methods

verify

const response = await netopiaIpn.verify(verificationToken, rawData);
Parameter list
FieldTypeDefaultDescriptionRequired
verificationTokenstringnullVerification token provided by NETOPIAYes
rawDatastringnullData provided by NETOPIA in the IPNYes

Response

Example:

   {
    errorType: 2,
    errorCode: 1234,
    errorMessage: 'Payment was confirmed; deliver goods',
    message: null,
    status: null
  }

Error Handling

Error codes

  • 0 : Card has no 3DS
  • 16 : Declined. Card has a risk
  • 17 : Invalid card number
  • 18 : Closed card
  • 19 : Expired card
  • 20 : Insufficient funds
  • 21 : Invalid CVV
  • 22 : Issuer error
  • 23 : Order is expired
  • 26 : Card limit exceeded
  • 34 : Transaction not allowed
  • 35 : Transaction declined (no reason specified)
  • 36 : Transaction declined by antifraud system
  • 39 : 3DSecure authentication failed
  • 56 : duplicated Order ID
  • 99 : General error
  • 100 : Requires 3-D Secure authentication
  • 101 : Redirect user to payment URL
  • 102 : Payment locked, 3DSecure authentication pending

Status codes

  • 3 : is paid
  • 5 : is confirmed
  • 12 : rejected
  • 15 : need authorize

License

This project is licensed under the MIT License. See the LICENSE file for details.

FAQs

Package last updated on 18 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts