@unchainedshop/plugins 4.0.0-rc.4 → 4.0.0-rc.6

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 (154) hide show
  1. package/lib/files/gridfs/adapter.d.ts.map +1 -1
  2. package/lib/files/gridfs/adapter.js +9 -4
  3. package/lib/files/gridfs/adapter.js.map +1 -1
  4. package/lib/files/gridfs/handler-express.d.ts.map +1 -1
  5. package/lib/files/gridfs/handler-express.js +4 -2
  6. package/lib/files/gridfs/handler-express.js.map +1 -1
  7. package/lib/files/gridfs/handler-fastify.d.ts.map +1 -1
  8. package/lib/files/gridfs/handler-fastify.js +4 -2
  9. package/lib/files/gridfs/handler-fastify.js.map +1 -1
  10. package/lib/files/gridfs/module.d.ts +2 -2
  11. package/lib/files/gridfs/module.d.ts.map +1 -1
  12. package/lib/files/gridfs/module.js +2 -2
  13. package/lib/files/gridfs/module.js.map +1 -1
  14. package/lib/payment/apple-iap/adapter.js +1 -1
  15. package/lib/payment/apple-iap/adapter.js.map +1 -1
  16. package/lib/payment/apple-iap/handler-express.js +1 -1
  17. package/lib/payment/apple-iap/handler-express.js.map +1 -1
  18. package/lib/payment/apple-iap/handler-fastify.js +1 -1
  19. package/lib/payment/apple-iap/handler-fastify.js.map +1 -1
  20. package/lib/payment/cryptopay/handle-webhook.js +1 -1
  21. package/lib/payment/cryptopay/handle-webhook.js.map +1 -1
  22. package/lib/payment/cryptopay/handler-express.js +1 -1
  23. package/lib/payment/cryptopay/handler-express.js.map +1 -1
  24. package/lib/payment/cryptopay/handler-fastify.d.ts.map +1 -1
  25. package/lib/payment/cryptopay/handler-fastify.js +1 -1
  26. package/lib/payment/cryptopay/handler-fastify.js.map +1 -1
  27. package/lib/payment/paypal-checkout.js +5 -7
  28. package/lib/payment/paypal-checkout.js.map +1 -1
  29. package/lib/payment/postfinance-checkout/api-client.d.ts +16 -0
  30. package/lib/payment/postfinance-checkout/api-client.d.ts.map +1 -0
  31. package/lib/payment/postfinance-checkout/api-client.js +75 -0
  32. package/lib/payment/postfinance-checkout/api-client.js.map +1 -0
  33. package/lib/payment/postfinance-checkout/api-types.d.ts +98 -0
  34. package/lib/payment/postfinance-checkout/api-types.d.ts.map +1 -0
  35. package/lib/payment/postfinance-checkout/api-types.js +51 -0
  36. package/lib/payment/postfinance-checkout/api-types.js.map +1 -0
  37. package/lib/payment/postfinance-checkout/api.d.ts +5 -5
  38. package/lib/payment/postfinance-checkout/api.d.ts.map +1 -1
  39. package/lib/payment/postfinance-checkout/api.js +38 -62
  40. package/lib/payment/postfinance-checkout/api.js.map +1 -1
  41. package/lib/payment/postfinance-checkout/handler-express.d.ts.map +1 -1
  42. package/lib/payment/postfinance-checkout/handler-express.js +5 -5
  43. package/lib/payment/postfinance-checkout/handler-express.js.map +1 -1
  44. package/lib/payment/postfinance-checkout/handler-fastify.d.ts.map +1 -1
  45. package/lib/payment/postfinance-checkout/handler-fastify.js +6 -6
  46. package/lib/payment/postfinance-checkout/handler-fastify.js.map +1 -1
  47. package/lib/payment/postfinance-checkout/index.d.ts +2 -1
  48. package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
  49. package/lib/payment/postfinance-checkout/index.js +25 -26
  50. package/lib/payment/postfinance-checkout/index.js.map +1 -1
  51. package/lib/payment/postfinance-checkout/utils.d.ts +3 -3
  52. package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
  53. package/lib/payment/postfinance-checkout/utils.js +3 -4
  54. package/lib/payment/postfinance-checkout/utils.js.map +1 -1
  55. package/lib/presets/all.d.ts +1 -1
  56. package/package.json +5 -10
  57. package/src/files/gridfs/adapter.ts +13 -4
  58. package/src/files/gridfs/handler-express.ts +8 -2
  59. package/src/files/gridfs/handler-fastify.ts +8 -2
  60. package/src/files/gridfs/module.ts +7 -2
  61. package/src/payment/apple-iap/adapter.ts +1 -1
  62. package/src/payment/apple-iap/handler-express.ts +1 -1
  63. package/src/payment/apple-iap/handler-fastify.ts +1 -1
  64. package/src/payment/cryptopay/handle-webhook.ts +1 -1
  65. package/src/payment/cryptopay/handler-express.ts +1 -1
  66. package/src/payment/cryptopay/handler-fastify.ts +2 -2
  67. package/src/payment/paypal-checkout.ts +5 -10
  68. package/src/payment/postfinance-checkout/api-client.ts +106 -0
  69. package/src/payment/postfinance-checkout/api-types.ts +111 -0
  70. package/src/payment/postfinance-checkout/api.ts +58 -85
  71. package/src/payment/postfinance-checkout/handler-express.ts +5 -7
  72. package/src/payment/postfinance-checkout/handler-fastify.ts +6 -8
  73. package/src/payment/postfinance-checkout/index.ts +41 -31
  74. package/src/payment/postfinance-checkout/utils.ts +5 -10
  75. package/lib/accounts/google-oauth.d.ts +0 -4
  76. package/lib/accounts/google-oauth.d.ts.map +0 -1
  77. package/lib/accounts/google-oauth.js +0 -145
  78. package/lib/accounts/google-oauth.js.map +0 -1
  79. package/lib/accounts/linkedin-oauth.d.ts +0 -4
  80. package/lib/accounts/linkedin-oauth.d.ts.map +0 -1
  81. package/lib/accounts/linkedin-oauth.js +0 -82
  82. package/lib/accounts/linkedin-oauth.js.map +0 -1
  83. package/lib/files/gridfs/gridfs-adapter.d.ts +0 -3
  84. package/lib/files/gridfs/gridfs-adapter.d.ts.map +0 -1
  85. package/lib/files/gridfs/gridfs-adapter.js +0 -97
  86. package/lib/files/gridfs/gridfs-adapter.js.map +0 -1
  87. package/lib/files/gridfs/gridfs-webhook.d.ts +0 -11
  88. package/lib/files/gridfs/gridfs-webhook.d.ts.map +0 -1
  89. package/lib/files/gridfs/gridfs-webhook.js +0 -84
  90. package/lib/files/gridfs/gridfs-webhook.js.map +0 -1
  91. package/lib/files/minio/minio-adapter.d.ts +0 -6
  92. package/lib/files/minio/minio-adapter.d.ts.map +0 -1
  93. package/lib/files/minio/minio-adapter.js +0 -181
  94. package/lib/files/minio/minio-adapter.js.map +0 -1
  95. package/lib/files/minio/minio-webhook.d.ts +0 -2
  96. package/lib/files/minio/minio-webhook.d.ts.map +0 -1
  97. package/lib/files/minio/minio-webhook.js +0 -33
  98. package/lib/files/minio/minio-webhook.js.map +0 -1
  99. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +0 -9
  100. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts.map +0 -1
  101. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +0 -17
  102. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +0 -1
  103. package/lib/payment/cryptopay/middleware.d.ts +0 -2
  104. package/lib/payment/cryptopay/middleware.d.ts.map +0 -1
  105. package/lib/payment/cryptopay/middleware.js +0 -75
  106. package/lib/payment/cryptopay/middleware.js.map +0 -1
  107. package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts +0 -25
  108. package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts.map +0 -1
  109. package/lib/payment/cryptopay/module/configureCryptopayModule.js +0 -75
  110. package/lib/payment/cryptopay/module/configureCryptopayModule.js.map +0 -1
  111. package/lib/payment/datatrans-v2/middleware.d.ts +0 -2
  112. package/lib/payment/datatrans-v2/middleware.d.ts.map +0 -1
  113. package/lib/payment/datatrans-v2/middleware.js +0 -68
  114. package/lib/payment/datatrans-v2/middleware.js.map +0 -1
  115. package/lib/payment/payrexx/middleware.d.ts +0 -2
  116. package/lib/payment/payrexx/middleware.d.ts.map +0 -1
  117. package/lib/payment/payrexx/middleware.js +0 -86
  118. package/lib/payment/payrexx/middleware.js.map +0 -1
  119. package/lib/payment/postfinance-checkout/middleware.d.ts +0 -2
  120. package/lib/payment/postfinance-checkout/middleware.d.ts.map +0 -1
  121. package/lib/payment/postfinance-checkout/middleware.js +0 -38
  122. package/lib/payment/postfinance-checkout/middleware.js.map +0 -1
  123. package/lib/payment/saferpay/middleware.d.ts +0 -2
  124. package/lib/payment/saferpay/middleware.d.ts.map +0 -1
  125. package/lib/payment/saferpay/middleware.js +0 -57
  126. package/lib/payment/saferpay/middleware.js.map +0 -1
  127. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.d.ts +0 -10
  128. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.d.ts.map +0 -1
  129. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.js +0 -24
  130. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.js.map +0 -1
  131. package/lib/payment/stripe/middleware.d.ts +0 -6
  132. package/lib/payment/stripe/middleware.d.ts.map +0 -1
  133. package/lib/payment/stripe/middleware.js +0 -114
  134. package/lib/payment/stripe/middleware.js.map +0 -1
  135. package/lib/plugins-index.d.ts +0 -48
  136. package/lib/plugins-index.d.ts.map +0 -1
  137. package/lib/plugins-index.js +0 -107
  138. package/lib/plugins-index.js.map +0 -1
  139. package/lib/worker/BaseWorker.d.ts +0 -30
  140. package/lib/worker/BaseWorker.d.ts.map +0 -1
  141. package/lib/worker/BaseWorker.js +0 -79
  142. package/lib/worker/BaseWorker.js.map +0 -1
  143. package/lib/worker/EventListenerWorker.d.ts +0 -6
  144. package/lib/worker/EventListenerWorker.d.ts.map +0 -1
  145. package/lib/worker/EventListenerWorker.js +0 -46
  146. package/lib/worker/EventListenerWorker.js.map +0 -1
  147. package/lib/worker/FailedRescheduler.d.ts +0 -15
  148. package/lib/worker/FailedRescheduler.d.ts.map +0 -1
  149. package/lib/worker/FailedRescheduler.js +0 -45
  150. package/lib/worker/FailedRescheduler.js.map +0 -1
  151. package/lib/worker/IntervalWorker.d.ts +0 -10
  152. package/lib/worker/IntervalWorker.d.ts.map +0 -1
  153. package/lib/worker/IntervalWorker.js +0 -37
  154. package/lib/worker/IntervalWorker.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { Order } from '@unchainedshop/core-orders';
