Skip to content

Commit 9637b63

Browse files
authored
Merge branch 'master' into add-loyalty-to-masterpass-v2
2 parents e704718 + 5fb4bfb commit 9637b63

69 files changed

Lines changed: 865 additions & 20 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@craftgate/craftgate",
3-
"version": "1.0.64",
3+
"version": "1.0.66",
44
"description": "Craftgate API JavaScript Client",
55
"main": "dist/index.js",
66
"scripts": {
@@ -38,6 +38,6 @@
3838
"typescript": "4.4.4"
3939
},
4040
"dependencies": {
41-
"axios": "0.30.2"
41+
"axios": "0.31.0"
4242
}
43-
}
43+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const Craftgate = require('../../dist');
2+
const fs = require('fs');
3+
const craftgate = new Craftgate.Client({
4+
apiKey: 'api-key',
5+
secretKey: 'secret-key',
6+
baseUrl: 'https://sandbox-api.craftgate.io'
7+
});
8+
9+
function createDate(days, hours, minutes, seconds) {
10+
let date = new Date();
11+
date.setDate(date.getDate() + days);
12+
date.setHours(hours);
13+
date.setMinutes(minutes);
14+
date.setSeconds(seconds);
15+
return date;
16+
}
17+
18+
craftgate.fileReporting().createReport({
19+
startDate: createDate(-1, 0, 0, 0),
20+
endDate: createDate(-1, 23, 59, 59),
21+
reportType: Craftgate.Model.ReportType.TRANSACTION,
22+
reportPeriod: Craftgate.Model.ReportPeriod.INSTANT
23+
})
24+
.then(result => {
25+
console.info('Create report demand report', result);
26+
})
27+
.catch(err => console.error('Failed create report demand report', err));
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const Craftgate = require('../../dist');
2+
const fs = require('fs');
3+
const craftgate = new Craftgate.Client({
4+
apiKey: 'api-key',
5+
secretKey: 'secret-key',
6+
baseUrl: 'https://sandbox-api.craftgate.io'
7+
});
8+
9+
craftgate
10+
.fileReporting()
11+
.retrieveReport(
12+
{
13+
fileType: Craftgate.Model.ReportFileType.CSV
14+
},
15+
49
16+
)
17+
.then(result => {
18+
console.info('Retrieve report', result);
19+
fs.writeFileSync('/tmp/report.csv', Buffer.from(result));
20+
})
21+
.catch(err => console.error('Failed to retrieve report', err));

