@luchalupa/csobcz_payment_gateway
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -14,3 +14,3 @@ import { ApplePayInitPayload, Currency, GooglePayInitPayload, InitPayload, InputPayload, Language, OneClickInitPayload, PaymentMethod, PaymentOperation, PaymentResult, PaymentStatus, PaymentStatusResult, ResultCode, ReturnMethod } from './types/Payment'; | ||
applePayInit(input: ApplePayInitPayload): Promise<PaymentResult>; | ||
oneClickPayment(input: OneClickInitPayload): Promise<PaymentResult>; | ||
oneClickInit(input: OneClickInitPayload): Promise<PaymentResult>; | ||
createPaymentPayload(payload: InputPayload, oneClick: boolean): any; | ||
@@ -21,2 +21,3 @@ getRedirectUrl(id: string): string; | ||
}): Promise<any>; | ||
processOneClickPayment(payId: string): Promise<any>; | ||
status(id: string): Promise<PaymentStatusResult>; | ||
@@ -23,0 +24,0 @@ reverse(id: string): Promise<PaymentResult>; |
@@ -120,3 +120,3 @@ "use strict"; | ||
} | ||
async oneClickPayment(input) { | ||
async oneClickInit(input) { | ||
const payload = input; | ||
@@ -168,2 +168,29 @@ payload['merchantId'] = this.config.merchantId; | ||
} | ||
async processOneClickPayment(payId) { | ||
var _a, _b, _c; | ||
const objectToSign = { | ||
merchantId: this.config.merchantId, | ||
payId, | ||
dttm: this.createDttm(), | ||
}; | ||
const payload = Object.assign(Object.assign({}, objectToSign), { signature: this.sign((0, getObjectTextToSign_1.getObjectTextToSign)(objectToSign)) }); | ||
try { | ||
const result = await superagent.post(`${this.config.gateUrl}/oneclick/process/`).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 failed'); | ||
throw new GatewayError_1.default('Process 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) { | ||
@@ -170,0 +197,0 @@ var _a; |
@@ -141,5 +141,9 @@ import { Customer } from './Customer'; | ||
export type ApplePayInitPayload = OtherInitPayload; | ||
export interface OneClickInitPayload extends OtherInitPayload { | ||
export interface OneClickInitPayload extends CommonInitPayload { | ||
origPayId: string; | ||
clientIp?: string; | ||
clientInitiated?: boolean; | ||
sdkUsed?: boolean; | ||
language?: Language; | ||
} | ||
export {}; |
{ | ||
"name": "@luchalupa/csobcz_payment_gateway", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "CSOB CZ payment gateway module", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -50,9 +50,9 @@ # ČSOB CZ payment modules [![npm](https://img.shields.io/npm/v/@luchalupa/csobcz_payment_gateway.svg)](https://www.npmjs.com/package/@luchalupa/csobcz_payment_gateway) ![npm type definitions](https://img.shields.io/npm/types/@luchalupa/csobcz_payment_gateway) | ||
{ | ||
"merchantId": "...", | ||
"payOperation": "payment", | ||
"payMethod": "card", | ||
"currency": "CZK", | ||
"language": "CZ", | ||
"returnUrl": "...", | ||
"returnMethod": "POST" | ||
"merchantId": "...", | ||
"payOperation": "payment", | ||
"payMethod": "card", | ||
"currency": "CZK", | ||
"language": "CZ", | ||
"returnUrl": "...", | ||
"returnMethod": "POST" | ||
} | ||
@@ -65,4 +65,5 @@ ``` | ||
- `init(json payload)` - payment init | ||
- `googlePayInit(json payload)` - GooglePay payment init (not fully implemented) | ||
- `applePayInit(json payload)` - ApplePay payment init (not fully implemented) | ||
- `googlePayInit(json payload)` - GooglePay payment init | ||
- `applePayInit(json payload)` - ApplePay payment init | ||
- `oneClickInit(json payload)` - OneClick payment init | ||
- `reverse(string payId)` - reverse payment with given payId | ||
@@ -75,2 +76,5 @@ - `close(string payId)` - close payment with given payId | ||
payload is json returned from gateway callback. | ||
- `getRedirectUrl(string payId)` - returns url to gateway | ||
- `processAppPayment("applepay" | "googlepay" type, string payId, object fingerprint)` - processes google or apple payment | ||
- `processOneClickPayment(string payId)` - processes oneClick paymment | ||
@@ -86,12 +90,12 @@ --- | ||
{ | ||
"id": "order1", | ||
"description": "Moje order", | ||
"items": [ | ||
{ | ||
"name": "Nákup: vasobchod.cz", | ||
"quantity": 1, | ||
"amount": 200, | ||
"description": "Produkt 1" | ||
} | ||
] | ||
"id": "order1", | ||
"description": "Moje order", | ||
"items": [ | ||
{ | ||
"name": "Nákup: vasobchod.cz", | ||
"quantity": 1, | ||
"amount": 200, | ||
"description": "Produkt 1" | ||
} | ||
] | ||
} | ||
@@ -113,3 +117,3 @@ ``` | ||
{ | ||
"url": "https://api.platebnibrana.csob.cz/api/v1.7/payment/process/MERCHANDID/PAYID/20180504105513/KZr8D0z%2FVYFlX2fy0bs2NTafv...." | ||
"url": "https://api.platebnibrana.csob.cz/api/v1.7/payment/process/MERCHANDID/PAYID/20180504105513/KZr8D0z%2FVYFlX2fy0bs2NTafv...." | ||
} | ||
@@ -121,12 +125,12 @@ ``` | ||
```javascript | ||
const gateway = require("csobcz_payment_gateway"); | ||
const gateway = require('csobcz_payment_gateway') | ||
gateway | ||
.echo("GET") | ||
.then((result) => { | ||
logger.log(result); | ||
}) | ||
.catch((e) => { | ||
logger.error(e); | ||
}); | ||
.echo('GET') | ||
.then((result) => { | ||
logger.log(result) | ||
}) | ||
.catch((e) => { | ||
logger.error(e) | ||
}) | ||
``` |
Sorry, the diff of this file is not supported yet
54708
827
131