Skip to content

Commit

Permalink
Merge branch 'master' into emirgundem-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterSlave authored Feb 9, 2024
2 parents 9a36769 + 9eeafe9 commit 30c978b
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 25 deletions.
20 changes: 20 additions & 0 deletions samples/fraud/AddCardFingerprintToFraudValueList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

const Craftgate = require('../../dist');

const craftgate = new Craftgate.Client({
apiKey: 'api-key',
secretKey: 'secret-key',
baseUrl: 'https://sandbox-api.craftgate.io'
});

//request
const request = {
listName: 'cardList',
type: Craftgate.Model.FraudValueType.Card,
label: "John Doe's Card",
paymentId: 11675
};

craftgate.fraud().addValueToValueList(request)
.then(() => console.info('Value added to fraud value list'))
.catch(err => console.error('Failed to add value to fraud value list', err));
12 changes: 10 additions & 2 deletions samples/fraud/AddTemporaryValueToFraudValueList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const Craftgate = require('../../dist');

const craftgate = new Craftgate.Client({
Expand All @@ -7,6 +6,15 @@ const craftgate = new Craftgate.Client({
baseUrl: 'https://sandbox-api.craftgate.io'
});

craftgate.fraud().addValueToValueList("ipList", "127.0.0.2", 60)
//request
const request = {
listName: 'ipList',
type: Craftgate.Model.FraudValueType.Ip,
label: "local ip 2",
value: "127.0.0.2",
durationInSeconds: 60
};

craftgate.fraud().addValueToValueList(request)
.then(() => console.info('Value added to fraud value list'))
.catch(err => console.error('Failed to add value to fraud value list', err));
10 changes: 9 additions & 1 deletion samples/fraud/AddValueToFraudValueList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ const craftgate = new Craftgate.Client({
baseUrl: 'https://sandbox-api.craftgate.io'
});

craftgate.fraud().addValueToValueList("ipList", "127.0.0.1", null)
//request
const request = {
listName: 'ipList',
type: Craftgate.Model.FraudValueType.Ip,
label: "local ip 1",
value: "127.0.0.1"
};

craftgate.fraud().addValueToValueList(request)
.then(() => console.info('Value added to fraud value list'))
.catch(err => console.error('Failed to add value to fraud value list', err));
2 changes: 1 addition & 1 deletion samples/fraud/CreateFraudValueList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ const craftgate = new Craftgate.Client({
baseUrl: 'https://sandbox-api.craftgate.io'
});

craftgate.fraud().createValueList("ipList")
craftgate.fraud().createValueList("ipList", Craftgate.Model.FraudValueType.Ip)
.then(() => console.info('Fraud value list created'))
.catch(err => console.error('Failed to create fraud value list', err));
2 changes: 1 addition & 1 deletion samples/fraud/RemoveValueFromFraudValueList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ const craftgate = new Craftgate.Client({
baseUrl: 'https://sandbox-api.craftgate.io'
});

craftgate.fraud().removeValueFromValueList("ipList", "127.0.0.1")
craftgate.fraud().removeValueFromValueList("ipList", "5758a029-4a82-4e47-a0cf-36d34052b8e5")
.then(() => console.info('Value removed from fraud value list'))
.catch(err => console.error('Failed to remove value from fraud value list', err));
2 changes: 1 addition & 1 deletion samples/payment/BnplPaymentOffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const request = {
id: "100",
name: "Test Elektronik 1",
brandName: "Samsung",
type: Craftgate.Model.BnplCartItemType.MobilePhoneOver5000Try,
type: Craftgate.Model.BnplCartItemType.MobilePhonePriceAboveRegulationLimit,
unitPrice: 4000,
quantity: 1,
}
Expand Down
2 changes: 1 addition & 1 deletion samples/payment/InitBnplPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const request = {
id: "100",
name: "Test Elektronik 1",
brandName:"Samsung",
type: Craftgate.Model.BnplCartItemType.MobilePhoneOver5000Try,
type: Craftgate.Model.BnplCartItemType.MobilePhonePriceAboveRegulationLimit,
unitPrice: 4000,
quantity: 1,
}
Expand Down
21 changes: 11 additions & 10 deletions src/adapter/FraudAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {ClientCreationOptions} from '../lib/HttpClient';
import FraudCheckStatus from '../model/FraudCheckStatus';
import FraudValueType from '../model/FraudValueType';

import FraudValueListRequest from '../request/FraudValueListRequest';
import SearchFraudChecksRequest from '../request/SearchFraudChecksRequest';

import FraudAllValueListsResponse from '../response/FraudAllValueListsResponse';
Expand Down Expand Up @@ -30,23 +32,22 @@ export default class FraudAdapter extends BaseAdapter {
return this._client.get(`/fraud/v1/value-lists/${listName}`);
}

async createValueList(listName: string): Promise<void> {
await this.addValueToValueList(listName, null, null);
async createValueList(listName: string, type: FraudValueType): Promise<void> {
await this.addValueToValueList({
listName: listName,
type: type
});
}

async deleteValueList(listName: string): Promise<void> {
await this._client.delete(`/fraud/v1/value-lists/${listName}`);
}

async addValueToValueList(listName: string, value: string, expireInSeconds: number): Promise<void> {
await this._client.post(`/fraud/v1/value-lists`, {
listName: listName,
value: value,
durationInSeconds: expireInSeconds
});
async addValueToValueList(request: FraudValueListRequest): Promise<void> {
await this._client.post(`/fraud/v1/value-lists`, request);
}

async removeValueFromValueList(listName: string, value: string): Promise<void> {
await this._client.delete(`/fraud/v1/value-lists/${listName}/values/${value}`);
async removeValueFromValueList(listName: string, valueId: string): Promise<void> {
await this._client.delete(`/fraud/v1/value-lists/${listName}/values/${valueId}`);
}
}
3 changes: 2 additions & 1 deletion src/model/ApmType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ enum ApmType {
CashOnDelivery = 'CASH_ON_DELIVERY',
Maslak = 'MASLAK',
ALFABANK = 'ALFABANK',
TomFinance = 'TOM_FINANCE'
TomFinance = 'TOM_FINANCE',
Haso = 'HASO'
}

export default ApmType;
4 changes: 2 additions & 2 deletions src/model/BnplCartItemType.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
enum BnplCartItemType {
MobilePhoneOver5000Try = 'MOBILE_PHONE_OVER_5000_TRY',
MobilePhoneBelow5000Try = 'MOBILE_PHONE_BELOW_5000_TRY',
MobilePhonePriceAboveRegulationLimit = 'MOBILE_PHONE_PRICE_ABOVE_REGULATION_LIMIT',
MobilePhonePriceBelowRegulationLimit = 'MOBILE_PHONE_PRICE_BELOW_REGULATION_LIMIT',
Tablet = 'TABLET',
Computer = 'COMPUTER',
ConstructionMarket = 'CONSTRUCTION_MARKET',
Expand Down
7 changes: 6 additions & 1 deletion src/model/Currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ enum Currency {
AED = 'AED',
IQD = 'IQD',
AZN = 'AZN',
KZT = 'KZT'
KZT = 'KZT',
KWD = 'KWD',
SAR = 'SAR',
BHD = 'BHD',
RUB = 'RUB',
JPY = 'JPY'
}

export default Currency;
9 changes: 9 additions & 0 deletions src/model/FraudValueType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
enum FraudValueType {
Card = 'CARD',
Ip = 'IP',
PhoneNumber = 'PHONE_NUMBER',
Email = 'EMAIL',
Other = 'OTHER'
}

export default FraudValueType;
3 changes: 2 additions & 1 deletion src/model/PaymentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ enum PaymentProvider {
YkbWorldPay = 'YKB_WORLD_PAY',
ApplePay = 'APPLEPAY',
GooglePay = 'GOOGLEPAY',
Stripe = 'STRIPE'
Stripe = 'STRIPE',
Haso = 'HASO'
}

export default PaymentProvider;
5 changes: 4 additions & 1 deletion src/model/PosIntegrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ enum PosIntegrator {
ALGORITMA = 'ALGORITMA',
PAYCELL = 'PAYCELL',
TAMI = 'TAMI',
QNB_PAY = 'QNB_PAY'
QNB_PAY = 'QNB_PAY',
AKBANK_VPOS = 'AKBANK_VPOS',
TAP = 'TAP',
RUBIK = 'RUBIK'
}

export default PosIntegrator;
2 changes: 2 additions & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Currency from './Currency';
import FileStatus from './FileStatus';
import FraudAction from './FraudAction';
import FraudCheckStatus from './FraudCheckStatus';
import FraudValueType from './FraudValueType';
import LoyaltyType from './LoyaltyType';
import MemberType from './MemberType';
import MerchantType from './MerchantType';
Expand Down Expand Up @@ -62,6 +63,7 @@ export = {
FileStatus,
FraudAction,
FraudCheckStatus,
FraudValueType,
LoyaltyType,
MemberType,
MerchantType,
Expand Down
12 changes: 12 additions & 0 deletions src/request/FraudValueListRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import FraudValueType from '../model/FraudValueType';

type FraudValueListRequest = {
listName: string;
type: FraudValueType;
label?: string;
value?: string;
durationInSeconds?: number;
paymentId?: number;
};

export default FraudValueListRequest;
2 changes: 0 additions & 2 deletions src/response/dto/FraudPaymentData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ type FraudPaymentData = {
conversationId: string;
paidPrice: number;
currency: string;
cardFingerprintId: string;
cardFingerprintExpirationDate: Date;
buyerId: number;
clientIp: string;
};
Expand Down
2 changes: 2 additions & 0 deletions src/response/dto/FraudValue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
type FraudValue = {
id: string;
label: string;
value: string;
expireInSeconds: number;
};
Expand Down

0 comments on commit 30c978b

Please sign in to comment.