samples/fraud/AddCardFingerprintToFraudValueList.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ const craftgate = new Craftgate.Client({
99

1010
//request
1111
const request = {
12-
listName: 'cardList',
13-
type: Craftgate.Model.FraudValueType.Card,
14-
label: "John Doe's Card",
15-
paymentId: 11675
12+
label: "label",
13+
durationInSeconds: 60,
14+
operationId: "operationId",
15+
operation: Craftgate.Model.FraudOperation.Payment
1616
};
1717

18-
craftgate.fraud().addValueToValueList(request)
18+
craftgate.fraud().addCardFingerprint(request, "listName")
1919
.then(() => console.info('Value added to fraud value list'))
2020
.catch(err => console.error('Failed to add value to fraud value list', err));

samples/fraud/SearchFraudRules.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const Craftgate = require('../../dist');
2+
3+
const craftgate = new Craftgate.Client({
4+
apiKey: 'api-key',
5+
secretKey: 'secret-key',
6+
baseUrl: 'https://sandbox-api.craftgate.io'
7+
});
8+
9+
const request = {
10+
page: 0,
11+
size: 10,
12+
};
13+
14+
craftgate.fraud().searchFraudRules(request)
15+
.then(result => console.info('Retrieved fraud rule search results', result))
16+
.catch(err => console.error('Failed to search fraud rule', err));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const Craftgate = require('../../dist');
2+
const ApmType = require('../../src/model/ApmType');
3+
4+
const craftgate = new Craftgate.Client({
5+
apiKey: 'api-key',
6+
secretKey: 'secret-key',
7+
baseUrl: 'https://sandbox-api.craftgate.io'
8+
});
9+
10+
craftgate.payment().bnplLimitInquiry({
11+
apmType: ApmType.Zip,
12+
additionalParams: {
13+
buyerPhoneNumber: '+905320000000',
14+
otpCode: '123456'
15+
}
16+
})
17+
.then(results => console.info('Complete BNPL limit inquiry response ', results))
18+
.catch(err => console.error('Failed to complete BNPL limit inquiry', err));
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const Craftgate = require('../../dist');
2+
const ApmType = require('../../src/model/ApmType');
3+
4+
const craftgate = new Craftgate.Client({
5+
apiKey: 'api-key',
6+
secretKey: 'secret-key',
7+
baseUrl: 'https://sandbox-api.craftgate.io'
8+
});
9+
10+
craftgate.payment().bnplLimitInquiryInit({
11+
apmType: ApmType.Zip,
12+
additionalParams: {
13+
buyerPhoneNumber: '5320000000',
14+
buyerIdentityNumber: '11111111110',
15+
buyerBirthdate: '1990-01-01'
16+
}
17+
})
18+
.then(results => console.info('Init BNPL limit inquiry response ', results))
19+
.catch(err => console.error('Failed to init BNPL limit inquiry', err));
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const Craftgate = require('../../dist');
2+
3+
const craftgate = new Craftgate.Client({
4+
apiKey: 'api-key',
5+
secretKey: 'secret-key',
6+
baseUrl: 'https://sandbox-api.craftgate.io'
7+
});
8+
9+
const request = {
10+
verificationPrice: 10,
11+
currency: Craftgate.Model.Currency.TRY,
12+
conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5',
13+
callbackUrl: 'https://www.your-website.com/craftgate-checkout-card-verify-callback',
14+
paymentAuthenticationType: Craftgate.Model.CardVerificationAuthType.NonThreeDs
15+
};
16+
17+
craftgate.payment().initCheckoutCardVerify(request)
18+
.then(result => console.info('Init checkout card verify successful', result))
19+
.catch(err => console.error('Init checkout card verify failed', err));
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const Craftgate = require('../../dist');
2+
3+
const craftgate = new Craftgate.Client({
4+
apiKey: 'api-key',
5+
secretKey: 'secret-key',
6+
baseUrl: 'https://sandbox-api.craftgate.io'
7+
});
8+
9+
const request = {
10+
price: 100.0,
11+
paidPrice: 100.0,
12+
callbackUrl: 'https://www.your-website.com/craftgate-checkout-callback',
13+
currency: Craftgate.Model.Currency.TRY,
14+
conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5',
15+
externalId: '123d1297-839e-4bd6-a13b-4be31a6e12b8',
16+
paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription,
17+
paymentPhase: Craftgate.Model.PaymentPhase.Auth,
18+
items: [
19+
{
20+
name: 'Item 1',
21+
price: 30.0,
22+
externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8'
23+
},
24+
{
25+
name: 'Item 2',
26+
price: 50.0,
27+
externalId: '789d1297-839e-4bd6-a13b-4be31a6e13f7'
28+
},
29+
{
30+
name: 'Item 3',
31+
price: 20.0,
32+
externalId: '3a1d1297-839e-4bd6-a13b-4be31a6e18e6'
33+
}
34+
]
35+
};
36+
37+
craftgate.payment().initMultiPayment(request)
38+
.then(payment => console.info('Init Multi payment', payment))
39+
.catch(err => console.error('Failed to init multi payment', err));
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const Craftgate = require('../../dist');
2+
3+
const craftgate = new Craftgate.Client({
4+
apiKey: 'api-key',
5+
secretKey: 'secret-key',
6+
baseUrl: 'https://sandbox-api.craftgate.io'
7+
});
8+
9+
const request = {
10+
paymentTransactionId: 1, // change it with a valid paymentTransactionId
11+
conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5',
12+
refundPrice: 20
13+
};
14+
15+
craftgate.payment().refundPaymentTransactionMarkAsRefunded(request)
16+
.then(results => console.info('Retrieve payment transaction mark as refunded response', results))
17+
.catch(err => console.error('Failed to retrieve payment transaction mark as refunded', err));

0 commit comments

Comments
 (0)