Skip to content

Commit 67136c7

Browse files
committed
Fix notification signature generation
1 parent 2948376 commit 67136c7

Some content is hidden

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

44 files changed

+296
-121
lines changed

lib/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
export { DbCalculation } from "./models/directbilling/service/db.calculation";
2-
export { DbProvider } from "./models/directbilling/service/db.provider";
2+
export { DbProvider, DbProviderID } from "./models/directbilling/db.provider";
33
export { DbService, DbServiceNotify } from "./models/directbilling/service/db.service";
44
export { PartialDbService } from "./models/directbilling/service/partial.db.service";
55
export { DbGenerationResponse } from "./models/directbilling/transaction/db.generation.response";
66
export { DbTransactionRequest } from "./models/directbilling/transaction/db.transaction.request";
77
export { DbTransactionStatus } from "./models/directbilling/transaction/db.transaction.status";
88
export { DbTransaction } from "./models/directbilling/transaction/db.transaction";
99
export { PartialDbTransaction } from "./models/directbilling/transaction/partial.db.transaction";
10+
export { DBServiceStatus } from "./models/directbilling/service/db.service.status";
1011
export { PaginatedResponse } from "./models/response/paginated.response";
1112
export { AmountType } from "./models/amount.type";
12-
export { ServiceStatus } from "./models/service.status";
1313
export { SmsNumber } from "./models/sms/service/sms.number";
1414
export { SmsService } from "./models/sms/service/sms.service";
1515
export { SmsServiceType } from "./models/sms/service/sms.service.type";
1616
export { SmsTransaction } from "./models/sms/transaction/sms.transaction";
1717
export { VerificationResponse } from "./models/sms/verification.response";
18+
export { SMSServiceStatus } from "./models/sms/service/sms.service.status";
1819
export { DirectBilling } from "./payments/directbilling";
1920
export { Sms } from "./payments/sms";
2021
export { SmsXml } from "./payments/sms.xml";

