Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ativando o antifraude e ajust jslint #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
'env': {
'browser': true,
'node': true,
'es6': true
},
'parserOptions': {
'ecmaVersion': 9,
'sourceType': 'module'
},
'extends': 'eslint:recommended',
'rules': {
'indent': [
'error',
4
],
'linebreak-style': [
'error',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'always'
],
'require-atomic-updates': 'off',
'no-console': 'off',
'no-trailing-spaces': 'error'
},
'globals': {

}
};
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,27 @@ new eRede(store).create(transaction).then(transaction => {
}
});
```
## Autorizando uma transação com antifraud

```js
const eRede = require('./lib/erede');
const Transaction = require('./lib/transaction');
const Store = require('./lib/store');
const Environment = require('./lib/environment');

let store = new Store('TOKEN', 'PV', Environment.sandbox());
let transaction = new Transaction(10, "ref123", 2).creditCard(
'5448280000000007',
'235',
'12',
'2020',
'Fulano de Tal'
).setAntifraud(Environment.sandbox()).autoCapture(false);

new eRede(store).create(transaction).then(transaction => {
if (transaction.returnCode === "00") {
console.log(`Transação autorizada com sucesso: ${transaction.tid}`);
console.log(`Transação autorizada com sucesso: ${transaction.antifraud}`);
}
});
```
4 changes: 2 additions & 2 deletions lib/additional.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

module.exports = class Additional {
constructor(gateway, module) {
Expand All @@ -10,7 +10,7 @@ module.exports = class Additional {
let additional = new Additional();

for (let property in json) {
if (json.hasOwnProperty(property)) {
if (Object.prototype.hasOwnProperty.call(json, property)) {
additional[property] = json[property];
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/address.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

module.exports = class Address {
static get BILLING() {
Expand Down
8 changes: 4 additions & 4 deletions lib/antifraud.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"use strict";
'use strict';

module.exports = class Antifraud {
constructor() {
this.success = false;
}

static fromJSON(json) {
let antifraud = new self();

let antifraud = new this();
for (let property in json) {
if (json.hasOwnProperty(property)) {

if (Object.prototype.hasOwnProperty.call(json, property)) {
antifraud[property] = json[property];
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/authorization.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict";
'use strict';

module.exports = class Authorization {
static fromJSON(json) {
let authorization = new Authorization();

for (let property in json) {
if (json.hasOwnProperty(property)) {
if (Object.prototype.hasOwnProperty.call(json, property)) {
let value = json[property];

if (property === 'requestDateTime' || property === 'dateTime' || property === 'refundDateTime') {
Expand Down
4 changes: 2 additions & 2 deletions lib/capture.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict";
'use strict';

module.exports = class Capture {
static fromJSON(json) {
let capture = new Capture();

for (let property in json) {
if (json.hasOwnProperty(property)) {
if (Object.prototype.hasOwnProperty.call(json, property)) {
let value = json[property];

if (property === 'requestDateTime' || property === 'dateTime' || property === 'refundDateTime') {
Expand Down
8 changes: 4 additions & 4 deletions lib/cart.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
'use strict';

const Address = require("./address");
const Consumer = require("./consumer");
const Iata = require("./iata");
const Address = require('./address');
const Consumer = require('./consumer');
const Iata = require('./iata');

module.exports = class Cart {
address(type = Address.BOTH) {
Expand Down
8 changes: 4 additions & 4 deletions lib/consumer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
'use strict';

const Phone = require("./phone");
const Phone = require('./phone');

module.exports = class Consumer {
constructor(name, email, cpf) {
Expand All @@ -10,11 +10,11 @@ module.exports = class Consumer {
}

static get MALE() {
return "M";
return 'M';
}

static get FEMALE() {
return "F";
return 'F';
}

addDocument(type, number) {
Expand Down
14 changes: 7 additions & 7 deletions lib/environment.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use strict";
'use strict';

const PRODUCTION = "https://api.userede.com.br/erede";
const SANDBOX = "https://api.userede.com.br/desenvolvedores";
const VERSION = "v1";
const PRODUCTION = 'https://api.userede.com.br/erede';
const SANDBOX = 'https://api.userede.com.br/desenvolvedores';
const VERSION = 'v1';

module.exports = class Environment {
constructor(baseUrl, version = VERSION) {
this.ip = "";
this.sessionId = "";
this.ip = '';
this.sessionId = '';
this.endpoint = `${baseUrl}/${version}`;
}

Expand All @@ -16,6 +16,6 @@ module.exports = class Environment {
}

static sandbox() {
return new Environment(SANDBOX, VERSION)
return new Environment(SANDBOX, VERSION);
}
};
10 changes: 5 additions & 5 deletions lib/erede.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";
'use strict';

const CancelTransactionService = require("./service/CancelTransactionService");
const CaptureTransactionService = require("./service/CaptureTransactionService");
const CreateTransactionService = require("./service/CreateTransactionService");
const GetTransactionService = require("./service/GetTransactionService");
const CancelTransactionService = require('./service/CancelTransactionService');
const CaptureTransactionService = require('./service/CaptureTransactionService');
const CreateTransactionService = require('./service/CreateTransactionService');
const GetTransactionService = require('./service/GetTransactionService');

module.exports = class eRede {
constructor(store) {
Expand Down
2 changes: 1 addition & 1 deletion lib/exception/RedeError.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

module.exports = class RedeError extends Error {
constructor(message, code) {
Expand Down
4 changes: 2 additions & 2 deletions lib/flight.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strinct";
'use strinct';

const Passenger = require("./passenger");
const Passenger = require('./passenger');

module.exports = class Flight {
constructor(number, from, to, date) {
Expand Down
2 changes: 1 addition & 1 deletion lib/iata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

module.exports = class Iata {
constructor(code, departureTax) {
Expand Down
2 changes: 1 addition & 1 deletion lib/item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

module.exports = class Item {
constructor(id, quantity, type = Item.PHYSICAL) {
Expand Down
2 changes: 1 addition & 1 deletion lib/passenger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

module.exports = class Passenger {
constructor(name, email, ticket) {
Expand Down
2 changes: 1 addition & 1 deletion lib/phone.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

module.exports = class Phone {
constructor(ddd, number, type = Phone.CELLPHONE) {
Expand Down
4 changes: 2 additions & 2 deletions lib/refund.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict";
'use strict';

module.exports = class Refund {
static fromJSON(json) {
let refund = new Refund();

for (let property in json) {
if (json.hasOwnProperty(property)) {
if (Object.prototype.hasOwnProperty.call(json, property)) {
let value = json[property];

if (property === 'requestDateTime' || property === 'dateTime' || property === 'refundDateTime') {
Expand Down
2 changes: 1 addition & 1 deletion lib/service/CancelTransactionService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

const TransactionService = require('./TransactionService');

Expand Down
2 changes: 1 addition & 1 deletion lib/service/CaptureTransactionService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

const TransactionService = require('./TransactionService');

Expand Down
2 changes: 1 addition & 1 deletion lib/service/CreateTransactionService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

const TransactionService = require('./TransactionService');

Expand Down
2 changes: 1 addition & 1 deletion lib/service/GetTransactionService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

const TransactionService = require('./TransactionService');

Expand Down
4 changes: 2 additions & 2 deletions lib/service/TransactionService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

const Transaction = require('../transaction');
const RedeError = require('../exception/RedeError');
Expand Down Expand Up @@ -33,7 +33,7 @@ module.exports = class TransactionService {
throw new Error('Ńão implementado');
}

sendRequest(method, body = "") {
sendRequest(method, body = '') {
const url = new URL(this.getUrl());
const options = {
hostname: url.hostname,
Expand Down
4 changes: 2 additions & 2 deletions lib/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
'use strict';

const Environment = require("./environment.js");
const Environment = require('./environment.js');

module.exports = class Store {
constructor(token, filiation, environment = Environment.production()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/submerchant.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

module.exports = class SubMerchant {
constructor(mcc, city, country) {
Expand Down
10 changes: 5 additions & 5 deletions lib/threedsecure.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
"use strict";
'use strict';

module.exports = class ThreeDSecure {
constructor() {
this.embedded = true;
this.threeDIndicator = "1";
this.threeDIndicator = '1';
}

static get CONTINUE_ON_FAILURE() {
return "continue";
return 'continue';
}

static get DECLINE_ON_FAILURE() {
return "decline";
return 'decline';
}

static fromJSON(json) {
let threeds = new ThreeDSecure();

for (let property in json) {
if (json.hasOwnProperty(property)) {
if (Object.prototype.hasOwnProperty.call(json, property)) {
threeds[property] = json[property];
}
}
Expand Down
Loading