Skip to content

Commit

Permalink
Remove deprecated barionTransfer function. Closes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
aron123 committed Dec 12, 2020
1 parent 41ce100 commit 0d2ba2e
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 323 deletions.
58 changes: 0 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Helps manage e-payment transactions through the [Barion Smart Gateway](https://w
- [Send money to a bank account](#send-money-to-a-bank-account---barionbanktransferoptions-callback)
- [Get existing accounts of the user](#get-existing-accounts-of-the-user---bariongetaccountsoptions-callback)
- [Send money to a Barion user or email address](#send-e-money-to-an-email-address---barionemailtransferoptions-callback)
- [Send money to a Barion user or email address](#send-money-to-a-barion-user-or-email-address---barionbariontransferoptions-callback) ![][DEPRECATED]
- [Download statement files](#download-statement-files---bariondownloadstatementoptions-callback)

- [Handling errors](#handling-errors)
Expand Down Expand Up @@ -589,63 +588,6 @@ barion.emailTransfer({
});
```

### Send money to a Barion user or email address - barion.barionTransfer(options, \[callback\])
![][DEPRECATED]
> **IMPORTANT**: This function is deprecated since version 2.1.0, and will be removed in the next major version of the module.
> Please use the [emailTransfer](#send-e-money-to-an-email-address---barionemailtransferoptions-callback) function instead.
To send money to a Barion user or to an email address, call the ``barionTransfer`` function. [[Barion Docs](https://docs.barion.com/Transfer-Send-v1)]

**Parameters**:
- ``UserName``: Email address of the shop in the Barion system (string). (required)

- ``Password``: Password of the shop in the Barion system (string). (required)

- ``Currency``: The currency to use (string). (optional, because it is assigned in the constructor)<br>
Allowed values are:
- ``'CZK'`` (Czech crown)
- ``'EUR'`` (Euro)
- ``'HUF'`` (Hungarian forint)
- ``'USD'`` (U.S. dollar)

- ``Amount``: Amount of the money to send (number). (required)

- ``Recipient``: Email address of the recipient (string). (required)

- ``Comment``: Comment of the transfer (string). (optional)

**Output**: [Read at Barion Docs](https://docs.barion.com/Transfer-Send-v1#Output_properties)

#### Usage example
##### With callback
```js
barion.barionTransfer({
UserName: 'info@example.com',
Password: 'someRlyStrongP4ss#!',
Currency: 'HUF',
Amount: 1,
Recipient: 'info@example.com',
Comment: 'Have a nice party'
}, function (err, data) {
//handle error / process data
});
```
##### With promise
```js
barion.barionTransfer({
UserName: 'info@example.com',
Password: 'someRlyStrongP4ss#!',
Currency: 'HUF',
Amount: 1,
Recipient: 'info@example.com',
Comment: 'Have a nice party'
}).then(data => {
//process data
}).catch(err => {
//handle error
});
```

### Download statement files - barion.downloadStatement(options, \[callback\])
To download monthly or daily statement files generated by the Barion system, call the ``downloadStatement`` function. [[Barion Docs](https://docs.barion.com/Statement-Download-v2)]

Expand Down
17 changes: 0 additions & 17 deletions lib/barion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const {
PaymentRefund,
BankTransfer,
GetAccounts,
SendTransfer,
EmailTransfer,
StatementDownload
} = require('./domain');
Expand Down Expand Up @@ -204,22 +203,6 @@ Barion.prototype.getAccounts = function (options, callback) {
}, callback);
};

/**
* Sends money between accounts in Barion.
* @param {Object} options - Options that are required to send money to Barion user.
* @param {Function} [callback] - Callback that handles the response. If not passed, the function returns a *Promise*.
* @see {@link https://docs.barion.com/Transfer-Send-v1|Barion API Documentation}
* @deprecated since version 2.1.0
*/
Barion.prototype.barionTransfer = function (options, callback) {
return doRequestAndReturn({
defaults: this.defaults,
customs: options,
schema: SendTransfer,
service: services.barionTransfer
}, callback);
};

/**
* Sends e-money to a given e-mail address.
* @param {Object} options - Options that are required to send money.
Expand Down
6 changes: 0 additions & 6 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const {
PaymentRefund,
BankTransfer,
GetAccounts,
SendTransfer,
EmailTransfer,
StatementDownload
} = require('./domain');
Expand Down Expand Up @@ -62,11 +61,6 @@ module.exports = {
path: '/v2/Accounts/Get',
model: GetAccounts
},
barionTransfer: {
method: 'POST',
path: '/v1/Transfer/Send',
model: SendTransfer
},
emailTransfer: {
method: 'POST',
path: '/v2/Transfer/Email',
Expand Down
25 changes: 0 additions & 25 deletions lib/domain/SendTransfer.js

This file was deleted.

2 changes: 0 additions & 2 deletions lib/domain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const CancelAuthorization = require('./CancelAuthorization');
const PaymentRefund = require('./PaymentRefund');
const BankTransfer = require('./BankTransfer');
const GetAccounts = require('./GetAccounts');
const SendTransfer = require('./SendTransfer');
const EmailTransfer = require('./EmailTransfer');
const StatementDownload = require('./StatementDownload');

Expand All @@ -21,7 +20,6 @@ module.exports = {
PaymentRefund,
BankTransfer,
GetAccounts,
SendTransfer,
EmailTransfer,
StatementDownload
};
11 changes: 0 additions & 11 deletions lib/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,6 @@ function getAccounts(environment, options) {
return doRequest(environment, endPoints.getAccounts, options);
}

/**
* Sends money between accounts in Barion.
* @param {String} environment - The environment to use ('test' or 'prod').
* @param {Object} options - The final request body to send to the Barion API.
*/
function barionTransfer(environment, options) {
console.warn('WARNING! node-barion module\'s barionTransfer function has been deprecated since version 2.1.0 and will be removed in the next major version of the module. Please use the "emailTransfer" function instead.');
return doRequest(environment, endPoints.barionTransfer, options);
}

/**
* Sends money to an email address.
* @param {String} environment - The environment to use ('test' or 'prod').
Expand Down Expand Up @@ -149,7 +139,6 @@ module.exports = {
cancelAuthorizedPayment,
bankTransfer,
getAccounts,
barionTransfer,
emailTransfer,
downloadStatement,
_private: {
Expand Down
79 changes: 0 additions & 79 deletions test/barion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const Barions = {
cancelAuthorizedPayment: returnSuccess,
refundPayment: returnSuccess,
bankTransfer: returnSuccess,
barionTransfer: returnSuccess,
getAccounts: returnSuccess,
emailTransfer: returnSuccess,
downloadStatement: returnSuccess
Expand All @@ -64,7 +63,6 @@ const Barions = {
cancelAuthorizedPayment: returnError,
refundPayment: returnError,
bankTransfer: returnError,
barionTransfer: returnError,
getAccounts: returnError,
emailTransfer: returnError,
downloadStatement: returnError
Expand All @@ -79,7 +77,6 @@ const Barions = {
cancelAuthorizedPayment: returnSuccess,
refundPayment: returnSuccess,
bankTransfer: returnSuccess,
barionTransfer: returnSuccess,
getAccounts: returnSuccess,
emailTransfer: returnSuccess,
downloadStatement: returnSuccess
Expand All @@ -97,7 +94,6 @@ const Barions = {
cancelAuthorizedPayment: returnSuccess,
refundPayment: returnSuccess,
bankTransfer: returnSuccess,
barionTransfer: returnSuccess,
getAccounts: returnSuccess,
emailTransfer: returnSuccess,
downloadStatement: returnSuccess
Expand Down Expand Up @@ -698,81 +694,6 @@ describe('lib/barion.js', function () {
});
});

describe('#barionTransfer(options, [callback])', function () {
const request = {
UserName: 'info@example.com',
Password: 'admin1234',
Currency: 'HUF',
Amount: 1500,
Recipient: 'admin@example.com'
};

it('should answer with callback on success', function (done) {
okBarion.barionTransfer(request, (err, res) => {
expect(err).to.be.null;
expect(res).to.deep.equal(successObject);
done();
});
});

it('should answer with callback on success when validation is turned off', function (done) {
okBarionWithoutValidation.barionTransfer(request, (err, res) => {
expect(err).to.be.null;
expect(res).to.deep.equal(successObject);
done();
});
});

it('should answer with callback on error', function (done) {
serviceErrorBarion.barionTransfer(request, (err, res) => {
expect(err).to.deep.equal(errorObject);
expect(res).to.be.null;
done();
});
});

it('should answer with callback on validation error', function (done) {
validationErrorBarion.barionTransfer(request, (err, res) => {
expect(err).to.deep.equal(validationErrorObject);
expect(res).to.be.null;
done();
});
});

it('should answer with callback on sanitization error when validation is turned off', function (done) {
sanitizationErrorBarion.barionTransfer(request, (err, res) => {
expect(err).to.deep.equal(sanitizationErrorObject);
expect(res).to.be.null;
done();
});
});

it('should answer with Promise on success', function (done) {
const promise = okBarion.barionTransfer(request);
expect(promise).to.eventually.deep.equal(successObject).notify(done);
});

it('should answer with Promise on success when validation is turned off', function (done) {
const promise = okBarionWithoutValidation.barionTransfer(request);
expect(promise).to.eventually.deep.equal(successObject).notify(done);
});

it('should answer with Promise on error', function (done) {
const promise = serviceErrorBarion.barionTransfer(request);
expect(promise).to.eventually.rejectedWith(errorObject).notify(done);
});

it('should answer with Promise on validation error', function (done) {
const promise = validationErrorBarion.barionTransfer(request);
expect(promise).to.eventually.rejectedWith(validationErrorObject).notify(done);
});

it('should answer with Promise on sanitization error when validation is turned off', function (done) {
const promise = sanitizationErrorBarion.barionTransfer(request);
expect(promise).to.eventually.rejectedWith(sanitizationErrorObject).notify(done);
});
});

describe('#getAccounts(options, [callback])', function () {
const request = {
UserName: 'info@example.com',
Expand Down
82 changes: 0 additions & 82 deletions test/integration/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,88 +327,6 @@ describe('Integration tests', function () {
);
});

describe('Barion transfer (callback)', function () {
it('should start Barion transfer when validation is turned on', function (done) {
validatedBarion.barionTransfer(testData.barionTransfer.successRequestBody, (err, res) => {
expect(err).to.be.null;
expect(res).to.deep.include(testData.barionTransfer.successResponseBody);
done();
});
});

it('should answer with BarionModelError when request object is not proper and validation is turned on',
function (done) {
validatedBarion.barionTransfer(testData.barionTransfer.errorRequestBody, (err, res) => {
expect(res).to.be.null;
expect(err.name).to.equal('BarionModelError');
expect(err.errors).to.be.an('array').and.have.length.greaterThan(0);
done();
});
}
);

it('should start Barion transfer when validation is turned off', function (done) {
notValidatedBarion.barionTransfer(testData.barionTransfer.successRequestBody, (err, res) => {
expect(err).to.be.null;
expect(res).to.deep.include(testData.barionTransfer.successResponseBody);
done();
});
});

it('should answer with BarionError when request object is not proper and validation is turned off',
function (done) {
notValidatedBarion.barionTransfer(testData.barionTransfer.errorRequestBody, (err, res) => {
expect(res).to.be.null;
expect(err.name).to.equal('BarionError');
expect(err.errors).to.be.an('array');
expect(err.errors[0]).to.deep.include(testData.barionTransfer.expectedError);
done();
});
}
);
});

describe('Barion transfer (Promise)', function () {
it('should start Barion transfer when validation is turned on', function (done) {
validatedBarion.barionTransfer(testData.barionTransfer.successRequestBody)
.then(res => {
expect(res).to.deep.include(testData.barionTransfer.successResponseBody);
done();
});
});

it('should answer with BarionModelError when request object is not proper and validation is turned on',
function (done) {
validatedBarion.barionTransfer(testData.barionTransfer.errorRequestBody)
.catch(err => {
expect(err.name).to.equal('BarionModelError');
expect(err.errors).to.be.an('array').and.have.length.greaterThan(0);
done();
});
}
);

it('should start Barion transfer when validation is turned off', function (done) {
notValidatedBarion.barionTransfer(testData.barionTransfer.successRequestBody)
.then(res => {
expect(res).to.deep.include(testData.barionTransfer.successResponseBody);
done();
});
});

it('should answer with BarionError when request object is not proper and validation is turned off',
function (done) {
notValidatedBarion.barionTransfer(testData.barionTransfer.errorRequestBody)
.catch(err => {
expect(err.name).to.equal('BarionError');
expect(err.errors).to.be.an('array');
expect(err.errors[0]).to.deep.include(testData.barionTransfer.expectedError);
done();
});
}
);
});

describe('Get accounts (callback)', function () {
it('should query accounts when validation is turned on', function (done) {
validatedBarion.getAccounts(testData.getAccounts.successRequestBody, (err, res) => {
Expand Down
Loading

0 comments on commit 0d2ba2e

Please sign in to comment.