Skip to content

Commit

Permalink
Fix used_at casting to date in sms code verification
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGL committed Nov 8, 2022
1 parent 169f19a commit daaab55
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/payments/directbilling.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export declare class DirectBilling {
getTransactionsPaginated(serviceId: number, page?: number, pageSize?: number): Promise<PaginatedResponse<PartialDbTransaction>>;
getTransaction(serviceId: number, transactionId: string): Promise<DbTransaction | undefined>;
createTransaction(serviceId: number, key: string, request: DbTransactionRequest): Promise<DbGenerationResponse | undefined>;
checkNotification(key: string, body: any): DbTransaction | undefined;
checkNotification(key: string, body: any): DbNotificationRequest | undefined;
generateSignature(key: string, request: DbTransactionRequest): string;
generateSignatureNotification(key: string, request: DbNotificationRequest): string;
}
4 changes: 3 additions & 1 deletion lib/payments/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ class Sms {
verifySmsCode(serviceId, code, number) {
return __awaiter(this, void 0, void 0, function* () {
const response = (yield this.client.post(`/${serviceId}`, { code, number })).data.data;
response.used_at = new Date(response.used_at.replace(' ', 'T'));
if (response.used_at) {
response.used_at = new Date(response.used_at.replace(' ', 'T'));
}
return response;
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simpay-typescript-api",
"author": "Rafał Więcek",
"version": "2.2.0",
"version": "2.2.1",
"description": "SimPay.pl API",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/payments/sms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export class Sms {
async verifySmsCode(serviceId: number, code: string, number?: number): Promise<VerificationResponse | undefined> {
const response = (await this.client.post(`/${serviceId}`, { code, number })).data.data;

response.used_at = new Date(response.used_at.replace(' ', 'T'));
if( response.used_at ) {
response.used_at = new Date(response.used_at.replace(' ', 'T'));
}

return response;
}
Expand Down

0 comments on commit daaab55

Please sign in to comment.