2
- import * as pf from 'postfinancecheckout';
3
- export declare const transactionIsPaid: (transaction: pf.PostFinanceCheckout.model.Transaction, expectedCurrency: string, expectedAmount: number) => Promise<boolean>;
4
- export declare const orderIsPaid: (order: Order, transaction: pf.PostFinanceCheckout.model.Transaction) => Promise<boolean>;
2
+ import { Transaction } from './api-types.js';
3
+ export declare const transactionIsPaid: (transaction: Transaction, expectedCurrency: string, expectedAmount: number) => Promise<boolean>;
4
+ export declare const orderIsPaid: (order: Order, transaction: Transaction) => Promise<boolean>;
5
5
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/payment/postfinance-checkout/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI1C,eAAO,MAAM,iBAAiB,GAC5B,aAAa,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,WAAW,EACrD,kBAAkB,MAAM,EACxB,gBAAgB,MAAM,KACrB,OAAO,CAAC,OAAO,CAgBjB,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,EACZ,aAAa,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,WAAW,KACpD,OAAO,CAAC,OAAO,CAOjB,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/payment/postfinance-checkout/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAC;AAE/D,eAAO,MAAM,iBAAiB,GAC5B,aAAa,WAAW,EACxB,kBAAkB,MAAM,EACxB,gBAAgB,MAAM,KACrB,OAAO,CAAC,OAAO,CAgBjB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,OAAO,KAAK,EAAE,aAAa,WAAW,KAAG,OAAO,CAAC,OAAO,CAOzF,CAAC"}
@@ -1,13 +1,12 @@
1
1
  import { OrderPricingSheet } from '@unchainedshop/core';
