Skip to content

azpay/azpay-sdk-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AZPAY SDK for Node (WARNING: IN DEVELOPMENT)

npm

This SDK is currently in development. Coming soon :)

Installing

$ npm install --save azpay
OR
$ yarn add azpay

Creating AZPay object

import Azpay from 'azpay';

const azpay = Azpay({
  id: 'YOUR_MERCHANT_ID',
  key: 'YOUR_MERCHANT_KEY',
});

Creating a Sale transaction

Your need to have the AZPAY object (created before)

Using Javascript ES8 ASYNC/AWAIT:

try {
  const response = await azpay.transaction.sale({
    order: {
      ...
    },
    payment: {
      ...
    },
    billing: {
      ...
    },
    urlReturn: ...,
    fraud: ...,
  });
} catch (error) {
  // DEAL WITH ERROR HERE
}

Using Promises:

azpay.transaction.sale({
  order: {
    ...
  },
  payment: {
    ...
  },
  billing: {
    ...
  },
  urlReturn: ...,
  fraud: ...,
}).then((response) => {
    // DEAL WITH RESPONSE
  }).catch((error) => {
    // DEAL WITH ERROR HERE
  });

Creating a Paypal transaction

Your need to have the AZPAY object (created before)

Using Javascript ES8 ASYNC/AWAIT:

try {
  const response = await azpay.transaction.paypal({
    order: {
      ...
    },
    payment: {
      ...
    },
    billing: {
      ...
    },
    urlReturn: ...,
  });
} catch (error) {
  // DEAL WITH ERROR HERE
}

Using Promises:

azpay.transaction.paypal({
  order: {
    ...
  },
  payment: {
    ...
  },
  billing: {
    ...
  },
  urlReturn: ...,
}).then((response) => {
    // DEAL WITH RESPONSE
  }).catch((error) => {
    // DEAL WITH ERROR HERE
  });

How to run the tests (For SDK developers only)

You must have a config file on the root called test.config.js:

export default {
  merchant_id: 'YOUR_MERCHANT_ID',
  merchant_key: 'YOUR_MERCHANT_KEY',
};

Run on your terminal:

yarn test

PS: The test.config.js file is ignored on .gitignore

About

The AZPay SDK for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published