@luchalupa/csobcz_payment_gateway
Advanced tools
Comparing version 0.6.15 to 0.6.17
@@ -17,2 +17,5 @@ import { ApplePayInitPayload, Currency, GooglePayInitPayload, InitPayload, InputPayload, Language, OneClickInitPayload, PaymentMethod, PaymentOperation, PaymentResult, PaymentStatus, PaymentStatusResult, ResultCode, ReturnMethod } from './types/Payment'; | ||
getRedirectUrl(id: string): string; | ||
processAppPayment(type: 'googlepay' | 'applepay', payId: string, fingerprint: { | ||
[key: string]: string; | ||
}): Promise<any>; | ||
status(id: string): Promise<PaymentStatusResult>; | ||
@@ -19,0 +22,0 @@ reverse(id: string): Promise<PaymentResult>; |
@@ -77,11 +77,14 @@ "use strict"; | ||
var _a, _b, _c; | ||
console.log('--------------------------------------'); | ||
console.log(new Date()); | ||
console.log('--------------------------------------'); | ||
console.log(payload); | ||
console.log('--------------------------------------'); | ||
console.log(`${this.config.gateUrl}${initUrlPath}`); | ||
console.log('--------------------------------------'); | ||
// console.log('--------------------------------------') | ||
// console.log(new Date()) | ||
// console.log('--------------------------------------') | ||
// console.log(payload) | ||
// console.log('--------------------------------------') | ||
// console.log(`${this.config.gateUrl}${initUrlPath}`) | ||
// console.log('--------------------------------------') | ||
try { | ||
const result = await superagent.post(`${this.config.gateUrl}${initUrlPath}`).send(payload); | ||
// console.log('--------------------------------------') | ||
// console.log("RESULT", result.body) | ||
// console.log('--------------------------------------') | ||
if (this.verify(this.createResultMessage(result.body), result.body.signature)) { | ||
@@ -108,4 +111,12 @@ if (result.body.resultCode.toString() === '0') { | ||
payload['dttm'] = this.createDttm(); | ||
// console.log('--------------------------------------') | ||
// console.log('--------------------------------------') | ||
// console.log('PAYLOAD', payload) | ||
// console.log('--------------------------------------') | ||
// console.log('PAYLOAD MESSAGE', this.createPayloadMessage(payload)) | ||
// console.log('--------------------------------------') | ||
// console.log('--------------------------------------') | ||
// console.log('--------------------------------------') | ||
payload['signature'] = this.sign(this.createPayloadMessage(payload)); | ||
return this.commonInit(input, '/payment/init'); | ||
return this.commonInit(payload, '/payment/init'); | ||
} | ||
@@ -116,4 +127,14 @@ async googlePayInit(input) { | ||
payload['dttm'] = this.createDttm(); | ||
payload['payload'] = input.payload; | ||
// console.log('--------------------------------------') | ||
// console.log('--------------------------------------') | ||
// console.log('PAYLOAD', payload) | ||
// console.log('--------------------------------------') | ||
// console.log('PAYLOAD MESSAGE', this.createPayloadMessage(payload)) | ||
// console.log('--------------------------------------') | ||
// console.log('--------------------------------------') | ||
// console.log('--------------------------------------') | ||
payload['signature'] = this.sign(this.createPayloadMessage(payload)); | ||
payload['payload'] = input.payload; | ||
// console.log('SIGNATURE', payload['signature']) | ||
// console.log('--------------------------------------') | ||
return this.commonInit(input, '/googlepay/init'); | ||
@@ -125,4 +146,4 @@ } | ||
payload['dttm'] = this.createDttm(); | ||
payload['payload'] = input.payload; | ||
payload['signature'] = this.sign(this.createPayloadMessage(payload)); | ||
payload['payload'] = input.payload; | ||
return this.commonInit(input, '/applepay/init'); | ||
@@ -146,2 +167,32 @@ } | ||
} | ||
async processAppPayment(type, payId, fingerprint) { | ||
var _a, _b, _c; | ||
const dttm = this.createDttm(); | ||
const payload = { | ||
merchantId: this.config.merchantId, | ||
payId, | ||
dttm, | ||
fingerprint, | ||
signature: this.sign(`${this.config.merchantId}|${payId}|${dttm}|${JSON.stringify(fingerprint)}`), | ||
}; | ||
const url = `${this.config.gateUrl}/${type}/process`; | ||
try { | ||
const result = await superagent.post(`${this.config.gateUrl}${url}`).send(payload); | ||
if (this.verify(this.createResultMessage(result.body), result.body.signature)) { | ||
if (result.body.resultCode.toString() === '0') { | ||
return result.body; | ||
} | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error({ result }, 'Process payment operation failed'); | ||
throw new GatewayError_1.default('Process payment operation failed', result.body); | ||
} | ||
else { | ||
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.error({ result }, 'Verification failed'); | ||
throw new VerificationError_1.default('Verification failed'); | ||
} | ||
} | ||
catch (err) { | ||
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.error({ err }, 'Uknown error'); | ||
throw err; | ||
} | ||
} | ||
async status(id) { | ||
@@ -255,2 +306,3 @@ var _a; | ||
'dttm', | ||
'clientIp', | ||
'payOperation', | ||
@@ -261,2 +313,3 @@ 'payMethod', | ||
'closePayment', | ||
'payload', | ||
'returnUrl', | ||
@@ -303,3 +356,4 @@ 'returnMethod', | ||
} | ||
return keys.map((key) => data[key]).filter((item) => typeof item !== 'undefined'); | ||
const filtered = keys.map((key) => data[key]).filter((item) => typeof item !== 'undefined'); | ||
return filtered; | ||
} | ||
@@ -306,0 +360,0 @@ createMessageString(data, keys = []) { |
@@ -79,2 +79,5 @@ import { Customer } from './Customer'; | ||
authCode?: string; | ||
actions?: { | ||
[key: string]: string; | ||
}; | ||
} | ||
@@ -81,0 +84,0 @@ export interface PaymentStatusResult { |
{ | ||
"name": "@luchalupa/csobcz_payment_gateway", | ||
"version": "0.6.15", | ||
"version": "0.6.17", | ||
"description": "CSOB CZ payment gateway module", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
50258
775