UNPKG

pcp-server-nodejs-sdk

Version:

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=PAYONE-GmbH_PCP-server-nodeJS-SDK&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=PAYONE-GmbH_PCP-server-nodeJS-SDK) [![Coverage](https://sonarcloud.io/api/pr

50 lines 2.87 kB
import { ApplePaymentTokenVersion } from '../models/ApplePaymentTokenVersion.js'; import { Network } from '../models/Network.js'; function networkFromString(value) { switch (value.toUpperCase()) { case Network.MASTERCARD: return Network.MASTERCARD; case Network.VISA: return Network.VISA; case Network.AMEX: return Network.AMEX; case Network.GIROCARD: return Network.GIROCARD; case Network.DISCOVER: return Network.DISCOVER; case Network.JCB: return Network.JCB; default: throw new TypeError(`'${value}' can't represent a Network`); } } function versionFromString(value) { switch (value) { case ApplePaymentTokenVersion.EC_V1: return ApplePaymentTokenVersion.EC_V1; default: throw new TypeError(`'${value}' can't represent an ApplePaymentTokenVersion`); } } export function transformApplePayPaymentToMobilePaymentMethodSpecificInput(payment) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; return { paymentProductId: 302, publicKeyHash: (_c = (_b = (_a = payment.token) === null || _a === void 0 ? void 0 : _a.paymentData) === null || _b === void 0 ? void 0 : _b.header) === null || _c === void 0 ? void 0 : _c.publicKeyHash, ephemeralKey: (_f = (_e = (_d = payment.token) === null || _d === void 0 ? void 0 : _d.paymentData) === null || _e === void 0 ? void 0 : _e.header) === null || _f === void 0 ? void 0 : _f.ephemeralPublicKey, paymentProduct302SpecificInput: { network: ((_h = (_g = payment.token) === null || _g === void 0 ? void 0 : _g.paymentMethod) === null || _h === void 0 ? void 0 : _h.network) ? networkFromString(payment.token.paymentMethod.network) : undefined, token: { version: ((_k = (_j = payment.token) === null || _j === void 0 ? void 0 : _j.paymentData) === null || _k === void 0 ? void 0 : _k.version) ? versionFromString(payment.token.paymentData.version) : undefined, signature: (_m = (_l = payment.token) === null || _l === void 0 ? void 0 : _l.paymentData) === null || _m === void 0 ? void 0 : _m.signature, header: { transactionId: (_q = (_p = (_o = payment.token) === null || _o === void 0 ? void 0 : _o.paymentData) === null || _p === void 0 ? void 0 : _p.header) === null || _q === void 0 ? void 0 : _q.transactionId, applicationData: (_t = (_s = (_r = payment.token) === null || _r === void 0 ? void 0 : _r.paymentData) === null || _s === void 0 ? void 0 : _s.header) === null || _t === void 0 ? void 0 : _t.applicationData, }, }, }, }; } //# sourceMappingURL=ApplePayTransformer.js.map