@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
25 lines • 1.21 kB
JavaScript
import { OrderPricingSheet } from '@unchainedshop/core';
import * as pf from 'postfinancecheckout';
const { PostFinanceCheckout } = pf;
export const transactionIsPaid = async (transaction, expectedCurrency, expectedAmount) => {
if (transaction.state === PostFinanceCheckout.model.TransactionState.FULFILL) {
return (transaction.completedAmount !== undefined &&
transaction.completedAmount.toFixed(2) === expectedAmount.toFixed(2) &&
transaction.currency === expectedCurrency);
}
if (transaction.state === PostFinanceCheckout.model.TransactionState.AUTHORIZED) {
return (transaction.authorizationAmount !== undefined &&
transaction.authorizationAmount.toFixed(2) === expectedAmount.toFixed(2) &&
transaction.currency === expectedCurrency);
}
return false;
};
export const orderIsPaid = async (order, transaction) => {
const pricing = OrderPricingSheet({
calculation: order.calculation,
currency: order.currency,
});
const totalAmount = pricing.total({ useNetPrice: false }).amount / 100;
return transactionIsPaid(transaction, order.currency, totalAmount);
};
//# sourceMappingURL=utils.js.map