@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.
Files changed (56) hide show
  1. package/lib/payment/apple-iap/adapter.js +1 -1
  2. package/lib/payment/apple-iap/adapter.js.map +1 -1
  3. package/lib/payment/apple-iap/handler-express.js +1 -1
  4. package/lib/payment/apple-iap/handler-express.js.map +1 -1
  5. package/lib/payment/apple-iap/handler-fastify.js +1 -1
  6. package/lib/payment/apple-iap/handler-fastify.js.map +1 -1
  7. package/lib/payment/cryptopay/handle-webhook.js +1 -1
  8. package/lib/payment/cryptopay/handle-webhook.js.map +1 -1
  9. package/lib/payment/cryptopay/handler-express.js +1 -1
  10. package/lib/payment/cryptopay/handler-express.js.map +1 -1
  11. package/lib/payment/cryptopay/handler-fastify.d.ts.map +1 -1
  12. package/lib/payment/cryptopay/handler-fastify.js +1 -1
  13. package/lib/payment/cryptopay/handler-fastify.js.map +1 -1
  14. package/lib/payment/paypal-checkout.js +5 -7
  15. package/lib/payment/paypal-checkout.js.map +1 -1
  16. package/lib/payment/postfinance-checkout/api-client.d.ts +16 -0
  17. package/lib/payment/postfinance-checkout/api-client.d.ts.map +1 -0
  18. package/lib/payment/postfinance-checkout/api-client.js +75 -0
  19. package/lib/payment/postfinance-checkout/api-client.js.map +1 -0
  20. package/lib/payment/postfinance-checkout/api-types.d.ts +98 -0
  21. package/lib/payment/postfinance-checkout/api-types.d.ts.map +1 -0
  22. package/lib/payment/postfinance-checkout/api-types.js +51 -0
  23. package/lib/payment/postfinance-checkout/api-types.js.map +1 -0
  24. package/lib/payment/postfinance-checkout/api.d.ts +5 -5
  25. package/lib/payment/postfinance-checkout/api.d.ts.map +1 -1
  26. package/lib/payment/postfinance-checkout/api.js +38 -62
  27. package/lib/payment/postfinance-checkout/api.js.map +1 -1
  28. package/lib/payment/postfinance-checkout/handler-express.d.ts.map +1 -1
  29. package/lib/payment/postfinance-checkout/handler-express.js +5 -5
  30. package/lib/payment/postfinance-checkout/handler-express.js.map +1 -1
  31. package/lib/payment/postfinance-checkout/handler-fastify.d.ts.map +1 -1
  32. package/lib/payment/postfinance-checkout/handler-fastify.js +6 -6
  33. package/lib/payment/postfinance-checkout/handler-fastify.js.map +1 -1
  34. package/lib/payment/postfinance-checkout/index.d.ts +2 -1
  35. package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
  36. package/lib/payment/postfinance-checkout/index.js +25 -26
  37. package/lib/payment/postfinance-checkout/index.js.map +1 -1
  38. package/lib/payment/postfinance-checkout/utils.d.ts +3 -3
  39. package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
  40. package/lib/payment/postfinance-checkout/utils.js +3 -4
  41. package/lib/payment/postfinance-checkout/utils.js.map +1 -1
  42. package/package.json +5 -10
  43. package/src/payment/apple-iap/adapter.ts +1 -1
  44. package/src/payment/apple-iap/handler-express.ts +1 -1
  45. package/src/payment/apple-iap/handler-fastify.ts +1 -1
  46. package/src/payment/cryptopay/handle-webhook.ts +1 -1
  47. package/src/payment/cryptopay/handler-express.ts +1 -1
  48. package/src/payment/cryptopay/handler-fastify.ts +2 -2
  49. package/src/payment/paypal-checkout.ts +5 -10
  50. package/src/payment/postfinance-checkout/api-client.ts +106 -0
  51. package/src/payment/postfinance-checkout/api-types.ts +111 -0
  52. package/src/payment/postfinance-checkout/api.ts +58 -85
  53. package/src/payment/postfinance-checkout/handler-express.ts +5 -7
  54. package/src/payment/postfinance-checkout/handler-fastify.ts +6 -8
  55. package/src/payment/postfinance-checkout/index.ts +41 -31
  56. 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 * as pf from 'postfinancecheckout';
4
-
5
- const { PostFinanceCheckout } = pf;
3
+ import { Transaction, TransactionState } from './api-types.js';
6
4
 
7
5
  export const transactionIsPaid = async (
8
- transaction: pf.PostFinanceCheckout.model.Transaction,
6
+ transaction: Transaction,
9
7
  expectedCurrency: string,
10
8
  expectedAmount: number,
11
9
  ): Promise<boolean> => {
12
- if (transaction.state === PostFinanceCheckout.model.TransactionState.FULFILL) {
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 === PostFinanceCheckout.model.TransactionState.AUTHORIZED) {
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,