@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
49 lines (38 loc) • 1.18 kB
text/typescript
import {
IOrderPricingAdapter,
OrderPricingDirector,
OrderPricingAdapter,
PaymentPricingSheet,
} from '@unchainedshop/core';
const OrderPayment: IOrderPricingAdapter = {
...OrderPricingAdapter,
key: 'shop.unchained.pricing.order-payment',
version: '1.0.0',
label: 'Add Payment Fees to Order',
orderIndex: 10,
isActivatedFor: () => {
return true;
},
actions: (params) => {
const pricingAdapter = OrderPricingAdapter.actions(params);
const { order, orderPayment } = params.context;
return {
...pricingAdapter,
calculate: async () => {
// just add tax + net price to order pricing
if (!orderPayment) return null;
const pricing = PaymentPricingSheet({
calculation: orderPayment.calculation,
currency: order.currency,
});
const tax = pricing.taxSum();
const paymentFees = pricing.gross();
pricingAdapter
.resultSheet()
.addPayment({ amount: paymentFees, taxAmount: tax, meta: { adapter: OrderPayment.key } });
return pricingAdapter.calculate();
},
};
},
};
OrderPricingDirector.registerAdapter(OrderPayment);