@vandenberghinc/volt 1.1.26 → 1.1.28
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/backend/dist/cjs/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
- package/backend/dist/cjs/{blacklist.js → backend/src/blacklist.js} +8 -5
- package/backend/dist/cjs/{cli.js → backend/src/cli.js} +29 -47
- package/backend/dist/cjs/backend/src/database/collection.d.ts +1543 -0
- package/backend/dist/cjs/backend/src/database/collection.js +3042 -0
- package/backend/dist/cjs/backend/src/database/database.d.ts +66 -0
- package/backend/dist/cjs/{database → backend/src/database}/database.js +48 -43
- package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +6 -0
- package/backend/dist/cjs/backend/src/database/filters/filters.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +443 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +355 -0
- package/backend/dist/cjs/backend/src/database/flatten.d.ts +75 -0
- package/backend/dist/cjs/{logger.js → backend/src/database/flatten.js} +18 -7
- package/backend/dist/cjs/backend/src/database/flatten_test.js +175 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +461 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.js +1014 -0
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +534 -0
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +1087 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +293 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.js +573 -0
- package/backend/dist/{esm → cjs/backend/src}/endpoint.d.ts +69 -46
- package/backend/dist/cjs/{endpoint.js → backend/src/endpoint.js} +87 -101
- package/backend/dist/cjs/backend/src/errors/index.d.ts +7 -0
- package/backend/dist/cjs/backend/src/errors/index.js +25 -0
- package/backend/dist/{esm/utils.d.ts → cjs/backend/src/errors/internal_external.d.ts} +14 -22
- package/backend/dist/cjs/backend/src/errors/internal_external.js +85 -0
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/backend/dist/cjs/{mutex.js → backend/src/errors/invalid_usage_error.js} +20 -37
- package/backend/dist/cjs/backend/src/errors/system_error.d.ts +230 -0
- package/backend/dist/cjs/backend/src/errors/system_error.js +393 -0
- package/backend/dist/cjs/backend/src/events.d.ts +54 -0
- package/backend/dist/cjs/backend/src/events.js +15 -0
- package/backend/dist/cjs/{frontend.js → backend/src/frontend.js} +1 -1
- package/backend/dist/cjs/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
- package/backend/dist/cjs/{image_endpoint.js → backend/src/image_endpoint.js} +3 -5
- package/backend/dist/cjs/backend/src/logger.d.ts +5 -0
- package/backend/dist/cjs/backend/src/logger.js +15 -0
- package/backend/dist/cjs/backend/src/meta.d.ts +64 -0
- package/backend/dist/cjs/{meta.js → backend/src/meta.js} +9 -12
- package/backend/dist/cjs/backend/src/payments/paddle.d.ts +326 -0
- package/backend/dist/cjs/{payments → backend/src/payments}/paddle.js +377 -327
- package/backend/dist/cjs/backend/src/plugins/browser.d.ts +1 -0
- package/backend/dist/cjs/backend/src/plugins/browser.js +15 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +248 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.js +379 -0
- package/backend/dist/{esm → cjs/backend/src}/plugins/mail/ui.d.ts +23 -0
- package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/cjs/backend/src/rate_limit.d.ts +145 -0
- package/backend/dist/cjs/backend/src/rate_limit.js +549 -0
- package/backend/dist/cjs/{route.d.ts → backend/src/route.d.ts} +3 -10
- package/backend/dist/cjs/{route.js → backend/src/route.js} +23 -21
- package/backend/dist/cjs/backend/src/server.d.ts +485 -0
- package/backend/dist/cjs/{server.js → backend/src/server.js} +688 -873
- package/backend/dist/cjs/backend/src/splash_screen.d.ts +80 -0
- package/backend/dist/cjs/{splash_screen.js → backend/src/splash_screen.js} +24 -3
- package/backend/dist/cjs/backend/src/status.d.ts +74 -0
- package/backend/dist/cjs/{status.js → backend/src/status.js} +64 -64
- package/backend/dist/cjs/backend/src/stream.d.ts +376 -0
- package/backend/dist/cjs/{stream.js → backend/src/stream.js} +299 -276
- package/backend/dist/cjs/backend/src/users.d.ts +807 -0
- package/backend/dist/cjs/backend/src/users.js +1971 -0
- package/backend/dist/cjs/backend/src/utils.d.ts +16 -0
- package/backend/dist/cjs/{utils.js → backend/src/utils.js} +14 -77
- package/backend/dist/{esm → cjs/backend/src}/view.d.ts +33 -11
- package/backend/dist/cjs/backend/src/view.js +508 -0
- package/backend/dist/{esm → cjs/backend/src}/volt.d.ts +10 -1
- package/backend/dist/cjs/{volt.js → backend/src/volt.js} +8 -5
- package/backend/dist/cjs/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/cjs/frontend/src/modules/request.js +99 -0
- package/backend/dist/esm/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
- package/backend/dist/esm/{blacklist.js → backend/src/blacklist.js} +9 -6
- package/backend/dist/esm/{cli.js → backend/src/cli.js} +43 -60
- package/backend/dist/esm/backend/src/database/collection.d.ts +1543 -0
- package/backend/dist/esm/backend/src/database/collection.js +3510 -0
- package/backend/dist/esm/backend/src/database/database.d.ts +66 -0
- package/backend/dist/esm/{database → backend/src/database}/database.js +62 -103
- package/backend/dist/esm/backend/src/database/document.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/document.js +558 -0
- package/backend/dist/esm/backend/src/database/filters/filters.d.ts +6 -0
- package/backend/dist/esm/backend/src/database/filters/filters.js +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter.js +3 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +505 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +712 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +44 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +405 -0
- package/backend/dist/esm/backend/src/database/flatten.d.ts +75 -0
- package/backend/dist/esm/backend/src/database/flatten.js +22 -0
- package/backend/dist/esm/backend/src/database/flatten_test.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/flatten_test.js +174 -0
- package/backend/dist/esm/backend/src/database/quota/quota.d.ts +461 -0
- package/backend/dist/esm/backend/src/database/quota/quota.js +1118 -0
- package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +534 -0
- package/backend/dist/esm/backend/src/database/quota/quota_v1.js +1242 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +293 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.js +602 -0
- package/backend/dist/{cjs → esm/backend/src}/endpoint.d.ts +69 -46
- package/backend/dist/esm/{endpoint.js → backend/src/endpoint.js} +136 -127
- package/backend/dist/esm/backend/src/errors/index.d.ts +7 -0
- package/backend/dist/esm/backend/src/errors/index.js +7 -0
- package/backend/dist/{cjs/utils.d.ts → esm/backend/src/errors/internal_external.d.ts} +14 -22
- package/backend/dist/esm/backend/src/errors/internal_external.js +70 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +30 -0
- package/backend/dist/esm/backend/src/errors/system_error.d.ts +230 -0
- package/backend/dist/esm/backend/src/errors/system_error.js +402 -0
- package/backend/dist/esm/backend/src/events.d.ts +54 -0
- package/backend/dist/esm/backend/src/events.js +5 -0
- package/backend/dist/esm/{frontend.js → backend/src/frontend.js} +1 -1
- package/backend/dist/esm/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
- package/backend/dist/esm/{image_endpoint.js → backend/src/image_endpoint.js} +16 -20
- package/backend/dist/esm/backend/src/logger.d.ts +5 -0
- package/backend/dist/esm/backend/src/logger.js +8 -0
- package/backend/dist/esm/backend/src/meta.d.ts +64 -0
- package/backend/dist/esm/{meta.js → backend/src/meta.js} +15 -54
- package/backend/dist/esm/backend/src/payments/paddle.d.ts +326 -0
- package/backend/dist/esm/{payments → backend/src/payments}/paddle.js +417 -452
- package/backend/dist/esm/backend/src/plugins/browser.d.ts +1 -0
- package/backend/dist/esm/backend/src/plugins/browser.js +170 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +248 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.js +389 -0
- package/backend/dist/{cjs → esm/backend/src}/plugins/mail/ui.d.ts +23 -0
- package/backend/dist/esm/{plugins → backend/src/plugins}/mail/ui.js +3 -6
- package/backend/dist/esm/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/esm/{plugins → backend/src/plugins}/pdf.js +3 -3
- package/backend/dist/esm/backend/src/rate_limit.d.ts +145 -0
- package/backend/dist/esm/backend/src/rate_limit.js +667 -0
- package/backend/dist/esm/{route.d.ts → backend/src/route.d.ts} +3 -10
- package/backend/dist/esm/{route.js → backend/src/route.js} +26 -21
- package/backend/dist/esm/backend/src/server.d.ts +485 -0
- package/backend/dist/esm/{server.js → backend/src/server.js} +891 -1441
- package/backend/dist/esm/backend/src/splash_screen.d.ts +80 -0
- package/backend/dist/esm/{splash_screen.js → backend/src/splash_screen.js} +42 -55
- package/backend/dist/esm/backend/src/status.d.ts +74 -0
- package/backend/dist/esm/backend/src/status.js +199 -0
- package/backend/dist/esm/backend/src/stream.d.ts +376 -0
- package/backend/dist/esm/{stream.js → backend/src/stream.js} +327 -292
- package/backend/dist/esm/backend/src/users.d.ts +809 -0
- package/backend/dist/esm/backend/src/users.js +2140 -0
- package/backend/dist/esm/backend/src/utils.d.ts +16 -0
- package/backend/dist/esm/{utils.js → backend/src/utils.js} +20 -81
- package/backend/dist/{cjs → esm/backend/src}/view.d.ts +33 -11
- package/backend/dist/esm/{view.js → backend/src/view.js} +266 -86
- package/backend/dist/{cjs → esm/backend/src}/volt.d.ts +10 -1
- package/backend/dist/esm/{volt.js → backend/src/volt.js} +7 -4
- package/backend/dist/esm/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/esm/frontend/src/modules/request.js +117 -0
- package/frontend/dist/backend/src/database/collection.d.ts +1543 -0
- package/frontend/dist/backend/src/database/collection.js +3510 -0
- package/frontend/dist/backend/src/database/database.d.ts +66 -0
- package/frontend/dist/backend/src/database/database.js +196 -0
- package/frontend/dist/backend/src/database/filters/filters.d.ts +6 -0
- package/frontend/dist/backend/src/database/filters/filters.js +1 -0
- package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/frontend/dist/backend/src/database/filters/strict_filter.js +3 -0
- package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/frontend/dist/backend/src/database/filters/strict_update_filter.js +5 -0
- package/frontend/dist/backend/src/database/flatten.d.ts +75 -0
- package/frontend/dist/backend/src/database/flatten.js +22 -0
- package/frontend/dist/backend/src/endpoint.d.ts +204 -0
- package/frontend/dist/backend/src/endpoint.js +570 -0
- package/frontend/dist/backend/src/errors/index.d.ts +7 -0
- package/frontend/dist/backend/src/errors/index.js +7 -0
- package/frontend/dist/backend/src/errors/internal_external.d.ts +38 -0
- package/frontend/dist/backend/src/errors/internal_external.js +70 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.js +30 -0
- package/frontend/dist/backend/src/errors/system_error.d.ts +230 -0
- package/frontend/dist/backend/src/errors/system_error.js +402 -0
- package/frontend/dist/backend/src/events.d.ts +54 -0
- package/frontend/dist/backend/src/events.js +5 -0
- package/frontend/dist/backend/src/frontend.d.ts +11 -0
- package/frontend/dist/backend/src/frontend.js +12 -0
- package/frontend/dist/backend/src/image_endpoint.d.ts +39 -0
- package/frontend/dist/backend/src/image_endpoint.js +202 -0
- package/frontend/dist/backend/src/meta.d.ts +64 -0
- package/frontend/dist/backend/src/meta.js +110 -0
- package/frontend/dist/backend/src/payments/paddle.d.ts +326 -0
- package/frontend/dist/backend/src/payments/paddle.js +2256 -0
- package/frontend/dist/backend/src/plugins/mail/mail.d.ts +248 -0
- package/frontend/dist/backend/src/plugins/mail/mail.js +389 -0
- package/{backend/dist/esm/plugins/mail.d.ts → frontend/dist/backend/src/plugins/mail/ui.d.ts} +23 -0
- package/{backend/dist/esm/plugins/mail.js → frontend/dist/backend/src/plugins/mail/ui.js} +3 -6
- package/frontend/dist/backend/src/rate_limit.d.ts +145 -0
- package/frontend/dist/backend/src/rate_limit.js +673 -0
- package/frontend/dist/backend/src/route.d.ts +35 -0
- package/frontend/dist/backend/src/route.js +212 -0
- package/frontend/dist/backend/src/server.d.ts +485 -0
- package/frontend/dist/backend/src/server.js +2670 -0
- package/frontend/dist/backend/src/splash_screen.d.ts +80 -0
- package/frontend/dist/backend/src/splash_screen.js +135 -0
- package/frontend/dist/backend/src/status.d.ts +74 -0
- package/frontend/dist/backend/src/status.js +199 -0
- package/frontend/dist/backend/src/stream.d.ts +376 -0
- package/frontend/dist/backend/src/stream.js +1007 -0
- package/frontend/dist/backend/src/users.d.ts +807 -0
- package/frontend/dist/backend/src/users.js +2118 -0
- package/frontend/dist/backend/src/utils.d.ts +16 -0
- package/frontend/dist/backend/src/utils.js +241 -0
- package/frontend/dist/backend/src/view.d.ts +162 -0
- package/frontend/dist/backend/src/view.js +720 -0
- package/frontend/dist/frontend/src/elements/base.d.ts +4414 -0
- package/frontend/dist/{elements → frontend/src/elements}/base.js +3624 -260
- package/frontend/dist/frontend/src/elements/module.d.ts +95 -0
- package/frontend/dist/{elements → frontend/src/elements}/module.js +53 -52
- package/frontend/dist/frontend/src/elements/types.d.ts +52 -0
- package/frontend/dist/frontend/src/elements/types.js +5 -0
- package/frontend/dist/frontend/src/modules/attachment.d.ts +126 -0
- package/frontend/dist/frontend/src/modules/attachment.js +306 -0
- package/frontend/dist/frontend/src/modules/auth.d.ts +44 -0
- package/frontend/dist/frontend/src/modules/auth.js +80 -0
- package/frontend/dist/{modules → frontend/src/modules}/color.js +2 -2
- package/frontend/dist/frontend/src/modules/compression.d.ts +39 -0
- package/frontend/dist/frontend/src/modules/compression.js +102 -0
- package/frontend/dist/frontend/src/modules/cookies.d.ts +44 -0
- package/frontend/dist/frontend/src/modules/cookies.js +143 -0
- package/frontend/dist/frontend/src/modules/events.d.ts +31 -0
- package/frontend/dist/frontend/src/modules/events.js +74 -0
- package/frontend/dist/frontend/src/modules/google.d.ts +23 -0
- package/frontend/dist/frontend/src/modules/google.js +52 -0
- package/frontend/dist/frontend/src/modules/meta.d.ts +14 -0
- package/frontend/dist/{modules → frontend/src/modules}/meta.js +9 -7
- package/frontend/dist/{modules → frontend/src/modules}/paddle.d.ts +37 -134
- package/frontend/dist/{modules → frontend/src/modules}/paddle.js +620 -568
- package/frontend/dist/frontend/src/modules/request.d.ts +70 -0
- package/frontend/dist/frontend/src/modules/request.js +117 -0
- package/frontend/dist/frontend/src/modules/settings.d.ts +3 -0
- package/frontend/dist/frontend/src/modules/settings.js +5 -0
- package/frontend/dist/frontend/src/modules/statics.d.ts +21 -0
- package/frontend/dist/{modules → frontend/src/modules}/statics.js +15 -18
- package/frontend/dist/frontend/src/modules/support.d.ts +30 -0
- package/frontend/dist/frontend/src/modules/support.js +53 -0
- package/frontend/dist/{modules → frontend/src/modules}/theme.d.ts +67 -0
- package/frontend/dist/{modules → frontend/src/modules}/theme.js +68 -38
- package/frontend/dist/frontend/src/modules/themes.d.ts +12 -0
- package/frontend/dist/frontend/src/modules/themes.js +22 -0
- package/frontend/dist/frontend/src/modules/user.d.ts +164 -0
- package/frontend/dist/frontend/src/modules/user.js +268 -0
- package/frontend/dist/frontend/src/modules/utils.d.ts +176 -0
- package/frontend/dist/frontend/src/modules/utils.js +569 -0
- package/frontend/dist/frontend/src/types/gradient.d.ts +29 -0
- package/frontend/dist/{types → frontend/src/types}/gradient.js +14 -18
- package/frontend/dist/frontend/src/ui/border_button.d.ts +94 -0
- package/frontend/dist/{ui → frontend/src/ui}/border_button.js +7 -13
- package/frontend/dist/frontend/src/ui/button.d.ts +28 -0
- package/frontend/dist/{ui → frontend/src/ui}/button.js +21 -12
- package/frontend/dist/frontend/src/ui/canvas.d.ts +138 -0
- package/frontend/dist/{ui → frontend/src/ui}/canvas.js +88 -55
- package/frontend/dist/frontend/src/ui/checkbox.d.ts +74 -0
- package/frontend/dist/{ui → frontend/src/ui}/checkbox.js +80 -41
- package/frontend/dist/{ui → frontend/src/ui}/code.d.ts +73 -6
- package/frontend/dist/{ui → frontend/src/ui}/code.js +55 -52
- package/frontend/dist/{ui → frontend/src/ui}/context_menu.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/context_menu.js +12 -17
- package/frontend/dist/{ui → frontend/src/ui}/css.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/css.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/divider.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/divider.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/dropdown.d.ts +57 -2
- package/frontend/dist/{ui → frontend/src/ui}/dropdown.js +87 -94
- package/frontend/dist/{ui → frontend/src/ui}/for_each.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/for_each.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/form.d.ts +6 -2
- package/frontend/dist/{ui → frontend/src/ui}/form.js +10 -7
- package/frontend/dist/frontend/src/ui/frame_modes.d.ts +37 -0
- package/frontend/dist/{ui → frontend/src/ui}/frame_modes.js +16 -22
- package/frontend/dist/{ui → frontend/src/ui}/google_map.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/google_map.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/gradient.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/gradient.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/image.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/image.js +5 -5
- package/frontend/dist/frontend/src/ui/input.d.ts +392 -0
- package/frontend/dist/{ui → frontend/src/ui}/input.js +346 -360
- package/frontend/dist/{ui → frontend/src/ui}/link.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/link.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/list.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/list.js +12 -6
- package/frontend/dist/frontend/src/ui/loader_button.d.ts +80 -0
- package/frontend/dist/{ui → frontend/src/ui}/loader_button.js +35 -47
- package/frontend/dist/frontend/src/ui/loaders.d.ts +57 -0
- package/frontend/dist/{ui → frontend/src/ui}/loaders.js +11 -11
- package/frontend/dist/{ui → frontend/src/ui}/popup.d.ts +11 -6
- package/frontend/dist/{ui → frontend/src/ui}/popup.js +32 -18
- package/frontend/dist/frontend/src/ui/pseudo.d.ts +44 -0
- package/frontend/dist/{ui → frontend/src/ui}/pseudo.js +84 -8
- package/frontend/dist/{ui → frontend/src/ui}/scroller.d.ts +14 -2
- package/frontend/dist/{ui → frontend/src/ui}/scroller.js +37 -43
- package/frontend/dist/{ui → frontend/src/ui}/slider.d.ts +5 -1
- package/frontend/dist/{ui → frontend/src/ui}/slider.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/spacer.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/spacer.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/span.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/span.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/stack.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/stack.js +3 -9
- package/frontend/dist/frontend/src/ui/steps.d.ts +131 -0
- package/frontend/dist/{ui → frontend/src/ui}/steps.js +30 -45
- package/frontend/dist/{ui → frontend/src/ui}/style.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/style.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/switch.d.ts +5 -1
- package/frontend/dist/{ui → frontend/src/ui}/switch.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/table.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/table.js +6 -6
- package/frontend/dist/{ui → frontend/src/ui}/tabs.d.ts +45 -3
- package/frontend/dist/{ui → frontend/src/ui}/tabs.js +65 -40
- package/frontend/dist/{ui → frontend/src/ui}/text.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/text.js +3 -3
- package/frontend/dist/frontend/src/ui/title.d.ts +91 -0
- package/frontend/dist/frontend/src/ui/title.js +272 -0
- package/frontend/dist/{ui → frontend/src/ui}/view.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/view.js +3 -3
- package/frontend/dist/{volt.d.ts → frontend/src/volt.d.ts} +3 -0
- package/frontend/dist/{volt.js → frontend/src/volt.js} +4 -0
- package/frontend/tools/bundle_d_ts.js +71 -0
- package/frontend/tools/convert_to_jsdoc_input.txt +9452 -0
- package/frontend/tools/convert_to_jsdoc_output.txt +7626 -0
- package/frontend/tools/convert_to_jsdoc_tmp.js +345 -0
- package/package.json +11 -12
- package/backend/dist/cjs/database/collection.d.ts +0 -160
- package/backend/dist/cjs/database/collection.js +0 -842
- package/backend/dist/cjs/database/database.d.ts +0 -121
- package/backend/dist/cjs/database/document.d.ts +0 -131
- package/backend/dist/cjs/database/document.js +0 -224
- package/backend/dist/cjs/database.d.ts +0 -502
- package/backend/dist/cjs/database.js +0 -2248
- package/backend/dist/cjs/logger.d.ts +0 -3
- package/backend/dist/cjs/meta.d.ts +0 -50
- package/backend/dist/cjs/mutex.d.ts +0 -24
- package/backend/dist/cjs/payments/paddle.d.ts +0 -160
- package/backend/dist/cjs/plugins/browser.d.ts +0 -36
- package/backend/dist/cjs/plugins/browser.js +0 -198
- package/backend/dist/cjs/plugins/css.d.ts +0 -11
- package/backend/dist/cjs/plugins/css.js +0 -80
- package/backend/dist/cjs/plugins/mail.d.ts +0 -277
- package/backend/dist/cjs/plugins/mail.js +0 -1370
- package/backend/dist/cjs/plugins/ts/compiler.d.ts +0 -139
- package/backend/dist/cjs/plugins/ts/compiler.js +0 -750
- package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +0 -14
- package/backend/dist/cjs/plugins/ts/preprocessing.js +0 -440
- package/backend/dist/cjs/rate_limit.d.ts +0 -63
- package/backend/dist/cjs/rate_limit.js +0 -348
- package/backend/dist/cjs/request.deprc.d.ts +0 -48
- package/backend/dist/cjs/request.deprc.js +0 -572
- package/backend/dist/cjs/response.deprc.d.ts +0 -55
- package/backend/dist/cjs/response.deprc.js +0 -275
- package/backend/dist/cjs/server.d.ts +0 -342
- package/backend/dist/cjs/splash_screen.d.ts +0 -35
- package/backend/dist/cjs/status.d.ts +0 -61
- package/backend/dist/cjs/stream.d.ts +0 -79
- package/backend/dist/cjs/users.d.ts +0 -111
- package/backend/dist/cjs/users.js +0 -1817
- package/backend/dist/cjs/view.js +0 -352
- package/backend/dist/cjs/vinc.dev.d.ts +0 -3
- package/backend/dist/cjs/vinc.dev.js +0 -7
- package/backend/dist/css/adyen.css +0 -92
- package/backend/dist/css/volt.css +0 -70
- package/backend/dist/esm/database/collection.d.ts +0 -160
- package/backend/dist/esm/database/collection.js +0 -1328
- package/backend/dist/esm/database/database.d.ts +0 -121
- package/backend/dist/esm/database/document.d.ts +0 -131
- package/backend/dist/esm/database/document.js +0 -247
- package/backend/dist/esm/database.d.ts +0 -502
- package/backend/dist/esm/database.js +0 -2423
- package/backend/dist/esm/file_watcher.js +0 -329
- package/backend/dist/esm/logger.d.ts +0 -3
- package/backend/dist/esm/logger.js +0 -11
- package/backend/dist/esm/meta.d.ts +0 -50
- package/backend/dist/esm/mutex.d.ts +0 -24
- package/backend/dist/esm/mutex.js +0 -48
- package/backend/dist/esm/payments/paddle.d.ts +0 -160
- package/backend/dist/esm/plugins/browser.d.ts +0 -36
- package/backend/dist/esm/plugins/browser.js +0 -176
- package/backend/dist/esm/plugins/css.d.ts +0 -11
- package/backend/dist/esm/plugins/css.js +0 -90
- package/backend/dist/esm/plugins/ts/compiler.d.ts +0 -139
- package/backend/dist/esm/plugins/ts/compiler.js +0 -1194
- package/backend/dist/esm/plugins/ts/preprocessing.d.ts +0 -14
- package/backend/dist/esm/plugins/ts/preprocessing.js +0 -726
- package/backend/dist/esm/rate_limit.d.ts +0 -63
- package/backend/dist/esm/rate_limit.js +0 -417
- package/backend/dist/esm/request.deprc.d.ts +0 -48
- package/backend/dist/esm/request.deprc.js +0 -572
- package/backend/dist/esm/response.deprc.d.ts +0 -55
- package/backend/dist/esm/response.deprc.js +0 -275
- package/backend/dist/esm/server.d.ts +0 -342
- package/backend/dist/esm/splash_screen.d.ts +0 -35
- package/backend/dist/esm/status.d.ts +0 -61
- package/backend/dist/esm/status.js +0 -197
- package/backend/dist/esm/stream.d.ts +0 -79
- package/backend/dist/esm/users.d.ts +0 -111
- package/backend/dist/esm/users.js +0 -1935
- package/backend/dist/esm/vinc.dev.d.ts +0 -3
- package/backend/dist/esm/vinc.dev.js +0 -7
- package/frontend/dist/elements/base.d.ts +0 -9889
- package/frontend/dist/elements/module.d.ts +0 -30
- package/frontend/dist/modules/array.d.ts +0 -94
- package/frontend/dist/modules/array.js +0 -634
- package/frontend/dist/modules/auth.d.ts +0 -46
- package/frontend/dist/modules/auth.js +0 -139
- package/frontend/dist/modules/colors.d.ts +0 -1
- package/frontend/dist/modules/colors.js +0 -417
- package/frontend/dist/modules/compression.d.ts +0 -6
- package/frontend/dist/modules/compression.js +0 -999
- package/frontend/dist/modules/cookies.d.ts +0 -18
- package/frontend/dist/modules/cookies.js +0 -167
- package/frontend/dist/modules/date.d.ts +0 -142
- package/frontend/dist/modules/date.js +0 -493
- package/frontend/dist/modules/events.d.ts +0 -8
- package/frontend/dist/modules/events.js +0 -91
- package/frontend/dist/modules/google.d.ts +0 -11
- package/frontend/dist/modules/google.js +0 -54
- package/frontend/dist/modules/meta.d.ts +0 -10
- package/frontend/dist/modules/mutex.d.ts +0 -7
- package/frontend/dist/modules/mutex.js +0 -51
- package/frontend/dist/modules/number.d.ts +0 -16
- package/frontend/dist/modules/number.js +0 -23
- package/frontend/dist/modules/object.d.ts +0 -52
- package/frontend/dist/modules/object.js +0 -383
- package/frontend/dist/modules/scheme.d.ts +0 -227
- package/frontend/dist/modules/scheme.js +0 -531
- package/frontend/dist/modules/settings.d.ts +0 -3
- package/frontend/dist/modules/settings.js +0 -4
- package/frontend/dist/modules/statics.d.ts +0 -5
- package/frontend/dist/modules/string.d.ts +0 -124
- package/frontend/dist/modules/string.js +0 -745
- package/frontend/dist/modules/support.d.ts +0 -19
- package/frontend/dist/modules/support.js +0 -103
- package/frontend/dist/modules/themes.d.ts +0 -8
- package/frontend/dist/modules/themes.js +0 -18
- package/frontend/dist/modules/user.d.ts +0 -59
- package/frontend/dist/modules/user.js +0 -280
- package/frontend/dist/modules/utils.d.ts +0 -87
- package/frontend/dist/modules/utils.js +0 -923
- package/frontend/dist/types/gradient.d.ts +0 -12
- package/frontend/dist/ui/border_button.d.ts +0 -152
- package/frontend/dist/ui/button.d.ts +0 -21
- package/frontend/dist/ui/canvas.d.ts +0 -56
- package/frontend/dist/ui/checkbox.d.ts +0 -52
- package/frontend/dist/ui/frame_modes.d.ts +0 -25
- package/frontend/dist/ui/input.d.ts +0 -241
- package/frontend/dist/ui/loader_button.d.ts +0 -93
- package/frontend/dist/ui/loaders.d.ts +0 -57
- package/frontend/dist/ui/pseudo.d.ts +0 -16
- package/frontend/dist/ui/steps.d.ts +0 -59
- package/frontend/dist/ui/title.d.ts +0 -21
- package/frontend/dist/ui/title.js +0 -121
- package/frontend/examples/dashboard/dashboard.ts +0 -776
- /package/backend/dist/cjs/{cli.d.ts → backend/src/cli.d.ts} +0 -0
- /package/backend/dist/cjs/{file_watcher.d.ts → backend/src/database/document.d.ts} +0 -0
- /package/backend/dist/cjs/{file_watcher.js → backend/src/database/document.js} +0 -0
- /package/backend/dist/cjs/{plugins/pdf.d.ts → backend/src/database/filters/strict_filter_test.d.ts} +0 -0
- /package/backend/dist/{esm/file_watcher.d.ts → cjs/backend/src/database/filters/strict_filter_test_v0.d.ts} +0 -0
- /package/backend/dist/{esm/plugins/pdf.d.ts → cjs/backend/src/database/flatten_test.d.ts} +0 -0
- /package/backend/dist/cjs/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.d.ts +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/mail/ui.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/pdf.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
- /package/backend/dist/cjs/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
- /package/backend/dist/cjs/{vinc.js → backend/src/vinc.js} +0 -0
- /package/backend/dist/esm/{cli.d.ts → backend/src/cli.d.ts} +0 -0
- /package/backend/dist/esm/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.d.ts +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.js +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
- /package/backend/dist/esm/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
- /package/backend/dist/esm/{vinc.js → backend/src/vinc.js} +0 -0
- /package/frontend/dist/{elements → frontend/src/elements}/register_element.d.ts +0 -0
- /package/frontend/dist/{elements → frontend/src/elements}/register_element.js +0 -0
- /package/frontend/dist/{modules → frontend/src/modules}/color.d.ts +0 -0
- /package/frontend/dist/{ui → frontend/src/ui}/ui.d.ts +0 -0
- /package/frontend/dist/{ui → frontend/src/ui}/ui.js +0 -0
|
@@ -1,143 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
1
|
+
/**
|
|
2
|
+
* @author Daan van den Bergh
|
|
3
|
+
* @copyright © 2022 - 2025 Daan van den Bergh. All rights reserved
|
|
4
4
|
*/
|
|
5
5
|
// Imports.
|
|
6
6
|
import * as https from "https";
|
|
7
7
|
import * as PDFDocument from "pdfkit";
|
|
8
8
|
import * as libcrypto from "crypto";
|
|
9
|
-
import blobstream from 'blob-stream';
|
|
10
9
|
import * as vlib from "@vandenberghinc/vlib";
|
|
11
|
-
import {
|
|
12
|
-
import { logger } from "../logger.js";
|
|
10
|
+
import { ExternalError } from "../errors/index.js";
|
|
13
11
|
import { Status } from "../status.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
import { Collection } from "../database/collection.js";
|
|
13
|
+
import { Utils } from "../utils.js";
|
|
14
|
+
/** Nested types for the {@link LineItem} interface. */
|
|
15
|
+
export var LineItem;
|
|
16
|
+
(function (LineItem) {
|
|
17
|
+
/** Validation schema. */
|
|
18
|
+
LineItem.Schema = {
|
|
19
|
+
product: "string",
|
|
20
|
+
item_id: "string",
|
|
21
|
+
paddle_prod_id: "string",
|
|
22
|
+
quantity: "number",
|
|
23
|
+
tax_rate: "number",
|
|
24
|
+
tax: "number",
|
|
25
|
+
discount: "number",
|
|
26
|
+
subtotal: "number",
|
|
27
|
+
total: "number",
|
|
28
|
+
status: { type: "string", enum: ["paid", "refunded", "refunding"] },
|
|
29
|
+
};
|
|
30
|
+
})(LineItem || (LineItem = {}));
|
|
31
|
+
export const PaymentStatusValues = ['open', 'paid', 'past_due', 'unknown'];
|
|
32
|
+
/** Nested types for the {@link Payment} interface. */
|
|
33
|
+
export var Payment;
|
|
34
|
+
(function (Payment) {
|
|
35
|
+
/**
|
|
36
|
+
* Check if a payment should be anonymized,
|
|
37
|
+
* if so return a public version of the payment.
|
|
38
|
+
*/
|
|
39
|
+
function anonymize(payment) {
|
|
40
|
+
if (!payment.uid || payment.uid === "unauth") {
|
|
41
|
+
const { billing_details, ...rest } = payment;
|
|
42
|
+
return {
|
|
43
|
+
...rest,
|
|
44
|
+
billing_details: undefined,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return payment;
|
|
21
48
|
}
|
|
22
|
-
|
|
49
|
+
Payment.anonymize = anonymize;
|
|
50
|
+
})(Payment || (Payment = {}));
|
|
23
51
|
// The paddle payments class.
|
|
24
52
|
// @todo check if a user can subscribe twice to a sub, should not be allowed for system logic.
|
|
25
53
|
// @todo still need to manage the reactivation of a subscription after a chargeback has been reversed.
|
|
26
54
|
// @todo still check if a subscription is automatically cancelled by paddle when it is refunded.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@name: api_key
|
|
37
|
-
@type: string
|
|
38
|
-
@description: Your paddle api key.
|
|
39
|
-
@required: true
|
|
40
|
-
@param:
|
|
41
|
-
@name: client_key
|
|
42
|
-
@type: string
|
|
43
|
-
@description: Your paddle client key.
|
|
44
|
-
@required: true
|
|
45
|
-
@param:
|
|
46
|
-
@name: sandbox
|
|
47
|
-
@type: boolean
|
|
48
|
-
@description: Enable the sandbox environment.
|
|
49
|
-
@param:
|
|
50
|
-
@name: inclusive_tax
|
|
51
|
-
@type: boolean
|
|
52
|
-
@description: Enable when prices are inclusive tax.
|
|
53
|
-
@param:
|
|
54
|
-
@name: products
|
|
55
|
-
@type: object
|
|
56
|
-
@warning: The payment product objects are accessable by anyone through the backend rest api so they should not contain any sensitive data.
|
|
57
|
-
@attributes_type: ProductObject
|
|
58
|
-
@attribute:
|
|
59
|
-
@name: id
|
|
60
|
-
@type: string
|
|
61
|
-
@required: true
|
|
62
|
-
@desc: The id of product
|
|
63
|
-
@warning: The id can not be changed
|
|
64
|
-
@warning: The id must be unique across all your products.
|
|
65
|
-
@attribute:
|
|
66
|
-
@name: name
|
|
67
|
-
@type: string
|
|
68
|
-
@required: true
|
|
69
|
-
@desc: The name of the product.
|
|
70
|
-
@attribute:
|
|
71
|
-
@name: price
|
|
72
|
-
@type: number
|
|
73
|
-
@required: true
|
|
74
|
-
@desc: The price of the product, digits after the decimal are the minor units (e.g. cents).
|
|
75
|
-
@attribute:
|
|
76
|
-
@name: currency
|
|
77
|
-
@type: string
|
|
78
|
-
@required: true
|
|
79
|
-
@desc: The ISO currency code of the price.
|
|
80
|
-
@attribute:
|
|
81
|
-
@name: tax_category
|
|
82
|
-
@type: string
|
|
83
|
-
@required: true
|
|
84
|
-
@desc: The tax category https://developer.paddle.com/api-reference/products/create-product.
|
|
85
|
-
@attribute:
|
|
86
|
-
@name: icon
|
|
87
|
-
@type: string
|
|
88
|
-
@desc: The icon url of the product, may also be an endpoint url of your website.
|
|
89
|
-
@attribute:
|
|
90
|
-
@name: frequency
|
|
91
|
-
@type: number
|
|
92
|
-
@desc: The recurring frequency, when this is defined a product will become a subscription product.
|
|
93
|
-
@attribute:
|
|
94
|
-
@name: interval
|
|
95
|
-
@type: string
|
|
96
|
-
@desc: The recurring interval, when this is defined a product will become a subscription product.
|
|
97
|
-
@enum:
|
|
98
|
-
@value: "day"
|
|
99
|
-
@desc: Use this value to create a subscription product that renews at a daily interval.
|
|
100
|
-
@enum:
|
|
101
|
-
@value: "week"
|
|
102
|
-
@desc: Use this value to create a subscription product that renews at a weekly interval.
|
|
103
|
-
@enum:
|
|
104
|
-
@value: "month"
|
|
105
|
-
@desc: Use this value to create a subscription product that renews at a monthly interval.
|
|
106
|
-
@enum:
|
|
107
|
-
@value: "year"
|
|
108
|
-
@desc: Use this value to create a subscription product that renews at a yearly interval.
|
|
109
|
-
@attribute:
|
|
110
|
-
@name: trial
|
|
111
|
-
@type: null, object
|
|
112
|
-
@desc: The trial settings for this product. Leave undefined to disable a trialing period. This attribute will be ignored for one-time payments.
|
|
113
|
-
@attribute:
|
|
114
|
-
@name: frequency
|
|
115
|
-
@type: number
|
|
116
|
-
@desc: The trial frequency.
|
|
117
|
-
@attribute:
|
|
118
|
-
@name: interval
|
|
119
|
-
@type: string
|
|
120
|
-
@desc: The trial interval.
|
|
121
|
-
@enum:
|
|
122
|
-
@value: "day"
|
|
123
|
-
@desc: Daily interval.
|
|
124
|
-
@enum:
|
|
125
|
-
@value: "week"
|
|
126
|
-
@desc: Weekly interval.
|
|
127
|
-
@enum:
|
|
128
|
-
@value: "month"
|
|
129
|
-
@desc: Monthly interval.
|
|
130
|
-
@enum:
|
|
131
|
-
@value: "year"
|
|
132
|
-
@desc: Yearly interval.
|
|
133
|
-
@attribute:
|
|
134
|
-
@name: plans
|
|
135
|
-
@type: array[ProductObject]
|
|
136
|
-
@desc: The plans for this subscription product. Every item is a product object. However, attributes `currency`, `frequency`, `interval`, `tax_category` and `icon` can either be defined in the subscription product or on each individual plan.
|
|
137
|
-
@parameter:
|
|
138
|
-
@name: _server
|
|
139
|
-
@ignore: true
|
|
140
|
-
*/
|
|
55
|
+
/**
|
|
56
|
+
* The paddle payments class.
|
|
57
|
+
*
|
|
58
|
+
* Sandbox env: https://sandbox-vendors.paddle.com
|
|
59
|
+
*
|
|
60
|
+
* @nav Backend/Payments
|
|
61
|
+
* @docs
|
|
62
|
+
* @deprecated Using stripe from now on.
|
|
63
|
+
*/
|
|
141
64
|
export class Paddle {
|
|
142
65
|
type;
|
|
143
66
|
client_key;
|
|
@@ -149,16 +72,21 @@ export class Paddle {
|
|
|
149
72
|
_headers;
|
|
150
73
|
webhook_key;
|
|
151
74
|
_has_create_products_permission;
|
|
152
|
-
|
|
75
|
+
_last_products_db;
|
|
76
|
+
_webhook_conf_db;
|
|
153
77
|
_sub_db;
|
|
154
78
|
_active_sub_db;
|
|
155
79
|
_pay_db;
|
|
156
|
-
// private _inv_db
|
|
80
|
+
// private _inv_db: Collection;
|
|
157
81
|
performance;
|
|
158
|
-
constructor({ api_key, client_key, sandbox = false, products = [], inclusive_tax = false, _server
|
|
82
|
+
constructor({ api_key, client_key, sandbox = false, products = [], inclusive_tax = false, _server, }) {
|
|
159
83
|
// Original constructor implementation remains the same
|
|
160
84
|
// Verify args.
|
|
161
|
-
vlib.
|
|
85
|
+
vlib.schema.validate(arguments[0], {
|
|
86
|
+
unknown: false,
|
|
87
|
+
throw: true,
|
|
88
|
+
parent: "payments",
|
|
89
|
+
schema: {
|
|
162
90
|
type: { type: "string", default: "paddle" },
|
|
163
91
|
api_key: "string",
|
|
164
92
|
client_key: "string",
|
|
@@ -166,7 +94,8 @@ export class Paddle {
|
|
|
166
94
|
inclusive_tax: { type: "boolean", default: false },
|
|
167
95
|
products: "array",
|
|
168
96
|
_server: "object",
|
|
169
|
-
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
170
99
|
// Attributes.
|
|
171
100
|
this.type = "paddle";
|
|
172
101
|
this.client_key = client_key;
|
|
@@ -186,6 +115,31 @@ export class Paddle {
|
|
|
186
115
|
this.server.csp["script-src"] += " https://*.paddle.com/ https://*.payments-amazon.com https://*.paypal.com https://*.google.com";
|
|
187
116
|
this.server.csp["style-src"] += " https://*.paddle.com/ https://*.media-amazon.com https://*.paypal.com https://*.google.com";
|
|
188
117
|
this.server.csp["img-src"] += " https://*.paddle.com/ https://*.media-amazon.com https://*.paypal.com https://*.google.com";
|
|
118
|
+
// Create database collections.
|
|
119
|
+
this._last_products_db = this.server.db.collection({
|
|
120
|
+
name: "Volt.Paddle.LastProducts",
|
|
121
|
+
indexes: ["production", "version"],
|
|
122
|
+
});
|
|
123
|
+
this._webhook_conf_db = this.server.db.collection({
|
|
124
|
+
name: "Volt.Paddle.WebhookConfig",
|
|
125
|
+
indexes: ["production", "version"],
|
|
126
|
+
});
|
|
127
|
+
this._sub_db = this.server.db.collection({
|
|
128
|
+
name: "Volt.Paddle.Subscriptions",
|
|
129
|
+
indexes: ["uid", "id"],
|
|
130
|
+
});
|
|
131
|
+
this._active_sub_db = this.server.db.collection({
|
|
132
|
+
name: "Volt.Paddle.ActiveSubscriptions",
|
|
133
|
+
indexes: ["uid", "prod_id"],
|
|
134
|
+
});
|
|
135
|
+
this._pay_db = this.server.db.collection({
|
|
136
|
+
name: "Volt.Paddle.Payments",
|
|
137
|
+
indexes: ["uid", "id", "tran_id"],
|
|
138
|
+
});
|
|
139
|
+
// this._inv_db = this.server.db.collection({
|
|
140
|
+
// name: "Volt.Paddle.Invoices",
|
|
141
|
+
// indexes: ["uid", "id", "tran_id" ],
|
|
142
|
+
// });
|
|
189
143
|
/* @performance */ this.performance = new vlib.Performance("Payments performance");
|
|
190
144
|
}
|
|
191
145
|
// ---------------------------------------------------------
|
|
@@ -194,11 +148,28 @@ export class Paddle {
|
|
|
194
148
|
// Utils (private).
|
|
195
149
|
async _req(method, endpoint, params = null) {
|
|
196
150
|
const promise = new Promise((resolve, reject) => {
|
|
151
|
+
// Build hostname + path for both relative and absolute endpoints.
|
|
152
|
+
const is_get_like = method === "GET" || method === "HEAD";
|
|
153
|
+
let hostname = this._host;
|
|
154
|
+
let path = endpoint;
|
|
155
|
+
try {
|
|
156
|
+
if (/^https?:\/\//i.test(endpoint)) {
|
|
157
|
+
const u = new URL(endpoint);
|
|
158
|
+
hostname = u.hostname;
|
|
159
|
+
path = u.pathname + u.search;
|
|
160
|
+
}
|
|
161
|
+
else if (is_get_like && params != null) {
|
|
162
|
+
path = `${endpoint}?${new URLSearchParams(params).toString()}`;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
// fall back to original host + endpoint
|
|
167
|
+
}
|
|
197
168
|
// Options.
|
|
198
169
|
const options = {
|
|
199
170
|
method: method,
|
|
200
|
-
hostname
|
|
201
|
-
path
|
|
171
|
+
hostname,
|
|
172
|
+
path,
|
|
202
173
|
port: 443,
|
|
203
174
|
headers: this._headers,
|
|
204
175
|
};
|
|
@@ -211,7 +182,7 @@ export class Paddle {
|
|
|
211
182
|
response.on('end', () => {
|
|
212
183
|
if (response?.statusCode >= 200 && response?.statusCode < 300) {
|
|
213
184
|
try {
|
|
214
|
-
resolve(JSON.parse(data));
|
|
185
|
+
resolve(data ? JSON.parse(data) : {});
|
|
215
186
|
}
|
|
216
187
|
catch (error) {
|
|
217
188
|
reject(new Error('Failed to parse response data'));
|
|
@@ -219,16 +190,16 @@ export class Paddle {
|
|
|
219
190
|
}
|
|
220
191
|
else {
|
|
221
192
|
if (data == null || data === "") {
|
|
222
|
-
return reject(new RequestError(`${method}:${endpoint}: Request failed [${response.statusCode}].`, response.statusCode));
|
|
193
|
+
return reject(new Paddle.RequestError(`${method}:${endpoint}: Request failed [${response.statusCode}].`, response.statusCode));
|
|
223
194
|
}
|
|
224
195
|
try {
|
|
225
196
|
data = JSON.parse(data);
|
|
226
197
|
}
|
|
227
198
|
catch (e) {
|
|
228
|
-
return reject(new RequestError(`${method}:${endpoint}: Request failed [${response.statusCode}].`, response.statusCode));
|
|
199
|
+
return reject(new Paddle.RequestError(`${method}:${endpoint}: Request failed [${response.statusCode}].`, response.statusCode));
|
|
229
200
|
}
|
|
230
201
|
if (data.error == null) {
|
|
231
|
-
return reject(new RequestError(`${method}:${endpoint}: Request failed [${response.statusCode}].`, response.statusCode));
|
|
202
|
+
return reject(new Paddle.RequestError(`${method}:${endpoint}: Request failed [${response.statusCode}].`, response.statusCode));
|
|
232
203
|
}
|
|
233
204
|
data = data.error;
|
|
234
205
|
let errs = "";
|
|
@@ -239,12 +210,12 @@ export class Paddle {
|
|
|
239
210
|
});
|
|
240
211
|
errs = errs.substr(0, errs.length - 2);
|
|
241
212
|
}
|
|
242
|
-
return reject(new RequestError(`${method}:${endpoint}: ${data.detail} [${response.statusCode}]${errs}.`, response.statusCode));
|
|
213
|
+
return reject(new Paddle.RequestError(`${method}:${endpoint}: ${data.detail} [${response.statusCode}]${errs}.`, response.statusCode));
|
|
243
214
|
}
|
|
244
215
|
});
|
|
245
216
|
});
|
|
246
217
|
// Write body params.
|
|
247
|
-
if (params != null) {
|
|
218
|
+
if (!is_get_like && params != null) {
|
|
248
219
|
// request.write(JSON.stringify(params));
|
|
249
220
|
const requestBody = JSON.stringify(params);
|
|
250
221
|
request.setHeader('Content-Length', Buffer.byteLength(requestBody));
|
|
@@ -262,7 +233,7 @@ export class Paddle {
|
|
|
262
233
|
return await promise;
|
|
263
234
|
}
|
|
264
235
|
catch (e) {
|
|
265
|
-
if (e instanceof Error || e instanceof RequestError) {
|
|
236
|
+
if (e instanceof Error || e instanceof Paddle.RequestError) {
|
|
266
237
|
throw e;
|
|
267
238
|
}
|
|
268
239
|
throw new Error(e);
|
|
@@ -272,33 +243,25 @@ export class Paddle {
|
|
|
272
243
|
// Database (private).
|
|
273
244
|
// Add or remove a subscription to the user's active subscriptions.
|
|
274
245
|
async _add_subscription(uid, prod_id, sub_id) {
|
|
275
|
-
await this._active_sub_db.
|
|
246
|
+
await this._active_sub_db.set({ uid, prod_id }, { prod_id, sub_id });
|
|
276
247
|
}
|
|
277
248
|
async _delete_subscription(uid, prod_id) {
|
|
278
249
|
await this._active_sub_db.delete({ uid, prod_id });
|
|
279
250
|
}
|
|
280
251
|
async _check_subscription(uid, prod_id, load_data = false) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if (load_data) {
|
|
285
|
-
return { exists, sub_id };
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
return exists;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
exists = true;
|
|
292
|
-
sub_id = doc.sub_id;
|
|
293
|
-
if (load_data) {
|
|
294
|
-
return { exists, sub_id };
|
|
252
|
+
try {
|
|
253
|
+
const doc = await this._active_sub_db.load({ uid, prod_id });
|
|
254
|
+
return load_data ? { exists: true, sub_id: doc.sub_id } : true;
|
|
295
255
|
}
|
|
296
|
-
|
|
297
|
-
|
|
256
|
+
catch (err) {
|
|
257
|
+
if (err instanceof Collection.NotFoundError) {
|
|
258
|
+
return load_data ? { exists: false, sub_id: undefined } : false;
|
|
259
|
+
}
|
|
260
|
+
throw err;
|
|
298
261
|
}
|
|
299
262
|
}
|
|
300
263
|
async _get_active_subscriptions(uid, detailed = false) {
|
|
301
|
-
const list = await this._active_sub_db.
|
|
264
|
+
const list = await this._active_sub_db.list({ uid: uid });
|
|
302
265
|
if (detailed) {
|
|
303
266
|
return list;
|
|
304
267
|
}
|
|
@@ -309,52 +272,40 @@ export class Paddle {
|
|
|
309
272
|
return products;
|
|
310
273
|
}
|
|
311
274
|
async _save_subscription(subscription) {
|
|
312
|
-
await this._sub_db.
|
|
275
|
+
await this._sub_db.set({
|
|
313
276
|
uid: subscription.uid == null ? "unauth" : subscription.uid,
|
|
314
277
|
id: subscription.id,
|
|
315
278
|
}, subscription);
|
|
316
279
|
}
|
|
317
280
|
async _load_subscription(id) {
|
|
318
|
-
|
|
319
|
-
if (subscription == null) {
|
|
320
|
-
throw Error(`Unable to find subscription "${id}".`);
|
|
321
|
-
}
|
|
322
|
-
return subscription;
|
|
281
|
+
return await this._sub_db.load({ id: id }, { retry: 3 });
|
|
323
282
|
}
|
|
324
283
|
async _get_subscriptions(uid) {
|
|
325
284
|
if (uid === "unauth" || uid == null) {
|
|
326
285
|
return [];
|
|
327
286
|
}
|
|
328
|
-
const list = await this._sub_db.
|
|
287
|
+
const list = await this._sub_db.list({ uid: uid });
|
|
329
288
|
return list;
|
|
330
289
|
}
|
|
331
290
|
// Save and delete payments, all failed payments should be deleted from the database.
|
|
332
291
|
async _save_payment(payment) {
|
|
333
|
-
await this._pay_db.
|
|
292
|
+
await this._pay_db.set({
|
|
334
293
|
uid: payment.uid == null ? "unauth" : payment.uid,
|
|
335
294
|
id: payment.id,
|
|
336
295
|
}, payment);
|
|
337
296
|
}
|
|
338
297
|
async _load_payment(id) {
|
|
339
298
|
const uid = id.split("_")[1];
|
|
340
|
-
|
|
341
|
-
if (payment == null) {
|
|
342
|
-
throw Error(`Unable to find payment "${id}".`);
|
|
343
|
-
}
|
|
344
|
-
if (uid == null || uid == "unauth") {
|
|
345
|
-
delete payment.billing_details;
|
|
346
|
-
}
|
|
347
|
-
return payment;
|
|
299
|
+
return await this._pay_db.load({ uid, id });
|
|
348
300
|
}
|
|
349
|
-
async
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
return payment;
|
|
301
|
+
async _load_payment_for_public(id) {
|
|
302
|
+
return Payment.anonymize(await this._load_payment(id));
|
|
303
|
+
}
|
|
304
|
+
async _load_payment_by_transaction(tran_id) {
|
|
305
|
+
return await this._pay_db.load({ tran_id: tran_id }, { retry: 3 });
|
|
306
|
+
}
|
|
307
|
+
async _load_payment_by_transaction_for_public(tran_id) {
|
|
308
|
+
return Payment.anonymize(await this._load_payment_by_transaction(tran_id));
|
|
358
309
|
}
|
|
359
310
|
async _delete_payment(id) {
|
|
360
311
|
const uid = id.split("_")[1];
|
|
@@ -362,14 +313,14 @@ export class Paddle {
|
|
|
362
313
|
}
|
|
363
314
|
// Delete all info of a user.
|
|
364
315
|
async _delete_user(uid) {
|
|
365
|
-
await this._sub_db.
|
|
366
|
-
await this._active_sub_db.
|
|
367
|
-
await this._pay_db.
|
|
316
|
+
await this._sub_db.delete_many({ uid });
|
|
317
|
+
await this._active_sub_db.delete_many({ uid });
|
|
318
|
+
await this._pay_db.delete_many({ uid });
|
|
368
319
|
// await this._inv_db.delete_all({ uid });
|
|
369
320
|
}
|
|
370
321
|
// List all active subscriptions.
|
|
371
322
|
async _get_all_active_subscriptions() {
|
|
372
|
-
return await this._active_sub_db.
|
|
323
|
+
return await this._active_sub_db.list_all();
|
|
373
324
|
}
|
|
374
325
|
// ---------------------------------------------------------
|
|
375
326
|
// Overall (private).
|
|
@@ -444,8 +395,8 @@ export class Paddle {
|
|
|
444
395
|
if (process.argv.includes("--no-payment-edits")) {
|
|
445
396
|
return false;
|
|
446
397
|
}
|
|
447
|
-
if (this._has_create_products_permission) {
|
|
448
|
-
return
|
|
398
|
+
if (this._has_create_products_permission != null) {
|
|
399
|
+
return this._has_create_products_permission;
|
|
449
400
|
}
|
|
450
401
|
const input = await vlib.logging.prompt("Some paddle products have to be edited, do you wish to make these changes? [y/n]: ");
|
|
451
402
|
if (["y", "yes", "ok"].includes(input.toLowerCase())) {
|
|
@@ -469,7 +420,7 @@ export class Paddle {
|
|
|
469
420
|
return;
|
|
470
421
|
}
|
|
471
422
|
// Create product.
|
|
472
|
-
log(0, `Creating product ${product.name}.`);
|
|
423
|
+
this.server.log(0, `Creating product ${product.name}.`);
|
|
473
424
|
const created_product = await this._req("POST", "/products", {
|
|
474
425
|
name: product.name,
|
|
475
426
|
description: product.description,
|
|
@@ -479,14 +430,14 @@ export class Paddle {
|
|
|
479
430
|
});
|
|
480
431
|
product.paddle_prod_id = created_product.data.id;
|
|
481
432
|
// Create price.
|
|
482
|
-
log(0, `Creating a price for product ${product.name}.`);
|
|
433
|
+
this.server.log(0, `Creating a price for product ${product.name}.`);
|
|
483
434
|
const created_price = await this._req("POST", "/prices", {
|
|
484
435
|
product_id: product.paddle_prod_id,
|
|
485
436
|
name: product.name,
|
|
486
437
|
description: product.description,
|
|
487
438
|
unit_price: { amount: Math.floor(product.price * 100).toString(), currency_code: product.currency },
|
|
488
439
|
billing_cycle: product.is_subscription ? { interval: product.interval, frequency: product.frequency } : null,
|
|
489
|
-
trial_period: product.trial,
|
|
440
|
+
trial_period: product.is_subscription ? product.trial : null,
|
|
490
441
|
tax_mode: this.inclusive_tax ? "internal" : "external",
|
|
491
442
|
});
|
|
492
443
|
product.price_id = created_price.data.id;
|
|
@@ -495,7 +446,7 @@ export class Paddle {
|
|
|
495
446
|
else {
|
|
496
447
|
// Vars.
|
|
497
448
|
product.paddle_prod_id = existing_product.id;
|
|
498
|
-
const has_trial = product.trial != null;
|
|
449
|
+
const has_trial = product.is_subscription && product.trial != null;
|
|
499
450
|
// Check if the product should be updated.
|
|
500
451
|
const update_product = (existing_product.name !== product.name ||
|
|
501
452
|
existing_product.description !== product.description ||
|
|
@@ -507,7 +458,7 @@ export class Paddle {
|
|
|
507
458
|
if (!await has_create_products_permission()) {
|
|
508
459
|
return;
|
|
509
460
|
}
|
|
510
|
-
log(0, `Updating product ${product.name}.`);
|
|
461
|
+
this.server.log(0, `Updating product ${product.name}.`);
|
|
511
462
|
await this._req("PATCH", `/products/${product.paddle_prod_id}`, {
|
|
512
463
|
name: product.name,
|
|
513
464
|
description: product.description,
|
|
@@ -528,14 +479,14 @@ export class Paddle {
|
|
|
528
479
|
if (!await has_create_products_permission()) {
|
|
529
480
|
return;
|
|
530
481
|
}
|
|
531
|
-
log(0, `Creating a price for product ${product.name}.`);
|
|
482
|
+
this.server.log(0, `Creating a price for product ${product.name}.`);
|
|
532
483
|
const price = await this._req("POST", "/prices", {
|
|
533
484
|
product_id: product.paddle_prod_id,
|
|
534
485
|
name: product.name,
|
|
535
486
|
description: product.description,
|
|
536
487
|
unit_price: { amount: Math.floor(product.price * 100).toString(), currency_code: product.currency },
|
|
537
488
|
billing_cycle: product.is_subscription ? { interval: product.interval, frequency: product.frequency } : null,
|
|
538
|
-
trial_period: product.trial,
|
|
489
|
+
trial_period: product.is_subscription ? product.trial : null,
|
|
539
490
|
tax_mode: this.inclusive_tax ? "internal" : "external",
|
|
540
491
|
});
|
|
541
492
|
product.price_id = price.data.id;
|
|
@@ -564,14 +515,14 @@ export class Paddle {
|
|
|
564
515
|
if (!await has_create_products_permission()) {
|
|
565
516
|
return;
|
|
566
517
|
}
|
|
567
|
-
log(0, `Updating the price of product ${product.name}.`);
|
|
518
|
+
this.server.log(0, `Updating the price of product ${product.name}.`);
|
|
568
519
|
await this._req("PATCH", `/prices/${product.price_id}`, {
|
|
569
520
|
// product_id: product.id, // not allowed.
|
|
570
521
|
name: product.name,
|
|
571
522
|
description: product.description,
|
|
572
523
|
unit_price: { amount: Math.floor(product.price * 100).toString(), currency_code: product.currency },
|
|
573
524
|
billing_cycle: product.is_subscription ? { interval: product.interval, frequency: product.frequency } : null,
|
|
574
|
-
trial_period: product.trial,
|
|
525
|
+
trial_period: product.is_subscription ? product.trial : null,
|
|
575
526
|
tax_mode: this.inclusive_tax ? "internal" : "external",
|
|
576
527
|
status: "active",
|
|
577
528
|
});
|
|
@@ -778,9 +729,9 @@ export class Paddle {
|
|
|
778
729
|
// Expand the payment products.
|
|
779
730
|
let sub_products = 0;
|
|
780
731
|
this.products.iterate((product) => {
|
|
781
|
-
if (product.
|
|
732
|
+
if (product.is_subscription) {
|
|
782
733
|
// Check plans.
|
|
783
|
-
if (product.plans
|
|
734
|
+
if (!product.plans || !Array.isArray(product.plans)) {
|
|
784
735
|
throw Error(`Product "${product_index}" has an incorrect value type for attribute "plans", the valid type is "array".`);
|
|
785
736
|
}
|
|
786
737
|
// Generate sub id.
|
|
@@ -817,9 +768,6 @@ export class Paddle {
|
|
|
817
768
|
initialize_product(plan);
|
|
818
769
|
});
|
|
819
770
|
}
|
|
820
|
-
else if (product.frequency != null || product.interval != null) {
|
|
821
|
-
throw Error(`Subscription products should be nested as plans of a subscription "{... plans: [...]}". Not as a direct product without a subscription parent.`);
|
|
822
|
-
}
|
|
823
771
|
else {
|
|
824
772
|
product.is_subscription = false;
|
|
825
773
|
initialize_product(product);
|
|
@@ -827,10 +775,11 @@ export class Paddle {
|
|
|
827
775
|
});
|
|
828
776
|
/* @performance */ now = this.performance.end("init-products", now);
|
|
829
777
|
// Check registered products.
|
|
830
|
-
const last_products = await this.
|
|
831
|
-
if (
|
|
832
|
-
|
|
833
|
-
|
|
778
|
+
const last_products = await this._last_products_db.load({ production: this.server.production, version: 1 }, { throw: false });
|
|
779
|
+
if (last_products instanceof Error && !(last_products instanceof Collection.NotFoundError))
|
|
780
|
+
throw last_products;
|
|
781
|
+
if (!(last_products instanceof Collection.NotFoundError) && vlib.Object.eq(last_products.last_products, this.products)) {
|
|
782
|
+
last_products.product_ids.iterate((item) => {
|
|
834
783
|
const product = this.get_product_sync(item.id);
|
|
835
784
|
if (product != null) {
|
|
836
785
|
product.paddle_prod_id = item.paddle_prod_id;
|
|
@@ -847,7 +796,7 @@ export class Paddle {
|
|
|
847
796
|
// Check all products.
|
|
848
797
|
const product_ids = [];
|
|
849
798
|
for (const product of this.products) {
|
|
850
|
-
if (product.
|
|
799
|
+
if (product.is_subscription) {
|
|
851
800
|
for (const plan of product.plans) {
|
|
852
801
|
await this._check_product(plan, existing_products, existing_prices);
|
|
853
802
|
product_ids.append({
|
|
@@ -870,76 +819,59 @@ export class Paddle {
|
|
|
870
819
|
;
|
|
871
820
|
/* @performance */ now = this.performance.end("check-products", now);
|
|
872
821
|
// Save last products.
|
|
873
|
-
await this.
|
|
874
|
-
|
|
875
|
-
|
|
822
|
+
await this._last_products_db.set({ production: this.server.production, version: 1 }, {
|
|
823
|
+
last_products: vlib.Object.delete_recursively(vlib.Object.deep_copy(this.products), ["paddle_prod_id", "price_id"]),
|
|
824
|
+
product_ids: product_ids,
|
|
825
|
+
});
|
|
876
826
|
/* @performance */ now = this.performance.end("save-products-to-db", now);
|
|
877
827
|
}
|
|
878
828
|
}
|
|
879
829
|
// Initialize the payments.
|
|
880
830
|
async _initialize() {
|
|
881
|
-
/* @performance */ this.performance.start();
|
|
882
|
-
// Create database collections.
|
|
883
|
-
this._settings_db = await this.server.db.collection({
|
|
884
|
-
name: "Volt.Paddle.Settings",
|
|
885
|
-
indexes: ["_path"],
|
|
886
|
-
});
|
|
887
|
-
this._sub_db = await this.server.db.collection({
|
|
888
|
-
name: "Volt.Paddle.Subscriptions",
|
|
889
|
-
indexes: ["uid", "id"],
|
|
890
|
-
});
|
|
891
|
-
this._active_sub_db = await this.server.db.collection({
|
|
892
|
-
name: "Volt.Paddle.ActiveSubscriptions",
|
|
893
|
-
indexes: ["uid", "prod_id"],
|
|
894
|
-
});
|
|
895
|
-
this._pay_db = await this.server.db.collection({
|
|
896
|
-
name: "Volt.Paddle.Payments",
|
|
897
|
-
indexes: ["uid", "id", "tran_id"],
|
|
898
|
-
});
|
|
899
|
-
// this._inv_db = await this.server.db.collection({
|
|
900
|
-
// name: "Volt.Paddle.Invoices",
|
|
901
|
-
// indexes: ["uid", "id", "tran_id" ],
|
|
902
|
-
// });
|
|
903
|
-
/* @performance */ this.performance.end("init-db");
|
|
904
831
|
// Initialize products.
|
|
905
832
|
await this._initialize_products();
|
|
906
833
|
/* @performance */ let now = this.performance.start();
|
|
907
834
|
// Initialize and verify an order, check if the user is authenticated when subscriptions are present and check if the user is not already subscribed to the same item.
|
|
908
835
|
this.server.endpoint({
|
|
909
836
|
method: "POST",
|
|
910
|
-
endpoint: "/volt/payments/init",
|
|
837
|
+
endpoint: "/volt/api/v1/payments/init",
|
|
911
838
|
content_type: "application/json",
|
|
912
839
|
rate_limit: "global",
|
|
913
840
|
params: {
|
|
914
|
-
items: "array",
|
|
841
|
+
items: { type: "array", required: true, value_schema: "object" }, // add schema for items
|
|
915
842
|
},
|
|
916
843
|
callback: async (stream, params) => {
|
|
917
844
|
// Check items.
|
|
918
845
|
if (params.items.length === 0) {
|
|
919
|
-
return stream.error({ status: Status.bad_request,
|
|
846
|
+
return stream.error({ status: Status.bad_request, message: "Shopping cart is empty." });
|
|
920
847
|
}
|
|
921
848
|
let sub_plan_count = {};
|
|
922
|
-
|
|
849
|
+
let error = undefined;
|
|
850
|
+
for (const item of params.items) {
|
|
923
851
|
if (item.product.is_subscription) {
|
|
924
852
|
if (stream.uid == null) {
|
|
925
|
-
|
|
853
|
+
error = "You must be signed-in to purchase a subscription.";
|
|
854
|
+
break;
|
|
926
855
|
}
|
|
927
856
|
if (item.quantity != null && item.quantity > 1) {
|
|
928
|
-
|
|
857
|
+
error = "Subscriptions have a max quantity of 1.";
|
|
858
|
+
break;
|
|
929
859
|
}
|
|
930
860
|
if (sub_plan_count[item.product.subscription_id] == null) {
|
|
931
861
|
sub_plan_count[item.product.subscription_id] = 1;
|
|
932
862
|
}
|
|
933
863
|
else {
|
|
934
|
-
|
|
864
|
+
error = "You can not charge two different subscription plans from the same subscription product.";
|
|
865
|
+
break;
|
|
935
866
|
}
|
|
936
867
|
if (await this._check_subscription(stream.uid, item.product.id, false)) {
|
|
937
|
-
|
|
868
|
+
error = `You are already subscribed to product "${item.product.name}".`;
|
|
869
|
+
break;
|
|
938
870
|
}
|
|
939
871
|
}
|
|
940
|
-
}
|
|
872
|
+
}
|
|
941
873
|
if (error) {
|
|
942
|
-
return stream.error({ status: Status.bad_request,
|
|
874
|
+
return stream.error({ status: Status.bad_request, message: error });
|
|
943
875
|
}
|
|
944
876
|
// Success.
|
|
945
877
|
return stream.success({ data: { message: "Successfully initialized the order." } });
|
|
@@ -948,7 +880,7 @@ export class Paddle {
|
|
|
948
880
|
// Get products.
|
|
949
881
|
this.server.endpoint({
|
|
950
882
|
method: "GET",
|
|
951
|
-
endpoint: "/volt/payments/products",
|
|
883
|
+
endpoint: "/volt/api/v1/payments/products",
|
|
952
884
|
content_type: "application/json",
|
|
953
885
|
rate_limit: "global",
|
|
954
886
|
callback: (stream) => {
|
|
@@ -958,119 +890,130 @@ export class Paddle {
|
|
|
958
890
|
// Get payment by id.
|
|
959
891
|
this.server.endpoint({
|
|
960
892
|
method: "GET",
|
|
961
|
-
endpoint: "/volt/payments/payment",
|
|
893
|
+
endpoint: "/volt/api/v1/payments/payment",
|
|
962
894
|
content_type: "application/json",
|
|
963
895
|
rate_limit: "global",
|
|
964
896
|
params: {
|
|
965
897
|
id: "string",
|
|
966
898
|
},
|
|
967
899
|
callback: async (stream, params) => {
|
|
968
|
-
return stream.success({
|
|
900
|
+
return stream.success({
|
|
901
|
+
data: await this._load_payment_for_public(params.id),
|
|
902
|
+
});
|
|
969
903
|
}
|
|
970
904
|
});
|
|
971
905
|
// Get payments.
|
|
972
906
|
this.server.endpoint({
|
|
973
907
|
method: "GET",
|
|
974
|
-
endpoint: "/volt/payments/payments",
|
|
908
|
+
endpoint: "/volt/api/v1/payments/payments",
|
|
975
909
|
content_type: "application/json",
|
|
976
910
|
authenticated: true,
|
|
977
911
|
rate_limit: "global",
|
|
978
912
|
params: {
|
|
979
913
|
days: { type: "number", default: 30 },
|
|
980
|
-
limit: { type: "number",
|
|
981
|
-
status: { type: "string",
|
|
914
|
+
limit: { type: "number", required: false },
|
|
915
|
+
status: { type: "string", required: false, enum: PaymentStatusValues },
|
|
982
916
|
},
|
|
983
917
|
callback: async (stream, params) => {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
918
|
+
return stream.success({
|
|
919
|
+
data: await this.get_payments({
|
|
920
|
+
uid: stream.uid,
|
|
921
|
+
days: params.days,
|
|
922
|
+
limit: params.limit,
|
|
923
|
+
status: params.status,
|
|
924
|
+
})
|
|
989
925
|
});
|
|
990
|
-
return stream.success({ data: result });
|
|
991
926
|
}
|
|
992
927
|
});
|
|
993
928
|
// Get refundable payments.
|
|
994
929
|
this.server.endpoint({
|
|
995
930
|
method: "GET",
|
|
996
|
-
endpoint: "/volt/payments/payments/refundable",
|
|
931
|
+
endpoint: "/volt/api/v1/payments/payments/refundable",
|
|
997
932
|
content_type: "application/json",
|
|
998
933
|
authenticated: true,
|
|
999
934
|
rate_limit: "global",
|
|
1000
935
|
params: {
|
|
1001
936
|
days: { type: "number", default: 30 },
|
|
1002
|
-
limit: { type:
|
|
1003
|
-
status: { type: ["null", "string"], default: null },
|
|
937
|
+
limit: { type: "number", required: false },
|
|
1004
938
|
},
|
|
1005
939
|
callback: async (stream, params) => {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
940
|
+
return stream.success({
|
|
941
|
+
data: await this.get_refundable_payments({
|
|
942
|
+
uid: stream.uid,
|
|
943
|
+
days: params.days,
|
|
944
|
+
limit: params.limit,
|
|
945
|
+
for_public: true,
|
|
946
|
+
})
|
|
1010
947
|
});
|
|
1011
|
-
return stream.success({ data: result });
|
|
1012
948
|
}
|
|
1013
949
|
});
|
|
1014
950
|
// Get refunded payments.
|
|
1015
951
|
this.server.endpoint({
|
|
1016
952
|
method: "GET",
|
|
1017
|
-
endpoint: "/volt/payments/payments/refunded",
|
|
953
|
+
endpoint: "/volt/api/v1/payments/payments/refunded",
|
|
1018
954
|
content_type: "application/json",
|
|
1019
955
|
authenticated: true,
|
|
1020
956
|
rate_limit: "global",
|
|
1021
957
|
params: {
|
|
1022
958
|
days: { type: "number", default: 30 },
|
|
1023
|
-
limit: { type:
|
|
959
|
+
limit: { type: "number", required: false },
|
|
1024
960
|
},
|
|
1025
961
|
callback: async (stream, params) => {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
962
|
+
return stream.success({
|
|
963
|
+
data: await this.get_refunded_payments({
|
|
964
|
+
uid: stream.uid,
|
|
965
|
+
days: params.days,
|
|
966
|
+
limit: params.limit,
|
|
967
|
+
for_public: true,
|
|
968
|
+
})
|
|
1030
969
|
});
|
|
1031
|
-
return stream.success({ data: result });
|
|
1032
970
|
}
|
|
1033
971
|
});
|
|
1034
972
|
// Get refunding payments.
|
|
1035
973
|
this.server.endpoint({
|
|
1036
974
|
method: "GET",
|
|
1037
|
-
endpoint: "/volt/payments/payments/refunding",
|
|
975
|
+
endpoint: "/volt/api/v1/payments/payments/refunding",
|
|
1038
976
|
content_type: "application/json",
|
|
1039
977
|
authenticated: true,
|
|
1040
978
|
rate_limit: "global",
|
|
1041
979
|
params: {
|
|
1042
|
-
days: { type:
|
|
1043
|
-
limit: { type:
|
|
980
|
+
days: { type: "number", default: 30 },
|
|
981
|
+
limit: { type: "number", required: false },
|
|
1044
982
|
},
|
|
1045
983
|
callback: async (stream, params) => {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
984
|
+
return stream.success({
|
|
985
|
+
data: await this.get_refunding_payments({
|
|
986
|
+
uid: stream.uid,
|
|
987
|
+
days: params.days,
|
|
988
|
+
limit: params.limit,
|
|
989
|
+
for_public: true,
|
|
990
|
+
})
|
|
1050
991
|
});
|
|
1051
|
-
return stream.success({ data: result });
|
|
1052
992
|
}
|
|
1053
993
|
});
|
|
1054
994
|
// Create a refund.
|
|
1055
995
|
this.server.endpoint({
|
|
1056
996
|
method: "POST",
|
|
1057
|
-
endpoint: "/volt/payments/refund",
|
|
997
|
+
endpoint: "/volt/api/v1/payments/refund",
|
|
1058
998
|
content_type: "application/json",
|
|
999
|
+
authenticated: true,
|
|
1059
1000
|
rate_limit: "global",
|
|
1060
1001
|
params: {
|
|
1061
|
-
payment: { type: ["string", "object"] },
|
|
1062
|
-
line_items: { type:
|
|
1002
|
+
payment: { type: ["string", "object"], schema: { id: "string" } },
|
|
1003
|
+
line_items: { type: "array", required: false, value_schema: {
|
|
1004
|
+
type: "object", schema: LineItem.Schema
|
|
1005
|
+
} },
|
|
1063
1006
|
reason: { type: "string", default: "refund" },
|
|
1064
1007
|
},
|
|
1065
1008
|
callback: async (stream, params) => {
|
|
1066
|
-
await this.create_refund(params.payment, params.line_items, params.reason);
|
|
1009
|
+
await this.create_refund(typeof params.payment === "string" ? params.payment : params.payment.id, params.line_items, params.reason);
|
|
1067
1010
|
return stream.success();
|
|
1068
1011
|
}
|
|
1069
1012
|
});
|
|
1070
1013
|
// Cancel a subscription.
|
|
1071
1014
|
this.server.endpoint({
|
|
1072
1015
|
method: "DELETE",
|
|
1073
|
-
endpoint: "/volt/payments/subscription",
|
|
1016
|
+
endpoint: "/volt/api/v1/payments/subscription",
|
|
1074
1017
|
content_type: "application/json",
|
|
1075
1018
|
authenticated: true,
|
|
1076
1019
|
rate_limit: "global",
|
|
@@ -1085,7 +1028,7 @@ export class Paddle {
|
|
|
1085
1028
|
// Cancel a subscription by payment.
|
|
1086
1029
|
// {
|
|
1087
1030
|
// method: "DELETE",
|
|
1088
|
-
// endpoint: "/volt/payments/subscription_by_payment",
|
|
1031
|
+
// endpoint: "/volt/api/v1/payments/subscription_by_payment",
|
|
1089
1032
|
// content_type: "application/json",
|
|
1090
1033
|
// authenticated: true,
|
|
1091
1034
|
// rate_limit: "global",
|
|
@@ -1100,20 +1043,22 @@ export class Paddle {
|
|
|
1100
1043
|
// Get active subscriptions.
|
|
1101
1044
|
this.server.endpoint({
|
|
1102
1045
|
method: "GET",
|
|
1103
|
-
endpoint: "/volt/payments/active_subscriptions",
|
|
1046
|
+
endpoint: "/volt/api/v1/payments/active_subscriptions",
|
|
1104
1047
|
content_type: "application/json",
|
|
1105
1048
|
authenticated: true,
|
|
1106
1049
|
rate_limit: "global",
|
|
1107
|
-
callback: async (stream
|
|
1050
|
+
callback: async (stream) => {
|
|
1108
1051
|
return stream.success({
|
|
1109
|
-
data: {
|
|
1052
|
+
data: {
|
|
1053
|
+
subscriptions: await this.get_active_subscriptions(stream.uid)
|
|
1054
|
+
},
|
|
1110
1055
|
});
|
|
1111
1056
|
}
|
|
1112
1057
|
});
|
|
1113
1058
|
// Is subscribed
|
|
1114
1059
|
this.server.endpoint({
|
|
1115
1060
|
method: "GET",
|
|
1116
|
-
endpoint: "/volt/payments/subscribed",
|
|
1061
|
+
endpoint: "/volt/api/v1/payments/subscribed",
|
|
1117
1062
|
content_type: "application/json",
|
|
1118
1063
|
authenticated: true,
|
|
1119
1064
|
rate_limit: "global",
|
|
@@ -1122,7 +1067,9 @@ export class Paddle {
|
|
|
1122
1067
|
},
|
|
1123
1068
|
callback: async (stream, params) => {
|
|
1124
1069
|
return stream.success({
|
|
1125
|
-
data: {
|
|
1070
|
+
data: {
|
|
1071
|
+
is_subscribed: (await this.is_subscribed(stream.uid, params.product))
|
|
1072
|
+
}
|
|
1126
1073
|
});
|
|
1127
1074
|
}
|
|
1128
1075
|
});
|
|
@@ -1165,7 +1112,7 @@ export class Paddle {
|
|
|
1165
1112
|
// Only used in the paid webhook, other parts use the saved payment object.
|
|
1166
1113
|
// This is required to manage the statuses of payments.
|
|
1167
1114
|
// Make request.
|
|
1168
|
-
let obj = (await this._req("GET", `/transactions/${data.id}`, { include: ["address", "
|
|
1115
|
+
let obj = (await this._req("GET", `/transactions/${data.id}`, { include: ["address", "adjustments", "business", "customer"] })).data;
|
|
1169
1116
|
// Initialize.
|
|
1170
1117
|
const id = `pay_${obj.custom_data.uid == null ? "unauth" : obj.custom_data.uid}_${vlib.String.random(4)}${Date.now()}`;
|
|
1171
1118
|
const payment = {
|
|
@@ -1246,7 +1193,7 @@ export class Paddle {
|
|
|
1246
1193
|
payment.status = "past_due";
|
|
1247
1194
|
break;
|
|
1248
1195
|
default:
|
|
1249
|
-
error(`Payment Webhook: Unknown payment status "${obj.status}".`);
|
|
1196
|
+
this.server.log.error(`Payment Webhook: Unknown payment status "${obj.status}".`);
|
|
1250
1197
|
payment.status = "unknown";
|
|
1251
1198
|
break;
|
|
1252
1199
|
}
|
|
@@ -1258,10 +1205,10 @@ export class Paddle {
|
|
|
1258
1205
|
paddle_prod_id: item.product.id, // paddle product id.
|
|
1259
1206
|
quantity: item.quantity,
|
|
1260
1207
|
tax_rate: parseFloat(item.tax_rate),
|
|
1261
|
-
tax:
|
|
1262
|
-
discount:
|
|
1263
|
-
subtotal:
|
|
1264
|
-
total:
|
|
1208
|
+
tax: item.totals.tax / 100, // should not be changed to unit totals, since mails and invoices depend on this behaviour, just divide by quantity.
|
|
1209
|
+
discount: item.totals.discount / 100, // should not be changed to unit totals, since mails and invoices depend on this behaviour, just divide by quantity.
|
|
1210
|
+
subtotal: item.totals.subtotal / 100, // should not be changed to unit totals, since mails and invoices depend on this behaviour, just divide by quantity.
|
|
1211
|
+
total: item.totals.total / 100, // should not be changed to unit totals, since mails and invoices depend on this behaviour, just divide by quantity.
|
|
1265
1212
|
status: "paid", // can be "paid", "refunded", "refunding".
|
|
1266
1213
|
});
|
|
1267
1214
|
});
|
|
@@ -1270,8 +1217,8 @@ export class Paddle {
|
|
|
1270
1217
|
obj.adustments.iterate((adj) => {
|
|
1271
1218
|
switch (adj.action) {
|
|
1272
1219
|
case "refund":
|
|
1273
|
-
case "
|
|
1274
|
-
|
|
1220
|
+
case "chargeback":
|
|
1221
|
+
// case "chargeback_warning":
|
|
1275
1222
|
adj.items.iterate((adj_item) => {
|
|
1276
1223
|
payment.line_items.iterate((item) => {
|
|
1277
1224
|
if (adj_item.item_id === item.item_id) {
|
|
@@ -1281,6 +1228,16 @@ export class Paddle {
|
|
|
1281
1228
|
});
|
|
1282
1229
|
});
|
|
1283
1230
|
break;
|
|
1231
|
+
case "chargeback_reversal":
|
|
1232
|
+
adj.items.iterate((adj_item) => {
|
|
1233
|
+
payment.line_items.iterate((item) => {
|
|
1234
|
+
if (adj_item.item_id === item.item_id) {
|
|
1235
|
+
item.status = "paid";
|
|
1236
|
+
return false;
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
});
|
|
1240
|
+
break;
|
|
1284
1241
|
default:
|
|
1285
1242
|
break;
|
|
1286
1243
|
}
|
|
@@ -1290,9 +1247,9 @@ export class Paddle {
|
|
|
1290
1247
|
await this._save_payment(payment);
|
|
1291
1248
|
// ---------------------------------------------------------
|
|
1292
1249
|
// Process the payment.
|
|
1293
|
-
const { uid
|
|
1250
|
+
const { uid } = payment;
|
|
1294
1251
|
// Check the payment line items.
|
|
1295
|
-
for (const item of
|
|
1252
|
+
for (const item of payment.line_items) {
|
|
1296
1253
|
const product = this.get_product_sync(item.product, false);
|
|
1297
1254
|
// @todo REFUND PAYMENT SINCE PRODUCT WAS NOT FOUND SO NO WAY OF DELIVERY.
|
|
1298
1255
|
// Refund the payment since there is no way of delivery.
|
|
@@ -1308,11 +1265,11 @@ export class Paddle {
|
|
|
1308
1265
|
// Cancel the other subscriptions plans that are part of this product.
|
|
1309
1266
|
// The `create_payment()` function makes sure there are not multiple subscription plans of the same subscription product charged in a single request.
|
|
1310
1267
|
const subscription = await this.get_product(product.subscription_id, true);
|
|
1311
|
-
for (const plan of subscription
|
|
1268
|
+
for (const plan of subscription?.plans ?? []) {
|
|
1312
1269
|
if (plan.id != product.id) {
|
|
1313
1270
|
const { exists, sub_id } = await this._check_subscription(uid, plan.id);
|
|
1314
1271
|
if (exists) {
|
|
1315
|
-
log(0, `Cancelling subscription "${plan.id}" due too downgrade/upgrade to "${product.id}" of user "${payment.uid}".`);
|
|
1272
|
+
this.server.log(0, `Cancelling subscription "${plan.id}" due too downgrade/upgrade to "${product.id}" of user "${payment.uid}".`);
|
|
1316
1273
|
// @todo cancel sub by sub id.
|
|
1317
1274
|
await this._cancel_subscription(sub_id);
|
|
1318
1275
|
}
|
|
@@ -1356,7 +1313,7 @@ export class Paddle {
|
|
|
1356
1313
|
const product = this._get_product_by_paddle_prod_id(item.price.product_id, false);
|
|
1357
1314
|
// Product not found or no sub id found, nothing to do here, the payment webhook already handles this scenario.
|
|
1358
1315
|
if (product == null) {
|
|
1359
|
-
error(`Subscription webhook [#sub1]: Unable to find product with id ${item.price.product_id}. This is a serious error which causes a non activated subscription for a paid transaction. You should manually cancel the subscription. Event: ${JSON.stringify(data, null, 4)}.`);
|
|
1316
|
+
this.server.log.error(`Subscription webhook [#sub1]: Unable to find product with id ${item.price.product_id}. This is a serious error which causes a non activated subscription for a paid transaction. You should manually cancel the subscription. Event: ${JSON.stringify(data, null, 4)}.`);
|
|
1360
1317
|
continue;
|
|
1361
1318
|
}
|
|
1362
1319
|
// Subscription.
|
|
@@ -1364,7 +1321,7 @@ export class Paddle {
|
|
|
1364
1321
|
// Add to plans.
|
|
1365
1322
|
subscription.plans.append(product.id);
|
|
1366
1323
|
// Active the user's subscription in the database.
|
|
1367
|
-
log(0, `Activating subscription "${product.id}" of user "${subscription.uid}".`);
|
|
1324
|
+
this.server.log(0, `Activating subscription "${product.id}" of user "${subscription.uid}".`);
|
|
1368
1325
|
await this._add_subscription(uid, product.id, subscription.id);
|
|
1369
1326
|
// No need to cancel other subs, this is already handled by the payment webhook.
|
|
1370
1327
|
// Execute callback.
|
|
@@ -1382,7 +1339,7 @@ export class Paddle {
|
|
|
1382
1339
|
// Delete subscriptions made by this subscription.
|
|
1383
1340
|
for (const plan_id of subscription.plans) {
|
|
1384
1341
|
await this._delete_subscription(subscription.uid, plan_id);
|
|
1385
|
-
log(0, `Deactivating subscription "${plan_id}" of user "${subscription.uid}".`);
|
|
1342
|
+
this.server.log(0, `Deactivating subscription "${plan_id}" of user "${subscription.uid}".`);
|
|
1386
1343
|
}
|
|
1387
1344
|
// Update database.
|
|
1388
1345
|
subscription.status = "cancelled";
|
|
@@ -1434,7 +1391,7 @@ export class Paddle {
|
|
|
1434
1391
|
}
|
|
1435
1392
|
// Execute callback.
|
|
1436
1393
|
if (is_approved) {
|
|
1437
|
-
log(0, `Refunded items of payment "${payment.id}" of user "${payment.uid}".`);
|
|
1394
|
+
this.server.log(0, `Refunded items of payment "${payment.id}" of user "${payment.uid}".`);
|
|
1438
1395
|
await this._exec_user_callback(is_refund ? this.server.on_refund : this.server.on_chargeback, { payment, line_items });
|
|
1439
1396
|
// try {
|
|
1440
1397
|
// await this._send_payment_mail({
|
|
@@ -1447,7 +1404,7 @@ export class Paddle {
|
|
|
1447
1404
|
// }
|
|
1448
1405
|
}
|
|
1449
1406
|
else {
|
|
1450
|
-
log(0, `Refund denied for items of payment ${payment.id} of user "${payment.uid}".`);
|
|
1407
|
+
this.server.log(0, `Refund denied for items of payment ${payment.id} of user "${payment.uid}".`);
|
|
1451
1408
|
await this._exec_user_callback(is_refund ? this.server.on_failed_refund : this.server.on_failed_chargeback, { payment, line_items });
|
|
1452
1409
|
// try {
|
|
1453
1410
|
// await this._send_payment_mail({
|
|
@@ -1466,7 +1423,7 @@ export class Paddle {
|
|
|
1466
1423
|
const payment = await this._load_payment_by_transaction(data.transaction_id);
|
|
1467
1424
|
// Log reactivation subscriptions on chargeback reverse.
|
|
1468
1425
|
if (payment.sub_id != null) {
|
|
1469
|
-
log(0, `Chargeback reversed for payment ${payment.id} from user "${payment.uid}".`);
|
|
1426
|
+
this.server.log(0, `Chargeback reversed for payment ${payment.id} from user "${payment.uid}".`);
|
|
1470
1427
|
// @todo.
|
|
1471
1428
|
}
|
|
1472
1429
|
// Get and update line items.
|
|
@@ -1487,8 +1444,8 @@ export class Paddle {
|
|
|
1487
1444
|
}
|
|
1488
1445
|
// Create and register the webhook endpoint.
|
|
1489
1446
|
async _create_webhook() {
|
|
1447
|
+
/* @performance */ const now = this.performance.start();
|
|
1490
1448
|
// Register the webhook.
|
|
1491
|
-
const webhook_doc = await this._settings_db.load(`webhook${this.server.production ? "" : "_demo"}`);
|
|
1492
1449
|
const webhook_settings = {
|
|
1493
1450
|
description: "volt webhook",
|
|
1494
1451
|
destination: `${this.server.full_domain}/volt/payments/webhook`,
|
|
@@ -1515,72 +1472,89 @@ export class Paddle {
|
|
|
1515
1472
|
"adjustment.updated",
|
|
1516
1473
|
],
|
|
1517
1474
|
};
|
|
1475
|
+
const hashed_webhook_settings = this.server.hash(webhook_settings);
|
|
1518
1476
|
// Register webhook.
|
|
1519
1477
|
const register_webhook = async () => {
|
|
1520
|
-
log(0, "Registering payments webhook.");
|
|
1478
|
+
this.server.log(0, "Registering payments webhook.");
|
|
1521
1479
|
const response = await this._req("POST", "/notification-settings", webhook_settings);
|
|
1522
1480
|
this.webhook_key = response.data.endpoint_secret_key;
|
|
1523
|
-
await this.
|
|
1481
|
+
await this._webhook_conf_db.set({ production: this.server.production, version: 1 }, {
|
|
1524
1482
|
id: response.data.id,
|
|
1525
1483
|
key: this.webhook_key,
|
|
1484
|
+
hash: this.server.hash(webhook_settings),
|
|
1526
1485
|
});
|
|
1527
1486
|
};
|
|
1528
|
-
//
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1487
|
+
// For speeding up the restart process we store the hash of the previous webhook under a temporary document.
|
|
1488
|
+
const home_dir = vlib.Path.home().join(".volt/cache");
|
|
1489
|
+
if (!home_dir.exists()) {
|
|
1490
|
+
home_dir.mkdir({ recursive: true });
|
|
1491
|
+
}
|
|
1492
|
+
const cached_local_hash_file = home_dir.join(`paddle_webhook_${this.server.production ? "live" : "sandbox"}.hash`);
|
|
1493
|
+
const cached_local_hash = cached_local_hash_file.exists() ? (await cached_local_hash_file.load()) : null;
|
|
1494
|
+
if (cached_local_hash !== hashed_webhook_settings) {
|
|
1495
|
+
// Load webhook doc.
|
|
1496
|
+
const webhook_doc = await this._webhook_conf_db.load({ production: this.server.production, version: 1 }, { throw: false });
|
|
1497
|
+
if (webhook_doc instanceof Error && !(webhook_doc instanceof Collection.NotFoundError)) {
|
|
1498
|
+
throw webhook_doc;
|
|
1499
|
+
}
|
|
1500
|
+
// Webhook registered.
|
|
1501
|
+
if (!(webhook_doc instanceof Collection.NotFoundError)) {
|
|
1502
|
+
this.webhook_key = webhook_doc.key;
|
|
1535
1503
|
// Check update required.
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
registered = undefined;
|
|
1544
|
-
await register_webhook();
|
|
1545
|
-
}
|
|
1546
|
-
else {
|
|
1547
|
-
throw error;
|
|
1504
|
+
if (webhook_doc.hash !== hashed_webhook_settings) {
|
|
1505
|
+
this.server.log(0, `Checking payments webhook.`);
|
|
1506
|
+
// Check update required.
|
|
1507
|
+
const webhook_id = webhook_doc.id;
|
|
1508
|
+
let registered;
|
|
1509
|
+
try {
|
|
1510
|
+
registered = await this._req("GET", `/notification-settings/${webhook_id}`);
|
|
1548
1511
|
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
item.description !== webhook_settings.description ||
|
|
1557
|
-
item.subscribed_events.length != webhook_settings.subscribed_events.length) {
|
|
1558
|
-
return true;
|
|
1512
|
+
catch (error) {
|
|
1513
|
+
if (error.status === 404 || error.status_code === 404) {
|
|
1514
|
+
registered = undefined;
|
|
1515
|
+
await register_webhook();
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
throw error;
|
|
1559
1519
|
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1520
|
+
}
|
|
1521
|
+
if (registered) {
|
|
1522
|
+
const item = registered.data;
|
|
1523
|
+
const patch = (() => {
|
|
1524
|
+
if (item.active !== true ||
|
|
1525
|
+
item.destination !== webhook_settings.destination ||
|
|
1526
|
+
item.type !== webhook_settings.type ||
|
|
1527
|
+
item.description !== webhook_settings.description ||
|
|
1528
|
+
item.subscribed_events.length != webhook_settings.subscribed_events.length) {
|
|
1529
|
+
return true;
|
|
1530
|
+
}
|
|
1531
|
+
return webhook_settings.subscribed_events.iterate((x) => {
|
|
1532
|
+
const found = item.subscribed_events.iterate((y) => {
|
|
1533
|
+
if (x === y.name) {
|
|
1534
|
+
return true;
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1537
|
+
if (found === false) {
|
|
1563
1538
|
return true;
|
|
1564
1539
|
}
|
|
1565
1540
|
});
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
await this._req("PATCH", `/notification-settings/${webhook_id}`, { ...webhook_settings, active: true });
|
|
1541
|
+
})();
|
|
1542
|
+
// Update.
|
|
1543
|
+
if (patch === true) {
|
|
1544
|
+
this.server.log(0, "Updating payments webhook.");
|
|
1545
|
+
await this._req("PATCH", `/notification-settings/${webhook_id}`, { ...webhook_settings, active: true });
|
|
1546
|
+
}
|
|
1547
|
+
// Save new hash.
|
|
1548
|
+
await this._webhook_conf_db.set({ production: this.server.production, version: 1 }, { hash: this.server.hash(webhook_settings) });
|
|
1575
1549
|
}
|
|
1576
|
-
// Save.
|
|
1577
|
-
await this._settings_db.save(`last_webhook${this.server.production ? "" : "_demo"}`, this.server.hash(webhook_settings));
|
|
1578
1550
|
}
|
|
1579
1551
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1552
|
+
// Register webhook.
|
|
1553
|
+
else {
|
|
1554
|
+
await register_webhook();
|
|
1555
|
+
}
|
|
1556
|
+
// Save the new hash.
|
|
1557
|
+
await cached_local_hash_file.save(hashed_webhook_settings);
|
|
1584
1558
|
}
|
|
1585
1559
|
// Ip whitelist.
|
|
1586
1560
|
const ip_whitelist = [
|
|
@@ -1599,22 +1573,23 @@ export class Paddle {
|
|
|
1599
1573
|
"44.241.183.62",
|
|
1600
1574
|
"100.20.172.113",
|
|
1601
1575
|
];
|
|
1576
|
+
/* @performance */ this.server.performance.end("create-payments-webhook", now);
|
|
1602
1577
|
// Create the endpoint.
|
|
1603
1578
|
return {
|
|
1604
1579
|
method: "POST",
|
|
1605
|
-
endpoint: "/volt/payments/webhook",
|
|
1580
|
+
endpoint: "/volt/api/v1/payments/webhook",
|
|
1606
1581
|
content_type: "application/json",
|
|
1607
1582
|
rate_limit: undefined,
|
|
1608
1583
|
callback: async (stream) => {
|
|
1609
1584
|
// Ip whitelist.
|
|
1610
1585
|
if (ip_whitelist.includes(stream.ip) === false) {
|
|
1611
|
-
log(0, `POST:/volt/payments/webhook: Warning: Blocking non whitelisted ip "${stream.ip}".`);
|
|
1586
|
+
this.server.log(0, `POST:/volt/payments/webhook: Warning: Blocking non whitelisted ip "${stream.ip}".`);
|
|
1612
1587
|
return stream.error({ status: Status.unauthorized });
|
|
1613
1588
|
}
|
|
1614
1589
|
// Verify.
|
|
1615
1590
|
const full_signature = stream.headers["paddle-signature"];
|
|
1616
1591
|
if (full_signature == null) {
|
|
1617
|
-
log(0, "POST:/volt/payments/webhook: Error: No paddle signature found in the request headers.");
|
|
1592
|
+
this.server.log(0, "POST:/volt/payments/webhook: Error: No paddle signature found in the request headers.");
|
|
1618
1593
|
return stream.error({ status: Status.unauthorized, data: { error: "Webhook signature verification failed." } });
|
|
1619
1594
|
}
|
|
1620
1595
|
const ts_index = full_signature.indexOf(";");
|
|
@@ -1622,7 +1597,7 @@ export class Paddle {
|
|
|
1622
1597
|
const signature = full_signature.substr(ts_index + 4);
|
|
1623
1598
|
const digest = libcrypto.createHmac("sha256", this.webhook_key).update(`${ts}:${stream.body}`).digest("hex");
|
|
1624
1599
|
if (libcrypto.timingSafeEqual(Buffer.from(digest, "hex"), Buffer.from(signature, "hex")) !== true) {
|
|
1625
|
-
log(0, "POST:/volt/payments/webhook: Error: Webhook signature verification failed.");
|
|
1600
|
+
this.server.log(0, "POST:/volt/payments/webhook: Error: Webhook signature verification failed.");
|
|
1626
1601
|
return stream.error({ status: Status.unauthorized, data: { error: "Webhook signature verification failed." } });
|
|
1627
1602
|
}
|
|
1628
1603
|
// Process items.
|
|
@@ -1683,7 +1658,6 @@ export class Paddle {
|
|
|
1683
1658
|
}
|
|
1684
1659
|
return product;
|
|
1685
1660
|
}
|
|
1686
|
-
// Get a payment by id.
|
|
1687
1661
|
/* @docs:
|
|
1688
1662
|
@title: Get Payment.
|
|
1689
1663
|
@desc: Get a payment by id.
|
|
@@ -1693,10 +1667,12 @@ export class Paddle {
|
|
|
1693
1667
|
@type: string
|
|
1694
1668
|
@desc: The id of the payment.
|
|
1695
1669
|
*/
|
|
1696
|
-
async get_payment(id) {
|
|
1670
|
+
async get_payment(id, opts) {
|
|
1671
|
+
if (opts?.for_public) {
|
|
1672
|
+
return await this._load_payment_for_public(id);
|
|
1673
|
+
}
|
|
1697
1674
|
return await this._load_payment(id);
|
|
1698
1675
|
}
|
|
1699
|
-
// Get payments.
|
|
1700
1676
|
/* @docs:
|
|
1701
1677
|
@title: Get Refunded Payments.
|
|
1702
1678
|
@desc:
|
|
@@ -1725,37 +1701,30 @@ export class Paddle {
|
|
|
1725
1701
|
@value: "paid"
|
|
1726
1702
|
@desc: Payments that are paid.
|
|
1727
1703
|
*/
|
|
1728
|
-
async get_payments({ uid, days = 30, limit =
|
|
1704
|
+
async get_payments({ uid, days = 30, limit = 10_000, status = undefined, for_public, }) {
|
|
1729
1705
|
// Get path.
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1732
|
-
|
|
1706
|
+
const query = {
|
|
1707
|
+
uid,
|
|
1708
|
+
};
|
|
1733
1709
|
if (days != null) {
|
|
1734
|
-
since = new Date();
|
|
1710
|
+
const since = new Date();
|
|
1735
1711
|
since.setHours(0, 0, 0, 0);
|
|
1736
|
-
|
|
1712
|
+
query.timestamp = { $gte: Math.floor(since.getTime() - (3600 * 24 * 1000 * days)) };
|
|
1737
1713
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
(status_is_array && status.includes(payment.status))) {
|
|
1746
|
-
payments.append(payment);
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
if (limit != null && limit != -1 && payments.length >= limit) {
|
|
1750
|
-
return false;
|
|
1751
|
-
}
|
|
1752
|
-
});
|
|
1714
|
+
if (Array.isArray(status)) {
|
|
1715
|
+
query.status = { $in: status };
|
|
1716
|
+
}
|
|
1717
|
+
else if (typeof status === "string") {
|
|
1718
|
+
query.status = status;
|
|
1719
|
+
}
|
|
1720
|
+
const payments = await this._pay_db.list(query, { limit });
|
|
1753
1721
|
// Sort.
|
|
1754
1722
|
payments.sort((a, b) => b.timestamp - a.timestamp);
|
|
1755
1723
|
// Response.
|
|
1756
|
-
return
|
|
1724
|
+
return (for_public
|
|
1725
|
+
? payments.map(p => Payment.anonymize(p))
|
|
1726
|
+
: payments);
|
|
1757
1727
|
}
|
|
1758
|
-
// Get all refundable payments.
|
|
1759
1728
|
/* @docs:
|
|
1760
1729
|
@title: Get Refundable Payments.
|
|
1761
1730
|
@desc: Get all payments that are refundable.
|
|
@@ -1771,24 +1740,17 @@ export class Paddle {
|
|
|
1771
1740
|
@type: number
|
|
1772
1741
|
@desc: Limit the amount of response payment objects.
|
|
1773
1742
|
*/
|
|
1774
|
-
async get_refundable_payments({ uid, days = 30, limit = undefined, }) {
|
|
1775
|
-
const
|
|
1776
|
-
const all_payments = await this.get_payments({ uid, days, limit, status: "paid" });
|
|
1777
|
-
all_payments.iterate((
|
|
1778
|
-
const
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
line_items.push(item);
|
|
1782
|
-
}
|
|
1783
|
-
});
|
|
1784
|
-
if (line_items.length > 0) {
|
|
1785
|
-
payment.line_items = line_items;
|
|
1786
|
-
payments.push(payment);
|
|
1743
|
+
async get_refundable_payments({ uid, days = 30, limit = undefined, for_public, }) {
|
|
1744
|
+
const out = [];
|
|
1745
|
+
const all_payments = await this.get_payments({ uid, days, limit, status: "paid", for_public });
|
|
1746
|
+
all_payments.iterate((pmt) => {
|
|
1747
|
+
const refundable = pmt.line_items.filter((li) => li.status === "paid" && li.total > 0);
|
|
1748
|
+
if (refundable.length > 0) {
|
|
1749
|
+
out.push({ ...pmt, line_items: refundable });
|
|
1787
1750
|
}
|
|
1788
1751
|
});
|
|
1789
|
-
return
|
|
1752
|
+
return out;
|
|
1790
1753
|
}
|
|
1791
|
-
// Get all refunded payments.
|
|
1792
1754
|
/* @docs:
|
|
1793
1755
|
@title: Get Refunded Payments.
|
|
1794
1756
|
@desc: Get all payments that are successfully refunded.
|
|
@@ -1804,24 +1766,17 @@ export class Paddle {
|
|
|
1804
1766
|
@type: number
|
|
1805
1767
|
@desc: Limit the amount of response payment objects.
|
|
1806
1768
|
*/
|
|
1807
|
-
async get_refunded_payments({ uid, days = 30, limit = undefined, }) {
|
|
1808
|
-
const
|
|
1809
|
-
const all_payments = await this.get_payments({ uid, days, limit, status: "paid" });
|
|
1810
|
-
all_payments.iterate((
|
|
1811
|
-
const
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
line_items.push(item);
|
|
1815
|
-
}
|
|
1816
|
-
});
|
|
1817
|
-
if (line_items.length > 0) {
|
|
1818
|
-
payment.line_items = line_items;
|
|
1819
|
-
payments.push(payment);
|
|
1769
|
+
async get_refunded_payments({ uid, days = 30, limit = undefined, for_public, }) {
|
|
1770
|
+
const out = [];
|
|
1771
|
+
const all_payments = await this.get_payments({ uid, days, limit, status: "paid", for_public });
|
|
1772
|
+
all_payments.iterate((pmt) => {
|
|
1773
|
+
const refundable = pmt.line_items.filter((li) => li.status === "refunded" && li.total > 0);
|
|
1774
|
+
if (refundable.length > 0) {
|
|
1775
|
+
out.push({ ...pmt, line_items: refundable });
|
|
1820
1776
|
}
|
|
1821
1777
|
});
|
|
1822
|
-
return
|
|
1778
|
+
return out;
|
|
1823
1779
|
}
|
|
1824
|
-
// Get all payments that are currently in the refunding process.
|
|
1825
1780
|
/* @docs:
|
|
1826
1781
|
@title: Get Refunding Payments.
|
|
1827
1782
|
@desc: Get all payments that are currently in the refunding process.
|
|
@@ -1837,24 +1792,17 @@ export class Paddle {
|
|
|
1837
1792
|
@type: number
|
|
1838
1793
|
@desc: Limit the amount of response payment objects.
|
|
1839
1794
|
*/
|
|
1840
|
-
async get_refunding_payments({ uid, days = undefined, limit = undefined, }) {
|
|
1841
|
-
const
|
|
1842
|
-
const all_payments = await this.get_payments({ uid, days, limit, status: "paid" });
|
|
1843
|
-
all_payments.iterate((
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
line_items.push(item);
|
|
1848
|
-
}
|
|
1849
|
-
});
|
|
1850
|
-
if (line_items.length > 0) {
|
|
1851
|
-
payment.line_items = line_items;
|
|
1852
|
-
payments.push(payment);
|
|
1795
|
+
async get_refunding_payments({ uid, days = undefined, limit = undefined, for_public, }) {
|
|
1796
|
+
const out = [];
|
|
1797
|
+
const all_payments = await this.get_payments({ uid, days, limit, status: "paid", for_public });
|
|
1798
|
+
all_payments.iterate((pmt) => {
|
|
1799
|
+
const refundable = pmt.line_items.filter((li) => li.status === "refunding" && li.total > 0);
|
|
1800
|
+
if (refundable.length > 0) {
|
|
1801
|
+
out.push({ ...pmt, line_items: refundable });
|
|
1853
1802
|
}
|
|
1854
1803
|
});
|
|
1855
|
-
return
|
|
1804
|
+
return out;
|
|
1856
1805
|
}
|
|
1857
|
-
// Refund a payment.
|
|
1858
1806
|
/* @docs:
|
|
1859
1807
|
@title: Refund Payment.
|
|
1860
1808
|
@desc: Refund a payment based on the payment id.
|
|
@@ -1939,7 +1887,6 @@ export class Paddle {
|
|
|
1939
1887
|
// Update the payment object.
|
|
1940
1888
|
await this._save_payment(payment);
|
|
1941
1889
|
}
|
|
1942
|
-
// Cancel a subscription.
|
|
1943
1890
|
/* @docs:
|
|
1944
1891
|
@title: Cancel Subscription.
|
|
1945
1892
|
@desc: Cancel a subscription based on the retrieved payment object or id.
|
|
@@ -1980,7 +1927,6 @@ export class Paddle {
|
|
|
1980
1927
|
});
|
|
1981
1928
|
}
|
|
1982
1929
|
}
|
|
1983
|
-
// Cancel subscription by subscription id.
|
|
1984
1930
|
/* @docs:
|
|
1985
1931
|
@title: Cancel subscription by subscription id.
|
|
1986
1932
|
@desc: Cancel a subscription based on the retrieved subscription object or id.
|
|
@@ -2001,7 +1947,6 @@ export class Paddle {
|
|
|
2001
1947
|
}
|
|
2002
1948
|
return await this._cancel_subscription(subscription, immediate);
|
|
2003
1949
|
}
|
|
2004
|
-
// Get subscriptioms.
|
|
2005
1950
|
/* @docs:
|
|
2006
1951
|
@title: Get active subscriptions
|
|
2007
1952
|
@desc: Get the active subscriptions of a user.
|
|
@@ -2022,7 +1967,6 @@ export class Paddle {
|
|
|
2022
1967
|
async get_subscriptions(uid) {
|
|
2023
1968
|
return await this._get_subscriptions(uid);
|
|
2024
1969
|
}
|
|
2025
|
-
// Is subscribed.
|
|
2026
1970
|
/* @docs:
|
|
2027
1971
|
@title: Is Subscribed
|
|
2028
1972
|
@desc: Check if a user is subscribed to a product.
|
|
@@ -2038,7 +1982,6 @@ export class Paddle {
|
|
|
2038
1982
|
async is_subscribed(uid, product) {
|
|
2039
1983
|
return await this._check_subscription(uid, product, false);
|
|
2040
1984
|
}
|
|
2041
|
-
// Generate an invoice.
|
|
2042
1985
|
/* @docs:
|
|
2043
1986
|
@title: Generate Invoice
|
|
2044
1987
|
@desc:
|
|
@@ -2248,17 +2191,24 @@ export class Paddle {
|
|
|
2248
2191
|
// doc.pipe(fs.createWriteStream(path.str()));
|
|
2249
2192
|
// return path;
|
|
2250
2193
|
// Get as bytes.
|
|
2251
|
-
const
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
});
|
|
2258
|
-
stream.on('error', (error) => {
|
|
2259
|
-
reject(error);
|
|
2260
|
-
});
|
|
2194
|
+
const chunks = [];
|
|
2195
|
+
return await new Promise((resolve, reject) => {
|
|
2196
|
+
doc.on("data", (chunk) => chunks.push(chunk));
|
|
2197
|
+
doc.on("end", () => resolve(Buffer.concat(chunks)));
|
|
2198
|
+
doc.on("error", (err) => reject(err));
|
|
2199
|
+
doc.end();
|
|
2261
2200
|
});
|
|
2201
|
+
// const stream = doc.pipe(blobstream());
|
|
2202
|
+
// doc.end();
|
|
2203
|
+
// return new Promise((resolve, reject) => {
|
|
2204
|
+
// stream.on('finish', () => {
|
|
2205
|
+
// const bytes = stream.toBuffer();
|
|
2206
|
+
// resolve(bytes);
|
|
2207
|
+
// });
|
|
2208
|
+
// stream.on('error', (error) => {
|
|
2209
|
+
// reject(error);
|
|
2210
|
+
// });
|
|
2211
|
+
// });
|
|
2262
2212
|
}
|
|
2263
2213
|
// ---------------------------------------------------------
|
|
2264
2214
|
// Development.
|
|
@@ -2280,7 +2230,7 @@ export class Paddle {
|
|
|
2280
2230
|
// Cancel.
|
|
2281
2231
|
for (const sub of subs) {
|
|
2282
2232
|
if (sub.status === "active") {
|
|
2283
|
-
|
|
2233
|
+
this.server.log("Cancelling subscription ", sub.id);
|
|
2284
2234
|
await this._req("POST", `/subscriptions/${sub.id}/cancel`, {
|
|
2285
2235
|
effective_from: "immediately",
|
|
2286
2236
|
});
|
|
@@ -2288,4 +2238,19 @@ export class Paddle {
|
|
|
2288
2238
|
}
|
|
2289
2239
|
}
|
|
2290
2240
|
}
|
|
2291
|
-
|
|
2241
|
+
/** Nested types for the {@link Paddle} class */
|
|
2242
|
+
(function (Paddle) {
|
|
2243
|
+
/** Paddle api request error. */
|
|
2244
|
+
class RequestError extends Error {
|
|
2245
|
+
status_code;
|
|
2246
|
+
constructor(err, status_code) {
|
|
2247
|
+
super(err);
|
|
2248
|
+
this.status_code = status_code;
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
Paddle.RequestError = RequestError;
|
|
2252
|
+
})(Paddle || (Paddle = {}));
|
|
2253
|
+
// APPLY_FIX
|
|
2254
|
+
/**
|
|
2255
|
+
* @todo if undeprecate: ASK claude to audit.
|
|
2256
|
+
*/
|