https://github.com/danibram/adyen-client
Basic adyen client for nodeJs Integrations
https://github.com/danibram/adyen-client
adyen payment-integration
Last synced: 11 days ago
JSON representation
Basic adyen client for nodeJs Integrations
- Host: GitHub
- URL: https://github.com/danibram/adyen-client
- Owner: danibram
- License: mit
- Created: 2015-12-30T11:40:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-04-16T04:03:02.000Z (about 5 years ago)
- Last Synced: 2024-11-12T19:25:01.225Z (6 months ago)
- Topics: adyen, payment-integration
- Language: JavaScript
- Homepage: https://github.com/danibram/adyen-client
- Size: 257 KB
- Stars: 2
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Warning: If you are looking for a modern solution you must use the oficial one -> https://github.com/Adyen/adyen-node-api-library
# Adyen Client
[](https://greenkeeper.io/)
[](https://david-dm.org/danibram/adyen-client)
Adyen client
## Getting started
Install the module with: `npm install adyen-client`
```javascript
var adyenClient = require('adyen-client')
var aClient = adyenClient({
frontKey: 'YOUR FRONT END KEY', //Only used for the initCCForm
merchantAccount: 'YOUR MERCHANT ACCOUNT'
username: 'YOUR USERNAME',
password: 'YOUR PASSWORD',
version: 'v30', // by default is v12
development: true
});aClient
.getRecurringData({
"shopperReference": "SimonHopper1",
"recurring": {
"contract": "RECURRING"
}
}).then(function (response) {
console.log(util.inspect(response, false, 20, true));
})
.fail(function (error) {
console.log(util.inspect(error, false, 20, true));
});
```## Documentation
First of all you need to initialize the client passing your merchant account, username, password and front end key (only if you need to do the frontend initialization).
```javascript
var adyenClient = require('adyen-client');/*
opts = {
frontKey: 'YOUR FRONT END KEY', //Only used for the initCCForm
merchantAccount: 'YOUR MERCHANT ACCOUNT'
username: 'YOUR USERNAME',
password: 'YOUR PASSWORD'
version: 'VERSION', // URL versions by default is v12
development: Boolean //TRUE or FALSE indicates that your are on development, for production is not neccesary
}*/
var aClient = adyenClient(opts);
```Then you have the client initialized, now you have access to this methods, every method return a promise, and you need to follow the adyen documentation to know how pass the data:
* **_initCCForm_**: Promise that returns the structure you need for the CSE encryption in frontend.
```javascript
aClient.initCCForm().then(function(data) {
console.log(data);
/*
{
"key": '10008|927D950...', // your Front-end key
"generationTime": '2016-01-01T00:00:00.000Z' // ISO date string
}
*/
});
```* **_authorizePayment_**
```javascript
aClient
.authorizePayment({
shopperEmail: '[email protected]',
shopperReference: 'SimonHopper1',
recurring: {
contract: 'RECURRING'
},
reference: 'authorize-simonhopper1',
amount: {
value: '0',
currency: 'EUR'
},
additionalData: {
'card.encrypted.json': 'adyenjs_0_1_15$......'
}
})
.then(function(data) {
console.log(data);
});
```* **_authorize3dPayment_**
```javascript
aClient.authorize3dPayment({
"md": 'nOw6sWy2Kbu+bmg......'
"paResponse":"eNqtmFmTo7iygN/5FRU9......",
"browserInfo": {
"userAgent": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
"acceptHeader": "application/json, text/plain, */*"
}
})
.then(function(data){
console.log(data)
})
```* **_getRecurringData_**
```javascript
aClient
.getRecurringData({
shopperReference: 'SimonHopper1',
recurring: {
contract: 'RECURRING'
}
})
.then(function(data) {
console.log(data);
});
```* **_disableRecurring_**
```javascript
aClient
.disableRecurring({
shopperReference: 'SimonHopper1',
recurringDetailReference: 'CC TOKENIZED' //if you need to remove a specific one
})
.then(function(data) {
console.log(data);
});
```* **_capture_**
```javascript
aClient
.capture({
modificationAmount: {
currency: 'EUR',
value: '0'
},
originalReference: 'YOUR AUTH REFERENCE',
reference: 'capture-' + data.transactionId
})
.then(function(data) {
console.log(data);
});
```* **_refund_**
```javascript
aClient
.refund({
modificationAmount: {
currency: 'EUR',
value: '0'
},
originalReference: 'YOUR REFERENCE'
})
.then(function(data) {
console.log(data);
});
```* **_cancelOrRefund_**:
```javascript
aClient
.cancelOrRefund({
originalReference: 'YOUR REFERENCE'
})
.then(function(data) {
console.log(data);
});
```## Responses
The initCCForm returns the data example and the others returns this:
```javascript
{
success: Boolean, //TRUE or FALSE
data: {},//The Response from Adyen
lastResponse: {}, //Axios RAW response
lastRequest: {} //Axios RAW request
}
```## Development
Run `npm install;npm run dev` to watch the proyect, and compile the code automatically.
Run `npm build` to build the module.## Release History
#### (2.0.11)
* Update dependecies (Axios ^0.18)
* Added posibility to pass the version in the contructor#### (2.0.10)
* Update dependecies (Axios ^0.16)
* Added `authorize3dPayment` for handling 3D Secure authorization (Thanks @grimor)#### (2.0.7)
* Update dependencies
* Added success field in response
* Fix issues
* Internal refractor (ES6)
* Docs Changed
* Responses now returns the RAW request, and response#### (1.0.8)
* Internal Refactor
* Added more methods
* Better docs#### (1.0.7)
* Fix dependencies
* Firsts step.
* Added basic methods## License
Licensed under the MIT license. 2018