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

34 lines 1.03 kB
// https://api-reference.datatrans.ch/#operation/init import getPaths from '../getPaths.js'; const defaultRedirect = getPaths(); export default async function init({ option, redirect: userRedirect, ...payload }) { const redirect = { ...defaultRedirect, ...(userRedirect || {}), }; delete redirect?.postUrl; delete redirect?.returnUrl; const reqBody = { ...payload, autoSettle: false, option: { createAlias: true, returnCustomerCountry: true, ...(option || {}), // allow to overturn the options above authenticationOnly: false, }, redirect, webhook: { url: defaultRedirect.postUrl, }, }; const { fetchDatatrans } = this; const result = await fetchDatatrans('/v1/transactions', reqBody); const json = await result.json(); const location = result.headers?.get('location'); return { location, ...json, }; } //# sourceMappingURL=init.js.map