lib/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.SmsXml = exports.Sms = exports.DirectBilling = exports.SmsServiceType = exports.ServiceStatus = exports.AmountType = exports.DbTransactionStatus = exports.DbProvider = void 0;
4-
var db_provider_1 = require("./models/directbilling/service/db.provider");
3+
exports.SmsXml = exports.Sms = exports.DirectBilling = exports.SMSServiceStatus = exports.SmsServiceType = exports.AmountType = exports.DBServiceStatus = exports.DbTransactionStatus = exports.DbProviderID = exports.DbProvider = void 0;
4+
var db_provider_1 = require("./models/directbilling/db.provider");
55
Object.defineProperty(exports, "DbProvider", { enumerable: true, get: function () { return db_provider_1.DbProvider; } });
6+
Object.defineProperty(exports, "DbProviderID", { enumerable: true, get: function () { return db_provider_1.DbProviderID; } });
67
var db_transaction_status_1 = require("./models/directbilling/transaction/db.transaction.status");
78
Object.defineProperty(exports, "DbTransactionStatus", { enumerable: true, get: function () { return db_transaction_status_1.DbTransactionStatus; } });
9+
var db_service_status_1 = require("./models/directbilling/service/db.service.status");
10+
Object.defineProperty(exports, "DBServiceStatus", { enumerable: true, get: function () { return db_service_status_1.DBServiceStatus; } });
811
var amount_type_1 = require("./models/amount.type");
912
Object.defineProperty(exports, "AmountType", { enumerable: true, get: function () { return amount_type_1.AmountType; } });
10-
var service_status_1 = require("./models/service.status");
11-
Object.defineProperty(exports, "ServiceStatus", { enumerable: true, get: function () { return service_status_1.ServiceStatus; } });
1213
var sms_service_type_1 = require("./models/sms/service/sms.service.type");
1314
Object.defineProperty(exports, "SmsServiceType", { enumerable: true, get: function () { return sms_service_type_1.SmsServiceType; } });
15+
var sms_service_status_1 = require("./models/sms/service/sms.service.status");
16+
Object.defineProperty(exports, "SMSServiceStatus", { enumerable: true, get: function () { return sms_service_status_1.SMSServiceStatus; } });
1417
// Payments
1518
var directbilling_1 = require("./payments/directbilling");
1619
Object.defineProperty(exports, "DirectBilling", { enumerable: true, get: function () { return directbilling_1.DirectBilling; } });
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export declare enum DbProvider {
2+
PLAY = "play",
3+
PLUS = "plus",
4+
ORANGE = "orange",
5+
T_MOBILE = "t-mobile"
6+
}
7+
export declare enum DbProviderID {
8+
ORANGE = 1,
9+
PLUS = 2,
10+
PLAY = 3,
11+
T_MOBILE = 4
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.DbProviderID = exports.DbProvider = void 0;
4+
var DbProvider;
5+
(function (DbProvider) {
6+
DbProvider["PLAY"] = "play";
7+
DbProvider["PLUS"] = "plus";
8+
DbProvider["ORANGE"] = "orange";
9+
DbProvider["T_MOBILE"] = "t-mobile";
10+
})(DbProvider = exports.DbProvider || (exports.DbProvider = {}));
11+
var DbProviderID;
12+
(function (DbProviderID) {
13+
DbProviderID[DbProviderID["ORANGE"] = 1] = "ORANGE";
14+
DbProviderID[DbProviderID["PLUS"] = 2] = "PLUS";
15+
DbProviderID[DbProviderID["PLAY"] = 3] = "PLAY";
16+
DbProviderID[DbProviderID["T_MOBILE"] = 4] = "T_MOBILE";
17+
})(DbProviderID = exports.DbProviderID || (exports.DbProviderID = {}));

lib/models/directbilling/service/db.calculation.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DbProvider } from './db.provider';
1+
import { DbProvider } from '../db.provider';
22
export interface DbCalculation {
33
[DbProvider.PLAY]: DbCalculationAmount;
44
[DbProvider.PLUS]: DbCalculationAmount;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
const db_provider_1 = require("./db.provider");
3+
const db_provider_1 = require("../db.provider");

lib/models/directbilling/service/db.service.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ServiceStatus } from '../../service.status';
2-
import { DbProvider } from './db.provider';
1+
import { DBServiceStatus } from '../service/db.service.status';
2+
import { DbProvider } from '../db.provider';
33
export interface DbService {
44
id: string;
55
name: string;
66
suffix: string;
7-
status: ServiceStatus;
7+
status: DBServiceStatus;
88
api?: DbServiceNotify;
99
providers: DbServiceProviders;
1010
commissions: DbServiceProvidersCommission;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
const db_provider_1 = require("./db.provider");
3+
const db_provider_1 = require("../db.provider");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export declare enum DBServiceStatus {
2+
SERVICE_NEW = "service_db_new",
3+
SERVICE_ACTIVE = "service_db_active",
4+
SERVICE_REJECTED = "service_db_rejected",
5+
SERVICE_ONGOING_REGISTRATION = "service_db_ongoing_registration"
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.DBServiceStatus = void 0;
4+
var DBServiceStatus;
5+
(function (DBServiceStatus) {
6+
DBServiceStatus["SERVICE_NEW"] = "service_db_new";
7+
DBServiceStatus["SERVICE_ACTIVE"] = "service_db_active";
8+
DBServiceStatus["SERVICE_REJECTED"] = "service_db_rejected";
9+
DBServiceStatus["SERVICE_ONGOING_REGISTRATION"] = "service_db_ongoing_registration";
10+
})(DBServiceStatus = exports.DBServiceStatus || (exports.DBServiceStatus = {}));
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { ServiceStatus } from '../../service.status';
1+
import { DBServiceStatus } from './db.service.status';
22
export interface PartialDbService {
33
id: string;
44
name: string;
55
suffix: string;
6-
status: ServiceStatus;
6+
status: DBServiceStatus;
77
created_at: Date;
88
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { DbServiceNotify } from '../service/db.service';
2+
import { DbTransactionStatus } from '../transaction/db.transaction.status';
3+
import { DbProviderID } from '../db.provider';
4+
export interface DbNotificationRequest {
5+
id: string;
6+
service_id: number;
7+
status: DbTransactionStatus;
8+
values?: {
9+
net?: number;
10+
gross?: number;
11+
partner?: number;
12+
};
13+
returns?: DbServiceNotify;
14+
control?: string;
15+
number_from?: string;
16+
provider: DbProviderID;
17+
signature?: string;
18+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });

lib/models/directbilling/transaction/db.transaction.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DbTransactionStatus } from './db.transaction.status';
2-
import { DbProvider } from '../service/db.provider';
2+
import { DbProvider } from '../db.provider';
33
export interface DbTransaction {
44
id: string;
55
status: DbTransactionStatus;
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export declare enum DbTransactionStatus {
2-
SERVICE_DB_NEW = "service_db_new",
3-
SERVICE_DB_ACTIVE = "service_db_active",
4-
SERVICE_DB_REJECTED = "service_db_rejected",
5-
SERVICE_DB_ONGOING_REGISTRATION = "service_db_ongoing_registration"
2+
TRANSACTION_DB_NEW = "transaction_db_new",
3+
TRANSACTION_DB_CONFIRMED = "transaction_db_confirmed",
4+
TRANSACTION_DB_REJECTED = "transaction_db_rejected",
5+
TRANSACTION_DB_CANCELED = "transaction_db_canceled",
6+
TRANSACTION_DB_PAYED = "transaction_db_payed",
7+
TRANSACTION_DB_GENERATE_ERROR = "transaction_db_generate_error"
68
}

lib/models/directbilling/transaction/db.transaction.status.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
exports.DbTransactionStatus = void 0;
44
var DbTransactionStatus;
55
(function (DbTransactionStatus) {
6-
DbTransactionStatus["SERVICE_DB_NEW"] = "service_db_new";
7-
DbTransactionStatus["SERVICE_DB_ACTIVE"] = "service_db_active";
8-
DbTransactionStatus["SERVICE_DB_REJECTED"] = "service_db_rejected";
9-
DbTransactionStatus["SERVICE_DB_ONGOING_REGISTRATION"] = "service_db_ongoing_registration";
6+
DbTransactionStatus["TRANSACTION_DB_NEW"] = "transaction_db_new";
7+
DbTransactionStatus["TRANSACTION_DB_CONFIRMED"] = "transaction_db_confirmed";
8+
DbTransactionStatus["TRANSACTION_DB_REJECTED"] = "transaction_db_rejected";
9+
DbTransactionStatus["TRANSACTION_DB_CANCELED"] = "transaction_db_canceled";
10+
DbTransactionStatus["TRANSACTION_DB_PAYED"] = "transaction_db_payed";
11+
DbTransactionStatus["TRANSACTION_DB_GENERATE_ERROR"] = "transaction_db_generate_error";
1012
})(DbTransactionStatus = exports.DbTransactionStatus || (exports.DbTransactionStatus = {}));

lib/models/directbilling/transaction/partial.db.transaction.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DbProvider } from '../service/db.provider';
1+
import { DbProvider } from '../db.provider';
22
import { DbTransactionStatus } from './db.transaction.status';
33
export interface PartialDbTransaction {
44
id: string;

lib/models/sms/service/sms.service.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { SmsServiceType } from './sms.service.type';
2-
import { ServiceStatus } from '../../service.status';
2+
import { SMSServiceStatus } from './sms.service.status';
33
export interface SmsService {
44
id: number;
55
type: SmsServiceType;
6-
status: ServiceStatus;
6+
status: SMSServiceStatus;
77
name: string;
88
prefix: string;
99
suffix: string;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export declare enum SMSServiceStatus {
2+
SERVICE_NEW = "service_new",
3+
SERVICE_ACTIVE = "service_active",
4+
SERVICE_BLOCKED = "service_blocked",
5+
SERVICE_DELETED = "service_deleted",
6+
SERVICE_SECOND_VERIFY = "service_second_verify",
7+
SERVICE_REJECTED = "service_rejected",
8+
SERVICE_VERIFY = "service_verify",
9+
SERVICE_ONGOING_REGISTRATION = "service_ongoing_registration"
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.SMSServiceStatus = void 0;
4+
var SMSServiceStatus;
5+
(function (SMSServiceStatus) {
6+
SMSServiceStatus["SERVICE_NEW"] = "service_new";
7+
SMSServiceStatus["SERVICE_ACTIVE"] = "service_active";
8+
SMSServiceStatus["SERVICE_BLOCKED"] = "service_blocked";
9+
SMSServiceStatus["SERVICE_DELETED"] = "service_deleted";
10+
SMSServiceStatus["SERVICE_SECOND_VERIFY"] = "service_second_verify";
11+
SMSServiceStatus["SERVICE_REJECTED"] = "service_rejected";
12+
SMSServiceStatus["SERVICE_VERIFY"] = "service_verify";
13+
SMSServiceStatus["SERVICE_ONGOING_REGISTRATION"] = "service_ongoing_registration";
14+
})(SMSServiceStatus = exports.SMSServiceStatus || (exports.SMSServiceStatus = {}));

lib/payments/directbilling.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { PartialDbTransaction } from '../models/directbilling/transaction/partia
66
import { DbTransaction } from '../models/directbilling/transaction/db.transaction';
77
import { DbGenerationResponse } from '../models/directbilling/transaction/db.generation.response';
88
import { DbTransactionRequest } from '../models/directbilling/transaction/db.transaction.request';
9+
import { DbNotificationRequest } from '../models/directbilling/transaction/db.notifications.request';
910
export declare class DirectBilling {
1011
private readonly key;
1112
private readonly password;
@@ -21,4 +22,5 @@ export declare class DirectBilling {
2122
createTransaction(serviceId: number, key: string, request: DbTransactionRequest): Promise<DbGenerationResponse | undefined>;
2223
checkNotification(key: string, body: any): DbTransaction | undefined;
2324
generateSignature(key: string, request: DbTransactionRequest): string;
25+
generateSignatureNotification(key: string, request: DbNotificationRequest): string;
2426
}

lib/payments/directbilling.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DirectBilling {
2525
});
2626
}
2727
/*
28-
https://docs-new.simpay.pl/typescript/?typescript#directbilling-pobieranie-listy-uslug
28+
https://docs.simpay.pl/typescript/?typescript#directbilling-pobieranie-listy-uslug
2929
*/
3030
getServices() {
3131
return __awaiter(this, void 0, void 0, function* () {
@@ -59,7 +59,7 @@ class DirectBilling {
5959
});
6060
}
6161
/*
62-
https://docs-new.simpay.pl/typescript/?typescript#directbilling-pobieranie-informacji-o-usludze
62+
https://docs.simpay.pl/typescript/?typescript#directbilling-pobieranie-informacji-o-usludze
6363
*/
6464
getService(id) {
6565
return __awaiter(this, void 0, void 0, function* () {
@@ -74,15 +74,15 @@ class DirectBilling {
7474
});
7575
}
7676
/*
77-
https://docs-new.simpay.pl/typescript/?typescript#directbilling-kalkulacja-prowizji
77+
https://docs.simpay.pl/typescript/?typescript#directbilling-kalkulacja-prowizji
7878
*/
7979
calculateCommission(serviceId, amount) {
8080
return __awaiter(this, void 0, void 0, function* () {
8181
return (yield this.client.get(`/${serviceId}/calculate?amount=${amount}`)).data.data;
8282
});
8383
}
8484
/*
85-
https://docs-new.simpay.pl/typescript/?typescript#directbilling-pobieranie-listy-transakcji
85+
https://docs.simpay.pl/typescript/?typescript#directbilling-pobieranie-listy-transakcji
8686
*/
8787
getTransactions(serviceId) {
8888
return __awaiter(this, void 0, void 0, function* () {
@@ -118,7 +118,7 @@ class DirectBilling {
118118
});
119119
}
120120
/*
121-
https://docs-new.simpay.pl/typescript/?typescript#directbilling-pobieranie-informacji-o-transakcji
121+
https://docs.simpay.pl/typescript/?typescript#directbilling-pobieranie-informacji-o-transakcji
122122
*/
123123
getTransaction(serviceId, transactionId) {
124124
return __awaiter(this, void 0, void 0, function* () {
@@ -129,7 +129,7 @@ class DirectBilling {
129129
});
130130
}
131131
/*
132-
https://docs-new.simpay.pl/typescript/?typescript#directbilling-generowanie-transakcji
132+
https://docs.simpay.pl/typescript/?typescript#directbilling-generowanie-transakcji
133133
*/
134134
createTransaction(serviceId, key, request) {
135135
return __awaiter(this, void 0, void 0, function* () {
@@ -138,16 +138,16 @@ class DirectBilling {
138138
});
139139
}
140140
/*
141-
https://docs-new.simpay.pl/shell/?shell#directbilling-generowanie-transakcji
141+
https://docs.simpay.pl/shell/?shell#directbilling-generowanie-transakcji
142142
*/
143143
checkNotification(key, body) {
144-
const signature = this.generateSignature(key, body);
144+
const signature = this.generateSignatureNotification(key, body);
145145
if (body.signature !== signature)
146146
return undefined;
147147
return body;
148148
}
149149
/*
150-
https://docs-new.simpay.pl/shell/?shell#directbilling-generowanie-transakcji
150+
https://docs.simpay.pl/shell/?shell#directbilling-generowanie-transakcji
151151
*/
152152
generateSignature(key, request) {
153153
var _a, _b;
@@ -163,5 +163,23 @@ class DirectBilling {
163163
].filter(e => e !== undefined && e !== null);
164164
return hashing_1.Hashing.sha256(elements.join('|'));
165165
}
166+
generateSignatureNotification(key, request) {
167+
var _a, _b, _c, _d, _e;
168+
const elements = [
169+
request.id,
170+
request.service_id,
171+
request.status,
172+
(_a = request.values) === null || _a === void 0 ? void 0 : _a.net,
173+
(_b = request.values) === null || _b === void 0 ? void 0 : _b.gross,
174+
(_c = request.values) === null || _c === void 0 ? void 0 : _c.partner,
175+
(_d = request.returns) === null || _d === void 0 ? void 0 : _d.success,
176+
(_e = request.returns) === null || _e === void 0 ? void 0 : _e.failure,
177+
request.control,
178+
request.number_from,
179+
request.provider,
180+
key
181+
].filter(e => e !== undefined && e !== null);
182+
return hashing_1.Hashing.sha256(elements.join('|'));
183+
}
166184
}
167185
exports.DirectBilling = DirectBilling;

0 commit comments

Comments
 (0)