Socket
Book a DemoInstallSign in
Socket

@heidelpay/nodejs-sdk

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@heidelpay/nodejs-sdk

Heidelpay SDK NodeJS

1.3.1
latest
npmnpm
Version published
Weekly downloads
14
Maintainers
2
Weekly downloads
 
Created
Source

Heidelpay SDK NodeJS

License Version Download

The Heidelpay SDK NodeJS provides convenient access to the Heidelpay API from applications written in server-side JavaScript.

Documentation

See the Node API docs.

Installation

Install the package with:

npm install --save @heidelpay/nodejs-sdk

Usages

The package needs to be configured with your private key. Make sure you have it first

Using Common JS

var Heidelpay = require('@heidelpay/nodejs-sdk').default;

// Create new instance Heidelpay
var heidelpay = new Heidelpay('s-priv-...');

Or using ES module

import Heidelpay from '@heidelpay/nodejs-sdk';

// Create new instance Heidelpay
const heidelpay = new Heidelpay('s-priv-...');

Or using TypeScript:

import Heidelpay from '@heidelpay/nodejs-sdk';

// Create new instance Heidelpay
const heidelpay = new Heidelpay('s-priv-...');

Example

Using Promise

Authorize with a payment type (Card)

var Heidelpay = require('@heidelpay/nodejs-sdk').default;
var Card = require('@heidelpay/nodejs-sdk').Card;
var Customer = require('@heidelpay/nodejs-sdk').Customer;

// Create new instance Heidelpay
var heidelpay = new Heidelpay('s-priv-...');

// New a card with pan number and exipry date
var card = new Card('471110xxxxxx0000', '01/xxxx');

// Set CVC
card.setCVC('xxx');

// Create customer object
var customer = new Customer('Rene', 'Fred');

heidelpay.createCustomer(customer).then(function(newCustomer) {
  // Create payment type then authorize (Card)
  return heidelpay.createPaymentType(card);
}).then(function(paymentCard) {    
  // Authorize with payment card
  return paymentCard.authorize({
    amount: 100,
    currency: 'EUR',
    typeId: paymentCard.getId(),
    returnUrl: 'https://www.google.at'
  })
}).then(function(authorize) {
  // Authorize successful
  console.log('authorize', authorize.getId());
}).catch(function (error) {
  // Handle error
  console.log('error', error);
});

Using async / await (ES6 style)

import Heidelpay, {Card} from '@heidelpay/nodejs-sdk';

// Create new instance Heidelpay
const heidelpay = new Heidelpay('s-priv-...');

// New a card with pan number and exipry date
const card = new Card('471110xxxxxx0000', '01/xxxx');

// Set CVC
card.setCVC('xxx');

// Create customer object
const customer = new Customer('Rene', 'Fred');

// Should wrap these code into async function (async/await syntax)
try {
  // Create a new customer
  const newCustomer = await heidelpay.createCustomer(customer);

  // Create payment type then authorize (Card)
  const paymentCard = await heidelpay.createPaymentType(card);

  // Authorize with payment card
  const authorize = await paymentCard.authorize({
    amount: 100,
    currency: 'EUR',
    typeId: paymentCard.getId(),
    returnUrl: 'https://www.google.at'
  });
} catch (error) {
  // Handle error
  console.log('error', error);
}

License

Apache 2.0

Keywords

heidelpay

FAQs

Package last updated on 31 Mar 2020

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.