2
- import * as pf from 'postfinancecheckout';
3
- const { PostFinanceCheckout } = pf;
2
+ import { TransactionState } from './api-types.js';
4
3
  export const transactionIsPaid = async (transaction, expectedCurrency, expectedAmount) => {
5
- if (transaction.state === PostFinanceCheckout.model.TransactionState.FULFILL) {
4
+ if (transaction.state === TransactionState.FULFILL) {
6
5
  return (transaction.completedAmount !== undefined &&
7
6
  transaction.completedAmount.toFixed(2) === expectedAmount.toFixed(2) &&
8
7
  transaction.currency === expectedCurrency);
9
8
  }
10
- if (transaction.state === PostFinanceCheckout.model.TransactionState.AUTHORIZED) {
9
+ if (transaction.state === TransactionState.AUTHORIZED) {
11
10
  return (transaction.authorizationAmount !== undefined &&
12
11
  transaction.authorizationAmount.toFixed(2) === expectedAmount.toFixed(2) &&
13
12
  transaction.currency === expectedCurrency);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/payment/postfinance-checkout/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE1C,MAAM,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC;AAEnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,WAAqD,EACrD,gBAAwB,EACxB,cAAsB,EACJ,EAAE;IACpB,IAAI,WAAW,CAAC,KAAK,KAAK,mBAAmB,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC7E,OAAO,CACL,WAAW,CAAC,eAAe,KAAK,SAAS;YACzC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YACpE,WAAW,CAAC,QAAQ,KAAK,gBAAgB,CAC1C,CAAC;IACJ,CAAC;IACD,IAAI,WAAW,CAAC,KAAK,KAAK,mBAAmB,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC;QAChF,OAAO,CACL,WAAW,CAAC,mBAAmB,KAAK,SAAS;YAC7C,WAAW,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YACxE,WAAW,CAAC,QAAQ,KAAK,gBAAgB,CAC1C,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,KAAY,EACZ,WAAqD,EACnC,EAAE;IACpB,MAAM,OAAO,GAAG,iBAAiB,CAAC;QAChC,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;IACvE,OAAO,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AACzE,CAAC,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/payment/postfinance-checkout/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAe,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,WAAwB,EACxB,gBAAwB,EACxB,cAAsB,EACJ,EAAE;IACpB,IAAI,WAAW,CAAC,KAAK,KAAK,gBAAgB,CAAC,OAAO,EAAE,CAAC;QACnD,OAAO,CACL,WAAW,CAAC,eAAe,KAAK,SAAS;YACzC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YACpE,WAAW,CAAC,QAAQ,KAAK,gBAAgB,CAC1C,CAAC;IACJ,CAAC;IACD,IAAI,WAAW,CAAC,KAAK,KAAK,gBAAgB,CAAC,UAAU,EAAE,CAAC;QACtD,OAAO,CACL,WAAW,CAAC,mBAAmB,KAAK,SAAS;YAC7C,WAAW,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YACxE,WAAW,CAAC,QAAQ,KAAK,gBAAgB,CAC1C,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,KAAY,EAAE,WAAwB,EAAoB,EAAE;IAC5F,MAAM,OAAO,GAAG,iBAAiB,CAAC;QAChC,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;IACvE,OAAO,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AACzE,CAAC,CAAC"}
@@ -58,7 +58,7 @@ declare const modules: {
58
58
  configure: ({ db }: {
59
59
  db: any;
60
60
  }) => {
61
- createWriteStream: (directoryName: any, fileId: any, fileName: any, metadata: any) => Promise<import("mongodb").GridFSBucketWriteStream>;
61
+ createWriteStream: (directoryName: any, fileId: any, fileName: any, uploadOptions: import("mongodb").GridFSBucketWriteStream["options"]) => Promise<import("mongodb").GridFSBucketWriteStream>;
62
62
  getFileInfo: (directoryName: any, fileId: any) => Promise<import("mongodb").GridFSFile>;
63
63
  createReadStream: (directoryName: any, fileId: any) => Promise<import("mongodb").GridFSBucketReadStream>;
64
64
  removeFileFromBucket: (directoryName: any, fileId: any) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
- "version": "4.0.0-rc.4",
3
+ "version": "4.0.0-rc.6",
4
4
  "main": "lib/plugins-index.js",
5
5
  "types": "lib/plugins-index.d.ts",
6
6
  "exports": {
@@ -64,7 +64,6 @@
64
64
  "nodemailer": ">= 6.9 < 8",
65
65
  "open": "10.x",
66
66
  "p-memoize": "7.x",
67
- "postfinancecheckout": ">= 4.5.0",
68
67
  "stripe": ">= 17 < 19",
69
68
  "web-push": ">= 3.6 <4",
70
69
  "xml-js": ">= 1.6 < 2"
@@ -112,9 +111,6 @@
112
111
  "p-memoize": {
113
112
  "optional": true
114
113
  },
115
- "postfinancecheckout": {
116
- "optional": true
117
- },
118
114
  "stripe": {
119
115
  "optional": true
120
116
  },
@@ -128,22 +124,21 @@
128
124
  "devDependencies": {
129
125
  "@breejs/later": "^4.2.0",
130
126
  "@paypal/checkout-server-sdk": "^1.0.3",
131
- "@redis/client": "^5.5.6",
127
+ "@redis/client": "^5.6.0",
132
128
  "@scure/bip32": "^1.7.0",
133
129
  "@scure/btc-signer": "^1.8.1",
134
130
  "@types/breejs__later": "^4.1.5",
135
131
  "@types/express": "^5.0.3",
136
- "@types/node": "^24.0.4",
132
+ "@types/node": "^24.0.13",
137
133
  "expiry-map": "^2.0.0",
138
134
  "express": "^5.1.0",
139
135
  "fastify": "^5.4.0",
140
136
  "mime-types": "^3.0.1",
141
137
  "minio": "^8.0.5",
142
- "nodemailer": "^7.0.3",
138
+ "nodemailer": "^7.0.5",
143
139
  "open": "^10.1.2",
144
140
  "p-memoize": "^7.1.1",
145
- "postfinancecheckout": "^4.7.0",
146
- "stripe": "^18.2.1",
141
+ "stripe": "^18.3.0",
147
142
  "tsx": "^4.20.3",
148
143
  "typescript": "^5.8.3",
149
144
  "web-push": "^3.6.7",
@@ -69,7 +69,7 @@ export const GridFSAdapter: IFileAdapter<
69
69
  } as UploadFileData & { putURL: string };
70
70
  },
71
71
 
72
- async uploadFileFromStream(directoryName: string, rawFile: any, { modules }) {
72
+ async uploadFileFromStream(directoryName: string, rawFile: any, { modules }, options = {}) {
73
73
  let stream: Readable;
74
74
  let fileName;
75
75
  if (rawFile instanceof Promise) {
@@ -89,9 +89,16 @@ export const GridFSAdapter: IFileAdapter<
89
89
  directoryName,
90
90
  hashedFilename,
91
91
  fileName,
92
- { 'content-type': type },
92
+ {
93
+ metadata: { 'content-type': type },
94
+ ...options,
95
+ },
96
+ );
97
+ await pipeline(
98
+ stream,
99
+ new PassThrough({ allowHalfOpen: true, highWaterMark: 1024 * 1024 }),
100
+ writeStream,
93
101
  );
94
- await pipeline(stream, new PassThrough({ allowHalfOpen: true }), writeStream);
95
102
  const { length } = writeStream;
96
103
  const url = `/gridfs/${directoryName}/${encodeURIComponent(hashedFilename)}`;
97
104
 
@@ -125,7 +132,9 @@ export const GridFSAdapter: IFileAdapter<
125
132
  directoryName,
126
133
  hashedFilename,
127
134
  fileName,
128
- { 'content-type': type },
135
+ {
136
+ metadata: { 'content-type': type },
137
+ },
129
138
  );
130
139
  await pipeline(response.body as unknown as Readable, new PassThrough(), writeStream);
131
140
  const { length } = writeStream;
@@ -61,9 +61,15 @@ const gridfsHandler = async (
61
61
  directoryName,
62
62
  fileId,
63
63
  fileName,
64
- { 'content-type': type },
64
+ {
65
+ metadata: { 'content-type': type },
66
+ },
67
+ );
68
+ await pipeline(
69
+ req,
70
+ new PassThrough({ allowHalfOpen: true, highWaterMark: 1024 * 1024 }),
71
+ writeStream,
65
72
  );
66
- await pipeline(req, new PassThrough(), writeStream);
67
73
 
68
74
  const { length } = writeStream;
69
75
  await services.files.linkFile({ fileId, size: length, type });
@@ -54,10 +54,16 @@ const gridfsHandler: RouteHandlerMethod = async (
54
54
  directoryName,
55
55
  fileId,
56
56
  fileName,
57
- { 'content-type': type },
57
+ {
58
+ metadata: { 'content-type': type },
59
+ },
58
60
  );
59
61
 
60
- await pipeline(req.raw, new PassThrough(), writeStream);
62
+ await pipeline(
63
+ req.raw,
64
+ new PassThrough({ allowHalfOpen: true, highWaterMark: 1024 * 1024 }),
65
+ writeStream,
66
+ );
61
67
 
62
68
  const { length } = writeStream;
63
69
  await services.files.linkFile({ fileId, size: length, type });
@@ -5,10 +5,15 @@ export const configureGridFSFileUploadModule = ({ db }) => {
5
5
  let { GridFSBucket } = mongodb;
6
6
 
7
7
  return {
8
- createWriteStream: async (directoryName, fileId, fileName, metadata) => {
8
+ createWriteStream: async (
9
+ directoryName,
10
+ fileId,
11
+ fileName,
12
+ uploadOptions: mongodb.GridFSBucketWriteStream['options'],
13
+ ) => {
9
14
  const options = { bucketName: `file_uploads_${directoryName}` };
10
15
  const bucket = new GridFSBucket(db, options);
11
- return bucket.openUploadStreamWithId(fileId, fileName, { metadata });
16
+ return bucket.openUploadStreamWithId(fileId, fileName, uploadOptions);
12
17
  },
13
18
  getFileInfo: async (directoryName, fileId) => {
14
19
  const options = { bucketName: `file_uploads_${directoryName}` };
@@ -3,7 +3,7 @@ import { createLogger } from '@unchainedshop/logger';
3
3
  import { AppleTransactionsModule } from './module.js';
4
4
  import { verifyReceipt } from './verify-receipt.js';
5
5
 
6
- const logger = createLogger('unchained:core-payment:iap');
6
+ const logger = createLogger('unchained:core-payment:apple-iap');
7
7
 
8
8
  const { APPLE_IAP_SHARED_SECRET } = process.env;
9
9
 
@@ -3,7 +3,7 @@ import { EnrollmentStatus } from '@unchainedshop/core-enrollments';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
4
  import { fixPeriods } from './fix-periods.js';
5
5
 
6
- const logger = createLogger('unchained:core-payment:iap');
6
+ const logger = createLogger('unchained:core-payment:apple-iap:handler');
7
7
 
8
8
  const { APPLE_IAP_SHARED_SECRET } = process.env;
9
9
 
@@ -5,7 +5,7 @@ import { fixPeriods } from './fix-periods.js';
5
5
  import { FastifyRequest, RouteHandlerMethod } from 'fastify';
6
6
  import { AppleTransactionsModule } from './module.js';
7
7
 
8
- const logger = createLogger('unchained:core-payment:iap');
8
+ const logger = createLogger('unchained:core-payment:apple-iap:handler');
9
9
 
10
10
  const { APPLE_IAP_SHARED_SECRET } = process.env;
11
11
 
@@ -6,7 +6,7 @@ import { ProductPriceRate } from '@unchainedshop/core-products';
6
6
 
7
7
  const { CRYPTOPAY_SECRET, CRYPTOPAY_MAX_RATE_AGE = '360' } = process.env;
8
8
 
9
- const logger = createLogger('unchained:core-payment:cryptopay');
9
+ const logger = createLogger('unchained:core-payment:cryptopay:handler');
10
10
 
11
11
  export default async function handleWebhook(
12
12
  {
@@ -1,7 +1,7 @@
1
1
  import { createLogger } from '@unchainedshop/logger';
2
2
  import handleWebhook from './handle-webhook.js';
3
3
 
4
- const logger = createLogger('unchained:core-payment:cryptopay');
4
+ const logger = createLogger('unchained:core-payment:cryptopay:handler');
5
5
 
6
6
  const cryptopayHandler = async (req, res) => {
7
7
  if (req.method === 'POST') {
@@ -1,9 +1,9 @@
1
1
  import { createLogger } from '@unchainedshop/logger';
2
2
  import handleWebhook from './handle-webhook.js';
3
-
4
- const logger = createLogger('unchained:core-payment:cryptopay');
5
3
  import { FastifyRequest, RouteHandlerMethod } from 'fastify';
6
4
 
5
+ const logger = createLogger('unchained:core-payment:cryptopay:handler');
6
+
7
7
  const cryptopayHandler: RouteHandlerMethod = async (
8
8
  req: FastifyRequest & {
9
9
  unchainedContext: any;
@@ -17,7 +17,7 @@ try {
17
17
  /* */
18
18
  }
19
19
 
20
- const logger = createLogger('unchained:core-payment');
20
+ const logger = createLogger('unchained:core-payment:paypal-checkout');
21
21
 
22
22
  const { PAYPAL_CLIENT_ID, PAYPAL_SECRET, PAYPAL_ENVIRONMENT = 'sandbox' } = process.env;
23
23
 
@@ -79,7 +79,6 @@ const PaypalCheckout: IPaymentAdapter = {
79
79
  const { order } = context;
80
80
 
81
81
  if (!orderID) {
82
- logger.warn('Paypal Native Plugin: PRICE MATCH');
83
82
  throw new Error('You have to provide orderID in paymentContext');
84
83
  }
85
84
 
@@ -96,21 +95,17 @@ const PaypalCheckout: IPaymentAdapter = {
96
95
  const paypalTotal = paypalOrder.result.purchase_units[0].amount.value;
97
96
 
98
97
  if (ourTotal === paypalTotal) {
99
- logger.info('Paypal Native Plugin: PRICE MATCH');
100
98
  return order;
101
99
  }
102
100
 
103
- logger.warn(
104
- 'Paypal Native Plugin: Missmatch PAYPAL ORDER',
105
- JSON.stringify(paypalOrder.result, null, 2),
106
- );
101
+ logger.warn('Missmatch PAYPAL ORDER', JSON.stringify(paypalOrder.result, null, 2));
107
102
 
108
- logger.debug('Paypal Native Plugin: OUR ORDER', order);
109
- logger.debug('Paypal Native Plugin: OUR PRICE', pricing);
103
+ logger.debug('OUR ORDER', order);
104
+ logger.debug('OUR PRICE', pricing);
110
105
 
111
106
  throw new Error(`Payment mismatch`);
112
107
  } catch (e) {
113
- logger.warn('Paypal Native Plugin: Failed', e);
108
+ logger.warn(e);
114
109
  throw new Error(e);
115
110
  }
116
111
  },
@@ -0,0 +1,106 @@
1
+ import crypto from 'crypto';
2
+
3
+ const API_BASE_URL = 'https://checkout.postfinance.ch/api';
4
+
5
+ interface ApiConfig {
6
+ spaceId: number;
7
+ userId: number;
8
+ apiSecret: string;
9
+ }
10
+
11
+ interface MacHeaders {
12
+ 'x-mac-version': string;
13
+ 'x-mac-userid': string;
14
+ 'x-mac-timestamp': string;
15
+ 'x-mac-value': string;
16
+ }
17
+
18
+ export class PostFinanceApiClient {
19
+ private config: ApiConfig;
20
+
21
+ constructor(config: ApiConfig) {
22
+ this.config = config;
23
+ }
24
+
25
+ private generateMacHeaders(method: string, path: string): MacHeaders {
26
+ const version = '1';
27
+ const timestamp = Math.floor(Date.now() / 1000).toString();
28
+ const userId = this.config.userId.toString();
29
+
30
+ // Use path as-is since it already includes /api from the URL
31
+ const resourcePath = path;
32
+
33
+ const dataToSign = [version, userId, timestamp, method, resourcePath].join('|');
34
+
35
+ const macValue = crypto
36
+ .createHmac('sha512', Buffer.from(this.config.apiSecret, 'base64'))
37
+ .update(dataToSign, 'utf8')
38
+ .digest('base64');
39
+
40
+ return {
41
+ 'x-mac-version': version,
42
+ 'x-mac-userid': userId,
43
+ 'x-mac-timestamp': timestamp,
44
+ 'x-mac-value': macValue,
45
+ };
46
+ }
47
+
48
+ async request<T>(method: string, endpoint: string, body?: any): Promise<T> {
49
+ const url = `${API_BASE_URL}${endpoint}`;
50
+ const urlObj = new URL(url);
51
+ // Include both pathname and search (query parameters) for MAC signature
52
+ const pathWithQuery = urlObj.pathname + urlObj.search;
53
+ const macHeaders = this.generateMacHeaders(method, pathWithQuery);
54
+
55
+ const headers: Record<string, string> = {
56
+ ...macHeaders,
57
+ 'Content-Type': 'application/json',
58
+ Accept: 'application/json',
59
+ };
60
+
61
+ const options: RequestInit = {
62
+ method,
63
+ headers,
64
+ };
65
+
66
+ if (body && method !== 'GET') {
67
+ options.body = JSON.stringify(body);
68
+ }
69
+
70
+ const response = await fetch(url, options);
71
+
72
+ if (!response.ok) {
73
+ const errorData = await response.json().catch(() => ({}));
74
+ throw new Error(
75
+ `PostFinance API error: ${response.status} ${response.statusText} ${JSON.stringify(errorData)}`,
76
+ );
77
+ }
78
+
79
+ const responseText = await response.text();
80
+ const contentType = response.headers.get('content-type');
81
+
82
+ if (contentType && contentType.includes('application/json')) {
83
+ try {
84
+ return JSON.parse(responseText);
85
+ } catch {
86
+ // If JSON parsing fails but content-type is json, return as text
87
+ // This handles PostFinance's payment-page-url endpoint that returns plain text with json content-type
88
+ return responseText as any;
89
+ }
90
+ } else {
91
+ return responseText as any;
92
+ }
93
+ }
94
+
95
+ get<T>(endpoint: string): Promise<T> {
96
+ return this.request<T>('GET', endpoint);
97
+ }
98
+
99
+ post<T>(endpoint: string, body: any): Promise<T> {
100
+ return this.request<T>('POST', endpoint, body);
101
+ }
102
+
103
+ patch<T>(endpoint: string, body: any): Promise<T> {
104
+ return this.request<T>('PATCH', endpoint, body);
105
+ }
106
+ }
@@ -0,0 +1,111 @@
1
+ // PostFinance Checkout API Types
2
+
3
+ export enum TransactionState {
4
+ CREATE = 'CREATE',
5
+ PENDING = 'PENDING',
6
+ CONFIRMED = 'CONFIRMED',
7
+ PROCESSING = 'PROCESSING',
8
+ FAILED = 'FAILED',
9
+ AUTHORIZED = 'AUTHORIZED',
10
+ VOIDED = 'VOIDED',
11
+ COMPLETED = 'COMPLETED',
12
+ FULFILL = 'FULFILL',
13
+ DECLINE = 'DECLINE',
14
+ }
15
+
16
+ export enum TokenizationMode {
17
+ FORCE_UPDATE = 'FORCE_UPDATE',
18
+ ALLOW = 'ALLOW',
19
+ ALLOW_ONE_CLICK_PAYMENT = 'ALLOW_ONE_CLICK_PAYMENT',
20
+ DENY = 'DENY',
21
+ }
22
+
23
+ export enum TransactionCompletionBehavior {
24
+ COMPLETE_IMMEDIATELY = 'COMPLETE_IMMEDIATELY',
25
+ COMPLETE_DEFERRED = 'COMPLETE_DEFERRED',
26
+ USE_CONFIGURATION = 'USE_CONFIGURATION',
27
+ }
28
+
29
+ export enum LineItemType {
30
+ SHIPPING = 'SHIPPING',
31
+ DISCOUNT = 'DISCOUNT',
32
+ FEE = 'FEE',
33
+ PRODUCT = 'PRODUCT',
34
+ TIP = 'TIP',
35
+ }
36
+
37
+ export enum RefundType {
38
+ MERCHANT_INITIATED_ONLINE = 'MERCHANT_INITIATED_ONLINE',
39
+ MERCHANT_INITIATED_OFFLINE = 'MERCHANT_INITIATED_OFFLINE',
40
+ CUSTOMER_INITIATED_AUTOMATIC = 'CUSTOMER_INITIATED_AUTOMATIC',
41
+ CUSTOMER_INITIATED_MANUAL = 'CUSTOMER_INITIATED_MANUAL',
42
+ }
43
+
44
+ export enum CreationEntityState {
45
+ CREATE = 'CREATE',
46
+ ACTIVE = 'ACTIVE',
47
+ INACTIVE = 'INACTIVE',
48
+ DELETING = 'DELETING',
49
+ DELETED = 'DELETED',
50
+ }
51
+
52
+ export interface LineItem {
53
+ name: string;
54
+ type: LineItemType;
55
+ quantity: number;
56
+ uniqueId: string;
57
+ amountIncludingTax: number;
58
+ }
59
+
60
+ export interface TransactionCreate {
61
+ currency: string;
62
+ customerId?: string;
63
+ tokenizationMode?: TokenizationMode;
64
+ completionBehavior?: TransactionCompletionBehavior;
65
+ lineItems?: LineItem[];
66
+ successUrl?: string;
67
+ failedUrl?: string;
68
+ metaData?: Record<string, any>;
69
+ }
70
+
71
+ export interface Transaction {
72
+ id: number;
73
+ state: TransactionState;
74
+ currency: string;
75
+ completedAmount?: number;
76
+ authorizationAmount?: number;
77
+ metaData?: Record<string, any>;
78
+ token?: {
79
+ id: number;
80
+ [key: string]: any;
81
+ };
82
+ }
83
+
84
+ export interface TransactionCompletion {
85
+ id: number;
86
+ state: string;
87
+ transaction: number;
88
+ linkedTransaction?: number;
89
+ }
90
+
91
+ export interface Token {
92
+ id: number;
93
+ state: CreationEntityState;
94
+ name?: string;
95
+ customerId?: string;
96
+ enabledForOneClickPayment?: boolean;
97
+ }
98
+
99
+ export interface RefundCreate {
100
+ transaction: number;
101
+ externalId: string;
102
+ amount: number;
103
+ type: RefundType;
104
+ }
105
+
106
+ export interface Refund {
107
+ id: number;
108
+ state: string;
109
+ amount: number;
110
+ transaction: number;
111
+ }