UNPKG

@unchainedshop/plugins

Version:

Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters

33 lines (32 loc) 906 B
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 || {}), 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, }; }