UNPKG

@unchainedshop/plugins

Version:

Because of a Typescript issue with upstream "postfinancecheckout", the Postfinance plugin has been disabled from transpilation, import the source ts files from src and enable node_module tsc or copy over the src/payment/postfinance-checkout to your projec

35 lines (32 loc) 921 B
import splitProperties from './splitProperties.js'; import { StatusResponseSuccess } from './api/types.js'; import { sha256 } from '@unchainedshop/utils'; export default async function parseRegistrationData(transaction: StatusResponseSuccess) { const parsed = Object.entries(transaction).reduce((acc, [objectKey, payload]) => { const { token, info } = splitProperties({ objectKey, payload }); if (token) { return { token, info, objectKey, }; } return acc; }, {}) as { token?: Record<string, unknown>; info?: Record<string, unknown>; objectKey?: string; }; if (parsed.objectKey) { const _id = await sha256(parsed.token); return { ...parsed, _id, paymentMethod: transaction.paymentMethod, currency: transaction.currency, language: transaction.language, type: transaction.type, }; } return null; }