@unchainedshop/plugins 4.0.0-rc.5 → 4.0.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/payment/apple-iap/adapter.js +1 -1
- package/lib/payment/apple-iap/adapter.js.map +1 -1
- package/lib/payment/apple-iap/handler-express.js +1 -1
- package/lib/payment/apple-iap/handler-express.js.map +1 -1
- package/lib/payment/apple-iap/handler-fastify.js +1 -1
- package/lib/payment/apple-iap/handler-fastify.js.map +1 -1
- package/lib/payment/cryptopay/handle-webhook.js +1 -1
- package/lib/payment/cryptopay/handle-webhook.js.map +1 -1
- package/lib/payment/cryptopay/handler-express.js +1 -1
- package/lib/payment/cryptopay/handler-express.js.map +1 -1
- package/lib/payment/cryptopay/handler-fastify.d.ts.map +1 -1
- package/lib/payment/cryptopay/handler-fastify.js +1 -1
- package/lib/payment/cryptopay/handler-fastify.js.map +1 -1
- package/lib/payment/paypal-checkout.js +5 -7
- package/lib/payment/paypal-checkout.js.map +1 -1
- package/lib/payment/postfinance-checkout/api-client.d.ts +16 -0
- package/lib/payment/postfinance-checkout/api-client.d.ts.map +1 -0
- package/lib/payment/postfinance-checkout/api-client.js +75 -0
- package/lib/payment/postfinance-checkout/api-client.js.map +1 -0
- package/lib/payment/postfinance-checkout/api-types.d.ts +98 -0
- package/lib/payment/postfinance-checkout/api-types.d.ts.map +1 -0
- package/lib/payment/postfinance-checkout/api-types.js +51 -0
- package/lib/payment/postfinance-checkout/api-types.js.map +1 -0
- package/lib/payment/postfinance-checkout/api.d.ts +5 -5
- package/lib/payment/postfinance-checkout/api.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/api.js +38 -62
- package/lib/payment/postfinance-checkout/api.js.map +1 -1
- package/lib/payment/postfinance-checkout/handler-express.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/handler-express.js +5 -5
- package/lib/payment/postfinance-checkout/handler-express.js.map +1 -1
- package/lib/payment/postfinance-checkout/handler-fastify.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/handler-fastify.js +6 -6
- package/lib/payment/postfinance-checkout/handler-fastify.js.map +1 -1
- package/lib/payment/postfinance-checkout/index.d.ts +2 -1
- package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/index.js +25 -26
- package/lib/payment/postfinance-checkout/index.js.map +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts +3 -3
- package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/utils.js +3 -4
- package/lib/payment/postfinance-checkout/utils.js.map +1 -1
- package/package.json +5 -10
- package/src/payment/apple-iap/adapter.ts +1 -1
- package/src/payment/apple-iap/handler-express.ts +1 -1
- package/src/payment/apple-iap/handler-fastify.ts +1 -1
- package/src/payment/cryptopay/handle-webhook.ts +1 -1
- package/src/payment/cryptopay/handler-express.ts +1 -1
- package/src/payment/cryptopay/handler-fastify.ts +2 -2
- package/src/payment/paypal-checkout.ts +5 -10
- package/src/payment/postfinance-checkout/api-client.ts +106 -0
- package/src/payment/postfinance-checkout/api-types.ts +111 -0
- package/src/payment/postfinance-checkout/api.ts +58 -85
- package/src/payment/postfinance-checkout/handler-express.ts +5 -7
- package/src/payment/postfinance-checkout/handler-fastify.ts +6 -8
- package/src/payment/postfinance-checkout/index.ts +41 -31
- package/src/payment/postfinance-checkout/utils.ts +5 -10
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { OrderPricingSheet } from '@unchainedshop/core';
|
|
2
2
|
import { Order } from '@unchainedshop/core-orders';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const { PostFinanceCheckout } = pf;
|
|
3
|
+
import { Transaction, TransactionState } from './api-types.js';
|
|
6
4
|
|
|
7
5
|
export const transactionIsPaid = async (
|
|
8
|
-
transaction:
|
|
6
|
+
transaction: Transaction,
|
|
9
7
|
expectedCurrency: string,
|
|
10
8
|
expectedAmount: number,
|
|
11
9
|
): Promise<boolean> => {
|
|
12
|
-
if (transaction.state ===
|
|
10
|
+
if (transaction.state === TransactionState.FULFILL) {
|
|
13
11
|
return (
|
|
14
12
|
transaction.completedAmount !== undefined &&
|
|
15
13
|
transaction.completedAmount.toFixed(2) === expectedAmount.toFixed(2) &&
|
|
16
14
|
transaction.currency === expectedCurrency
|
|
17
15
|
);
|
|
18
16
|
}
|
|
19
|
-
if (transaction.state ===
|
|
17
|
+
if (transaction.state === TransactionState.AUTHORIZED) {
|
|
20
18
|
return (
|
|
21
19
|
transaction.authorizationAmount !== undefined &&
|
|
22
20
|
transaction.authorizationAmount.toFixed(2) === expectedAmount.toFixed(2) &&
|
|
@@ -26,10 +24,7 @@ export const transactionIsPaid = async (
|
|
|
26
24
|
return false;
|
|
27
25
|
};
|
|
28
26
|
|
|
29
|
-
export const orderIsPaid = async (
|
|
30
|
-
order: Order,
|
|
31
|
-
transaction: pf.PostFinanceCheckout.model.Transaction,
|
|
32
|
-
): Promise<boolean> => {
|
|
27
|
+
export const orderIsPaid = async (order: Order, transaction: Transaction): Promise<boolean> => {
|
|
33
28
|
const pricing = OrderPricingSheet({
|
|
34
29
|
calculation: order.calculation,
|
|
35
30
|
currencyCode: order.currencyCode,
|