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

42 lines (35 loc) 1.12 kB
import { mongodb } from '@unchainedshop/mongodb'; import { SaferpayTransactionsCollection } from './db/SaferpayTransactionsCollection.js'; const configureSaferpayTransactionsModule = async ({ db }: { db: mongodb.Db }) => { const SaferpayTransactions = await SaferpayTransactionsCollection(db); return { findTransactionById: async (_id: mongodb.ObjectId) => { return SaferpayTransactions.findOne({ _id, }); }, createTransaction: async (orderPaymentId) => { const result = await SaferpayTransactions.insertOne({ created: new Date(), orderPaymentId, }); return result.insertedId; }, setToken: async (_id: mongodb.ObjectId, token: string) => { await SaferpayTransactions.updateOne( { _id }, { $set: { token, updated: new Date() }, }, ); }, }; }; export default { saferpayTransactions: { configure: configureSaferpayTransactionsModule, }, }; export type SaferpayTransactionsModule = { saferpayTransactions: Awaited<ReturnType<typeof configureSaferpayTransactionsModule>>; };