@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,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/*
|
|
2
3
|
* @author: Daan van den Bergh
|
|
3
4
|
* @copyright: © 2022 - 2024 Daan van den Bergh.
|
|
@@ -5,31 +6,36 @@
|
|
|
5
6
|
// Imports.
|
|
6
7
|
import { Utils } from "./utils.js";
|
|
7
8
|
import { User } from "./user.js";
|
|
8
|
-
import { HStack, VStack, } from "../ui/stack";
|
|
9
|
-
import { Text } from "../ui/text";
|
|
10
|
-
import { Title } from "../ui/title";
|
|
11
|
-
import { ForEach } from "../ui/for_each";
|
|
12
|
-
import { Image, ImageMask } from "../ui/image";
|
|
13
|
-
import { RingLoader } from "../ui/loaders";
|
|
14
|
-
import { BorderButton } from "../ui/border_button";
|
|
15
|
-
import { LoaderButton } from "../ui/loader_button";
|
|
16
|
-
import { Divider } from "../ui/divider";
|
|
17
|
-
import { Input, ExtendedSelect, ExtendedInput } from "../ui/input";
|
|
18
|
-
import { Spacer } from "../ui/spacer";
|
|
19
|
-
import { Form } from "../ui/form";
|
|
20
|
-
import { YesNoPopup } from "../ui/popup";
|
|
9
|
+
import { HStack, VStack, } from "../ui/stack.js";
|
|
10
|
+
import { Text } from "../ui/text.js";
|
|
11
|
+
import { Title } from "../ui/title.js";
|
|
12
|
+
import { ForEach } from "../ui/for_each.js";
|
|
13
|
+
import { Image, ImageMask } from "../ui/image.js";
|
|
14
|
+
import { RingLoader } from "../ui/loaders.js";
|
|
15
|
+
import { BorderButton } from "../ui/border_button.js";
|
|
16
|
+
import { LoaderButton } from "../ui/loader_button.js";
|
|
17
|
+
import { Divider } from "../ui/divider.js";
|
|
18
|
+
import { Input, ExtendedSelect, ExtendedInput } from "../ui/input.js";
|
|
19
|
+
import { Spacer } from "../ui/spacer.js";
|
|
20
|
+
import { Form } from "../ui/form.js";
|
|
21
|
+
import { YesNoPopup } from "../ui/popup.js";
|
|
21
22
|
import { Span } from "../ui/span.js";
|
|
23
|
+
import { request } from "./request.js";
|
|
22
24
|
// ---------------------------------------------------------
|
|
23
25
|
// Payments Object.
|
|
24
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated using stripe from now on.
|
|
28
|
+
*/
|
|
29
|
+
export var Payments;
|
|
30
|
+
(function (Payments) {
|
|
25
31
|
// ---------------------------------------------------------
|
|
26
32
|
// Private Properties.
|
|
27
|
-
client_key
|
|
33
|
+
const client_key = "{{PADDLE_CLIENT_KEY}}";
|
|
28
34
|
// @ts-ignore
|
|
29
|
-
sandbox
|
|
35
|
+
Payments.sandbox = "{{PADDLE_SANDBOX}}" === "true";
|
|
30
36
|
// @ts-ignore
|
|
31
|
-
tax_inclusive
|
|
32
|
-
countries
|
|
37
|
+
Payments.tax_inclusive = "{{PADDLE_INCLUSIVE_TAX}}" === "true";
|
|
38
|
+
Payments.countries = {
|
|
33
39
|
"AD": { name: "🇦🇩 Andorra", calling_code: "+376" },
|
|
34
40
|
"AE": { name: "🇦🇪 United Arab Emirates", calling_code: "+971" },
|
|
35
41
|
"AF": { name: "🇦🇫 Afghanistan", calling_code: "+93" },
|
|
@@ -279,34 +285,34 @@ const Payments = {
|
|
|
279
285
|
"ZA": { name: "🇿🇦 South Africa", calling_code: "+27" },
|
|
280
286
|
"ZM": { name: "🇿🇲 Zambia", calling_code: "+260" },
|
|
281
287
|
"ZW": { name: "🇿🇼 Zimbabwe", calling_code: "+263" }
|
|
282
|
-
}
|
|
283
|
-
_paddle_initialized
|
|
284
|
-
_payment_element
|
|
285
|
-
_sign_in_redirect
|
|
286
|
-
|
|
287
|
-
_steps_element
|
|
288
|
-
_steps_container
|
|
289
|
-
_overview_container
|
|
290
|
-
_order_container
|
|
291
|
-
_billing_container
|
|
292
|
-
_payment_container
|
|
293
|
-
_processing_container
|
|
294
|
-
_checkout_button
|
|
295
|
-
_prev_step_button
|
|
296
|
-
_style
|
|
297
|
-
_currency_symbol
|
|
298
|
-
_render_payment_element_reject
|
|
299
|
-
_render_payment_element_resolve
|
|
300
|
-
_refunds_element
|
|
301
|
-
_refunds_container
|
|
302
|
-
_processing_element
|
|
303
|
-
_theme
|
|
304
|
-
_products
|
|
305
|
-
_days_refundable
|
|
306
|
-
on_error
|
|
288
|
+
};
|
|
289
|
+
let _paddle_initialized = false;
|
|
290
|
+
let _payment_element = undefined; // Replace 'any' with the actual type if known.
|
|
291
|
+
let _sign_in_redirect = undefined;
|
|
292
|
+
let _payment_step = 0;
|
|
293
|
+
let _steps_element = undefined;
|
|
294
|
+
let _steps_container = undefined;
|
|
295
|
+
let _overview_container = undefined;
|
|
296
|
+
let _order_container = undefined;
|
|
297
|
+
let _billing_container = undefined;
|
|
298
|
+
let _payment_container = undefined;
|
|
299
|
+
let _processing_container = undefined;
|
|
300
|
+
let _checkout_button = undefined;
|
|
301
|
+
let _prev_step_button = undefined;
|
|
302
|
+
let _style = undefined;
|
|
303
|
+
let _currency_symbol = undefined;
|
|
304
|
+
let _render_payment_element_reject = undefined;
|
|
305
|
+
let _render_payment_element_resolve = undefined;
|
|
306
|
+
let _refunds_element = undefined;
|
|
307
|
+
let _refunds_container = undefined;
|
|
308
|
+
let _processing_element = undefined;
|
|
309
|
+
let _theme = undefined;
|
|
310
|
+
let _products = undefined;
|
|
311
|
+
let _days_refundable = 30; // **Added Property**
|
|
312
|
+
Payments.on_error = () => { };
|
|
307
313
|
// Additional properties that might be inferred from function bodies:
|
|
308
|
-
_refund_policy
|
|
309
|
-
_cancellation_policy
|
|
314
|
+
let _refund_policy; // Used in commented code
|
|
315
|
+
let _cancellation_policy; // Used in commented code
|
|
310
316
|
// cart: {
|
|
311
317
|
// items: [] as any[], // Replace 'any' with the actual item type.
|
|
312
318
|
// refresh: function() { /* Implement refresh logic */ },
|
|
@@ -314,93 +320,97 @@ const Payments = {
|
|
|
314
320
|
// add: async function(productId: string, quantity: number) { /* Implement add logic */ },
|
|
315
321
|
// remove: async function(productId: string, quantity: number | "all") { /* Implement remove logic */ },
|
|
316
322
|
// },
|
|
317
|
-
_billing_element
|
|
318
|
-
_billing_details
|
|
319
|
-
_overview_subtotal
|
|
320
|
-
_overview_total
|
|
321
|
-
_overview_subtotal_tax
|
|
322
|
-
_overview_tax_container
|
|
323
|
-
_overview_incl_excl_tax
|
|
324
|
-
_overview_element
|
|
325
|
-
_order_element
|
|
323
|
+
let _billing_element; // Replace 'any' with the actual type if known.
|
|
324
|
+
let _billing_details; // Replace 'any' with the actual type if known.
|
|
325
|
+
let _overview_subtotal; // Replace 'any' with the actual type if known.
|
|
326
|
+
let _overview_total; // Replace 'any' with the actual type if known.
|
|
327
|
+
let _overview_subtotal_tax; // Replace 'any' with the actual type if known.
|
|
328
|
+
let _overview_tax_container; // Replace 'any' with the actual type if known.
|
|
329
|
+
let _overview_incl_excl_tax; // Replace 'any' with the actual type if known.
|
|
330
|
+
let _overview_element; // Replace 'any' with the actual type if known.
|
|
331
|
+
let _order_element; // Replace 'any' with the actual type if known.
|
|
326
332
|
// ---------------------------------------------------------
|
|
327
333
|
// Private Methods.
|
|
328
334
|
/**
|
|
329
335
|
* Initialize Paddle with the provided client key and set up event callbacks.
|
|
330
336
|
*/
|
|
331
|
-
|
|
332
|
-
if (
|
|
333
|
-
if (
|
|
337
|
+
function _initialize_paddle() {
|
|
338
|
+
if (_paddle_initialized !== true) {
|
|
339
|
+
if (Payments.sandbox) {
|
|
334
340
|
Paddle.Environment.set("sandbox");
|
|
335
341
|
}
|
|
336
342
|
Paddle.Setup({
|
|
337
|
-
token:
|
|
343
|
+
token: client_key,
|
|
338
344
|
eventCallback: (data) => {
|
|
339
345
|
if (data.name === "checkout.loaded") {
|
|
340
|
-
|
|
346
|
+
_render_payment_element_resolve();
|
|
341
347
|
}
|
|
342
348
|
else if (data.name === "checkout.completed") {
|
|
343
|
-
|
|
349
|
+
_show_processing("success");
|
|
344
350
|
}
|
|
345
351
|
else if (data.name === "checkout.payment.initiated") {
|
|
346
352
|
// Uncomment and implement if needed.
|
|
347
|
-
//
|
|
353
|
+
// _show_processing("processing");
|
|
348
354
|
}
|
|
349
355
|
else if (data.name === "checkout.payment.failed") {
|
|
350
|
-
|
|
356
|
+
_show_processing("error");
|
|
351
357
|
}
|
|
352
358
|
else if (data.type === "checkout.error") {
|
|
353
359
|
if (data.error?.detail) {
|
|
354
360
|
console.error(data);
|
|
355
|
-
|
|
361
|
+
Payments.on_error(data.error.detail);
|
|
356
362
|
}
|
|
357
363
|
else {
|
|
358
364
|
console.error(data);
|
|
359
|
-
|
|
365
|
+
Payments.on_error(new Error("Unknown error"));
|
|
360
366
|
}
|
|
361
|
-
|
|
367
|
+
_render_payment_element_reject(data.detail.split("|")[0]);
|
|
362
368
|
}
|
|
363
369
|
else if (data.type === "checkout.warning") {
|
|
364
|
-
if (
|
|
370
|
+
if (Payments.sandbox) {
|
|
365
371
|
console.log("Checkout warning:", data);
|
|
366
372
|
}
|
|
367
373
|
}
|
|
368
374
|
else {
|
|
369
375
|
// Handle other events if necessary.
|
|
370
376
|
// Uncomment for debugging.
|
|
371
|
-
// if (
|
|
377
|
+
// if (sandbox) {
|
|
372
378
|
// console.log("Event", data);
|
|
373
379
|
// }
|
|
374
380
|
}
|
|
375
381
|
}
|
|
376
382
|
});
|
|
377
|
-
|
|
383
|
+
_paddle_initialized = true;
|
|
378
384
|
}
|
|
379
|
-
}
|
|
385
|
+
}
|
|
380
386
|
/**
|
|
381
387
|
* Reset the payment element by removing it if it exists.
|
|
382
388
|
*/
|
|
383
|
-
|
|
384
|
-
if (
|
|
385
|
-
|
|
389
|
+
function _reset_payment_element() {
|
|
390
|
+
if (_payment_element !== undefined) {
|
|
391
|
+
_payment_element.remove();
|
|
386
392
|
}
|
|
387
|
-
|
|
388
|
-
}
|
|
393
|
+
_payment_element = undefined;
|
|
394
|
+
}
|
|
389
395
|
/**
|
|
390
396
|
* Initialize the order by verifying authentication and making a POST request.
|
|
391
397
|
*/
|
|
392
|
-
|
|
398
|
+
async function _init_order() {
|
|
393
399
|
try {
|
|
394
|
-
if (
|
|
395
|
-
Utils.redirect(
|
|
400
|
+
if (_sign_in_redirect != null && !User.is_authenticated()) {
|
|
401
|
+
Utils.redirect(_sign_in_redirect);
|
|
396
402
|
}
|
|
397
|
-
const
|
|
403
|
+
const payload = {
|
|
404
|
+
items: Cart.items,
|
|
405
|
+
};
|
|
406
|
+
const response = await request({
|
|
398
407
|
method: "POST",
|
|
399
|
-
url: "/volt/payments/init",
|
|
400
|
-
data:
|
|
401
|
-
items: this.cart.items,
|
|
402
|
-
}
|
|
408
|
+
url: "/volt/api/v1/payments/init",
|
|
409
|
+
data: payload,
|
|
403
410
|
});
|
|
411
|
+
if (response.error) {
|
|
412
|
+
throw new Error(response.error.message);
|
|
413
|
+
}
|
|
404
414
|
// Handle response if necessary.
|
|
405
415
|
}
|
|
406
416
|
catch (err) {
|
|
@@ -409,26 +419,26 @@ const Payments = {
|
|
|
409
419
|
}
|
|
410
420
|
throw new Error(err);
|
|
411
421
|
}
|
|
412
|
-
}
|
|
422
|
+
}
|
|
413
423
|
/**
|
|
414
424
|
* Set the current step in the payment process.
|
|
415
425
|
*/
|
|
416
|
-
|
|
426
|
+
async function _set_step() {
|
|
417
427
|
// Switch step.
|
|
418
|
-
switch (
|
|
428
|
+
switch (_payment_step) {
|
|
419
429
|
// Order.
|
|
420
430
|
case 0: {
|
|
421
431
|
// Select the current step.
|
|
422
|
-
|
|
432
|
+
_steps_element.select(_payment_step);
|
|
423
433
|
// Show and hide relevant containers.
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
//
|
|
431
|
-
|
|
434
|
+
_overview_container.show();
|
|
435
|
+
_order_container.show();
|
|
436
|
+
_billing_container.hide();
|
|
437
|
+
_payment_container.hide();
|
|
438
|
+
_processing_container.hide();
|
|
439
|
+
_checkout_button.nodes.text.text("Next");
|
|
440
|
+
// _policy_checkbox.hide();
|
|
441
|
+
_prev_step_button.hide();
|
|
432
442
|
break;
|
|
433
443
|
}
|
|
434
444
|
// Address.
|
|
@@ -437,139 +447,139 @@ const Payments = {
|
|
|
437
447
|
const min_duration = new Promise(resolve => setTimeout(resolve, 350));
|
|
438
448
|
// Verify the order.
|
|
439
449
|
try {
|
|
440
|
-
await
|
|
450
|
+
await _init_order();
|
|
441
451
|
}
|
|
442
452
|
catch (err) {
|
|
443
|
-
--
|
|
453
|
+
--_payment_step;
|
|
444
454
|
console.error(err);
|
|
445
|
-
|
|
455
|
+
Payments.on_error(err);
|
|
446
456
|
return null;
|
|
447
457
|
}
|
|
448
458
|
// Render billing element.
|
|
449
|
-
|
|
459
|
+
_render_billing_element();
|
|
450
460
|
// Await minimum duration.
|
|
451
461
|
await min_duration;
|
|
452
462
|
// Select the current step.
|
|
453
|
-
|
|
463
|
+
_steps_element.select(_payment_step);
|
|
454
464
|
// Show and hide relevant containers.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
//
|
|
462
|
-
|
|
465
|
+
_overview_container.show();
|
|
466
|
+
_order_container.hide();
|
|
467
|
+
_billing_container.show();
|
|
468
|
+
_payment_container.hide();
|
|
469
|
+
_processing_container.hide();
|
|
470
|
+
_checkout_button.nodes.text.text("Next");
|
|
471
|
+
// _policy_checkbox.hide();
|
|
472
|
+
_prev_step_button.show();
|
|
463
473
|
break;
|
|
464
474
|
}
|
|
465
475
|
// Payment.
|
|
466
476
|
case 2: {
|
|
467
477
|
// Check if the billing details are entered correctly.
|
|
468
478
|
try {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
delete
|
|
479
|
+
_billing_details = _billing_element.data();
|
|
480
|
+
_billing_details.phone_number = _billing_details.phone_country_code + _billing_details.phone_number;
|
|
481
|
+
delete _billing_details.phone_country_code;
|
|
472
482
|
}
|
|
473
483
|
catch (error) {
|
|
474
|
-
--
|
|
484
|
+
--_payment_step;
|
|
475
485
|
console.error(error);
|
|
476
|
-
|
|
486
|
+
Payments.on_error(error);
|
|
477
487
|
return null;
|
|
478
488
|
}
|
|
479
489
|
// Render payment element.
|
|
480
490
|
try {
|
|
481
|
-
await
|
|
491
|
+
await _render_payment_element();
|
|
482
492
|
}
|
|
483
493
|
catch (error) {
|
|
484
|
-
--
|
|
494
|
+
--_payment_step;
|
|
485
495
|
console.error(error);
|
|
486
|
-
|
|
496
|
+
Payments.on_error(error);
|
|
487
497
|
return null;
|
|
488
498
|
}
|
|
489
499
|
// Select the current step.
|
|
490
|
-
|
|
500
|
+
_steps_element.select(_payment_step);
|
|
491
501
|
// Show and hide relevant containers.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
//
|
|
499
|
-
|
|
502
|
+
_overview_container.hide();
|
|
503
|
+
_order_container.hide();
|
|
504
|
+
_billing_container.hide();
|
|
505
|
+
_payment_container.show();
|
|
506
|
+
_processing_container.hide();
|
|
507
|
+
_checkout_button.nodes.text.text("Checkout");
|
|
508
|
+
// _policy_checkbox.show();
|
|
509
|
+
_prev_step_button.show();
|
|
500
510
|
break;
|
|
501
511
|
}
|
|
502
512
|
}
|
|
503
|
-
}
|
|
513
|
+
}
|
|
504
514
|
/**
|
|
505
515
|
* Navigate to the next step in the payment process.
|
|
506
516
|
*/
|
|
507
|
-
|
|
508
|
-
if (
|
|
509
|
-
++
|
|
510
|
-
return
|
|
517
|
+
async function _next() {
|
|
518
|
+
if (_payment_step < 3) {
|
|
519
|
+
++_payment_step;
|
|
520
|
+
return _set_step();
|
|
511
521
|
}
|
|
512
|
-
else if (
|
|
513
|
-
return
|
|
522
|
+
else if (_payment_step === 3) {
|
|
523
|
+
return _set_step();
|
|
514
524
|
}
|
|
515
|
-
}
|
|
525
|
+
}
|
|
516
526
|
/**
|
|
517
527
|
* Navigate to the previous step in the payment process.
|
|
518
528
|
*/
|
|
519
|
-
|
|
520
|
-
if (
|
|
521
|
-
--
|
|
522
|
-
return
|
|
529
|
+
async function _prev() {
|
|
530
|
+
if (_payment_step > 0) {
|
|
531
|
+
--_payment_step;
|
|
532
|
+
return _set_step();
|
|
523
533
|
}
|
|
524
|
-
}
|
|
534
|
+
}
|
|
525
535
|
/**
|
|
526
536
|
* Render the steps element in the UI.
|
|
527
537
|
*/
|
|
528
|
-
|
|
538
|
+
function _render_steps_element() {
|
|
529
539
|
// Shortcuts.
|
|
530
|
-
const style =
|
|
540
|
+
const style = _style;
|
|
531
541
|
// The previous step button.
|
|
532
|
-
|
|
542
|
+
_prev_step_button = HStack(ImageMask("/volt_static/payments/arrow.long.webp")
|
|
533
543
|
.frame(15, 15)
|
|
534
|
-
.mask_color(
|
|
544
|
+
.mask_color(_style.fg_1)
|
|
535
545
|
.transition_mask("background 300ms ease-in-out")
|
|
536
546
|
.transform("rotate(180deg)")
|
|
537
547
|
.margin_right(10), Text("Previous Step")
|
|
538
|
-
.color(
|
|
548
|
+
.color(_style.fg_1)
|
|
539
549
|
.transition("color 300ms ease-in-out")
|
|
540
550
|
.padding(0)
|
|
541
551
|
.margin(0)
|
|
542
552
|
.font_size(14))
|
|
543
553
|
.hide()
|
|
544
554
|
.on_mouse_over_out((e) => {
|
|
545
|
-
e.child(0).color(
|
|
546
|
-
e.child(1).color(
|
|
555
|
+
e.child(0).color(_style.fg);
|
|
556
|
+
e.child(1).color(_style.fg);
|
|
547
557
|
}, (e) => {
|
|
548
|
-
e.child(0).color(
|
|
549
|
-
e.child(1).color(
|
|
558
|
+
e.child(0).color(_style.fg_1);
|
|
559
|
+
e.child(1).color(_style.fg_1);
|
|
550
560
|
})
|
|
551
561
|
.on_click(() => {
|
|
552
|
-
|
|
562
|
+
_prev()
|
|
553
563
|
.catch((err) => console.error(err));
|
|
554
564
|
})
|
|
555
565
|
.center_vertical();
|
|
556
566
|
// The steps element.
|
|
557
|
-
|
|
567
|
+
_steps_element = HStack(ForEach(["Order Details", "Billing Details", "Payment Details", "Processing Details"], (item, index) => {
|
|
558
568
|
const stack = HStack(VStack((index + 1).toString())
|
|
559
569
|
.font_size(11)
|
|
560
570
|
.padding(0)
|
|
561
571
|
.margin(0)
|
|
562
|
-
.color(index === 0 ?
|
|
572
|
+
.color(index === 0 ? _style.selected.fg : _style.fg_1)
|
|
563
573
|
.frame(17.5, 17.5)
|
|
564
|
-
.background(index === 0 ?
|
|
574
|
+
.background(index === 0 ? _style.selected.bg : _style.bg_1)
|
|
565
575
|
.transition("color 300ms ease-in-out, background 300ms ease-in-out")
|
|
566
576
|
.border_radius("50%")
|
|
567
577
|
.margin_right(15)
|
|
568
578
|
.flex_shrink(0)
|
|
569
579
|
.center()
|
|
570
580
|
.center_vertical()
|
|
571
|
-
.border(1,
|
|
572
|
-
.color(index === 0 ?
|
|
581
|
+
.border(1, _style.divider_bg), Text(item)
|
|
582
|
+
.color(index === 0 ? _style.fg : _style.fg_1)
|
|
573
583
|
.transition("color 300ms ease-in-out")
|
|
574
584
|
.padding(0)
|
|
575
585
|
.font_size(14)
|
|
@@ -577,9 +587,9 @@ const Payments = {
|
|
|
577
587
|
.center_vertical()
|
|
578
588
|
.margin_right(25);
|
|
579
589
|
return stack;
|
|
580
|
-
}), Spacer().min_frame(10, 1),
|
|
590
|
+
}), Spacer().min_frame(10, 1), _prev_step_button)
|
|
581
591
|
.overflow_x("scroll")
|
|
582
|
-
.class("
|
|
592
|
+
.class("volt_hide_scrollbar")
|
|
583
593
|
.extend({
|
|
584
594
|
selected_index: 0,
|
|
585
595
|
/**
|
|
@@ -604,74 +614,74 @@ const Payments = {
|
|
|
604
614
|
},
|
|
605
615
|
});
|
|
606
616
|
// Append the steps element to the steps container.
|
|
607
|
-
|
|
608
|
-
}
|
|
617
|
+
_steps_container.append(_steps_element);
|
|
618
|
+
}
|
|
609
619
|
/**
|
|
610
620
|
* Render the overview element in the UI.
|
|
611
621
|
*/
|
|
612
|
-
|
|
622
|
+
function _render_overview_element() {
|
|
613
623
|
// The subtotal price from the overview.
|
|
614
|
-
|
|
615
|
-
.color(
|
|
616
|
-
.font_size(
|
|
624
|
+
_overview_subtotal = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
|
|
625
|
+
.color(_style.fg)
|
|
626
|
+
.font_size(_style.font_size)
|
|
617
627
|
.flex_shrink(0)
|
|
618
628
|
.margin(0)
|
|
619
629
|
.padding(0);
|
|
620
630
|
// The total price from the overview.
|
|
621
|
-
|
|
631
|
+
_overview_total = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
|
|
622
632
|
.font_weight("bold")
|
|
623
|
-
.color(
|
|
624
|
-
.font_size(
|
|
633
|
+
.color(_style.fg)
|
|
634
|
+
.font_size(_style.font_size)
|
|
625
635
|
.flex_shrink(0)
|
|
626
636
|
.margin(0)
|
|
627
637
|
.padding(0);
|
|
628
638
|
// The subtotal VAT price from the overview.
|
|
629
|
-
|
|
630
|
-
.color(
|
|
631
|
-
.font_size(
|
|
639
|
+
_overview_subtotal_tax = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
|
|
640
|
+
.color(_style.fg)
|
|
641
|
+
.font_size(_style.font_size)
|
|
632
642
|
.flex_shrink(0)
|
|
633
643
|
.margin(0)
|
|
634
644
|
.padding(0);
|
|
635
645
|
// The tax stack.
|
|
636
|
-
|
|
637
|
-
.color(
|
|
638
|
-
.font_size(
|
|
646
|
+
_overview_tax_container = HStack(Text("Tax:")
|
|
647
|
+
.color(_style.fg)
|
|
648
|
+
.font_size(_style.font_size)
|
|
639
649
|
.stretch(true)
|
|
640
650
|
.flex_shrink(0)
|
|
641
651
|
.margin(0, 5, 0, 0)
|
|
642
652
|
.padding(0)
|
|
643
653
|
.wrap(false)
|
|
644
654
|
.overflow("hidden")
|
|
645
|
-
.text_overflow("ellipsis"),
|
|
655
|
+
.text_overflow("ellipsis"), _overview_subtotal_tax)
|
|
646
656
|
.margin_top(5);
|
|
647
657
|
// The incl/excl tax text.
|
|
648
|
-
|
|
649
|
-
.color(
|
|
650
|
-
.font_size(
|
|
658
|
+
_overview_incl_excl_tax = Text(Payments.tax_inclusive ? "incl. tax" : "excl. tax")
|
|
659
|
+
.color(_style.fg_2)
|
|
660
|
+
.font_size(_style.font_size - 6)
|
|
651
661
|
.margin(2.5, 0, 0, 0)
|
|
652
662
|
.padding(0)
|
|
653
663
|
.flex_shrink(0)
|
|
654
664
|
.text_trailing();
|
|
655
665
|
// The checkout button.
|
|
656
|
-
|
|
657
|
-
.color(
|
|
658
|
-
.background(
|
|
659
|
-
.border_radius(
|
|
660
|
-
.border(
|
|
661
|
-
.hover_brightness(...
|
|
666
|
+
_checkout_button = LoaderButton("Next")
|
|
667
|
+
.color(_style.button.fg)
|
|
668
|
+
.background(_style.button.bg)
|
|
669
|
+
.border_radius(_style.button.border_radius)
|
|
670
|
+
.border(_style.button.border_inset ? `${_style.button.border_width} inset ${_style.button.border_color}` : `${_style.button.border_width} solid ${_style.button.border_color}`)
|
|
671
|
+
.hover_brightness(..._style.button.hover_brightness)
|
|
662
672
|
.nodes.loader
|
|
663
|
-
.background(
|
|
673
|
+
.background(_style.button.fg)
|
|
664
674
|
.update()
|
|
665
675
|
.parent()
|
|
666
676
|
.on_click(async () => {
|
|
667
|
-
|
|
668
|
-
|
|
677
|
+
_checkout_button.show_loader();
|
|
678
|
+
_next()
|
|
669
679
|
.then(() => {
|
|
670
|
-
|
|
680
|
+
_checkout_button.hide_loader();
|
|
671
681
|
})
|
|
672
682
|
.catch((err) => {
|
|
673
683
|
console.error(err);
|
|
674
|
-
|
|
684
|
+
_checkout_button.hide_loader();
|
|
675
685
|
});
|
|
676
686
|
});
|
|
677
687
|
// Accept agreements (currently commented out).
|
|
@@ -683,38 +693,38 @@ const Payments = {
|
|
|
683
693
|
// " policy. I agree that my payment method may be used for recurring subscriptions.",
|
|
684
694
|
// required: true
|
|
685
695
|
// }) // @todo check text.
|
|
686
|
-
// .color(
|
|
687
|
-
// .border_color(
|
|
688
|
-
// .font_size(
|
|
689
|
-
// .focus_color(
|
|
690
|
-
// .missing_color(
|
|
691
|
-
// .inner_bg(
|
|
696
|
+
// .color(_style.fg_2)
|
|
697
|
+
// .border_color(_style.divider_bg)
|
|
698
|
+
// .font_size(_style.font_size - 6)
|
|
699
|
+
// .focus_color(_style.theme_fg)
|
|
700
|
+
// .missing_color(_style.missing_fg)
|
|
701
|
+
// .inner_bg(_style.bg)
|
|
692
702
|
// .margin_bottom(15)
|
|
693
703
|
// .hide();
|
|
694
704
|
// The overview element.
|
|
695
|
-
|
|
696
|
-
.color(
|
|
705
|
+
_overview_element = VStack(Title("Overview")
|
|
706
|
+
.color(_style.fg)
|
|
697
707
|
.width("fit-content")
|
|
698
|
-
.font_size(
|
|
708
|
+
.font_size(_style.font_size - 2)
|
|
699
709
|
.flex_shrink(0)
|
|
700
710
|
.margin(0, 0, 15, 0)
|
|
701
711
|
.letter_spacing("1px")
|
|
702
712
|
.text_transform("uppercase")
|
|
703
713
|
.ellipsis_overflow(true), HStack(Text("Subtotal:")
|
|
704
|
-
.color(
|
|
705
|
-
.font_size(
|
|
714
|
+
.color(_style.fg)
|
|
715
|
+
.font_size(_style.font_size)
|
|
706
716
|
.stretch(true)
|
|
707
717
|
.flex_shrink(0)
|
|
708
718
|
.margin(0, 5, 0, 0)
|
|
709
719
|
.padding(0)
|
|
710
720
|
.wrap(false)
|
|
711
721
|
.overflow("hidden")
|
|
712
|
-
.text_overflow("ellipsis"),
|
|
722
|
+
.text_overflow("ellipsis"), _overview_subtotal),
|
|
713
723
|
// Uncomment and define Shipping if needed.
|
|
714
724
|
// HStack(
|
|
715
725
|
// Text("Shipping:")
|
|
716
|
-
// .color(
|
|
717
|
-
// .font_size(
|
|
726
|
+
// .color(_style.fg_1)
|
|
727
|
+
// .font_size(_style.font_size)
|
|
718
728
|
// .stretch(true)
|
|
719
729
|
// .flex_shrink(0)
|
|
720
730
|
// .margin(0, 5, 0, 0)
|
|
@@ -723,8 +733,8 @@ const Payments = {
|
|
|
723
733
|
// .overflow("hidden")
|
|
724
734
|
// .text_overflow("ellipsis"),
|
|
725
735
|
// Text("free")
|
|
726
|
-
// .color(
|
|
727
|
-
// .font_size(
|
|
736
|
+
// .color(_style.fg_1)
|
|
737
|
+
// .font_size(_style.font_size)
|
|
728
738
|
// .flex_shrink(0)
|
|
729
739
|
// .margin(0)
|
|
730
740
|
// .padding(0)
|
|
@@ -733,104 +743,104 @@ const Payments = {
|
|
|
733
743
|
// .text_overflow("ellipsis"),
|
|
734
744
|
// )
|
|
735
745
|
// .margin_top(5),
|
|
736
|
-
|
|
746
|
+
_overview_tax_container, Divider()
|
|
737
747
|
.margin(20, 0, 20, 0)
|
|
738
|
-
.background(
|
|
748
|
+
.background(_style.divider_bg), HStack(Text("Total:")
|
|
739
749
|
.font_weight("bold")
|
|
740
|
-
.color(
|
|
741
|
-
.font_size(
|
|
750
|
+
.color(_style.fg)
|
|
751
|
+
.font_size(_style.font_size)
|
|
742
752
|
.stretch(true)
|
|
743
753
|
.flex_shrink(0)
|
|
744
754
|
.margin(0, 5, 0, 0)
|
|
745
755
|
.padding(0)
|
|
746
756
|
.wrap(false)
|
|
747
757
|
.overflow("hidden")
|
|
748
|
-
.text_overflow("ellipsis"), VStack(
|
|
758
|
+
.text_overflow("ellipsis"), VStack(_overview_total, _overview_incl_excl_tax))
|
|
749
759
|
.margin_bottom(25),
|
|
750
760
|
// this._policy_checkbox,
|
|
751
|
-
|
|
761
|
+
_checkout_button)
|
|
752
762
|
.extend({
|
|
753
763
|
total: 0,
|
|
754
764
|
tax: 0,
|
|
755
765
|
/**
|
|
756
766
|
* Handle unknown tax scenarios by updating the UI accordingly.
|
|
757
767
|
*/
|
|
758
|
-
unknown_tax
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
768
|
+
unknown_tax() {
|
|
769
|
+
_overview_incl_excl_tax.text(Payments.tax_inclusive ? "incl. tax" : "excl. tax");
|
|
770
|
+
_overview_tax_container.hide();
|
|
771
|
+
_overview_element.tax = 0;
|
|
772
|
+
_overview_total.text(`${_currency_symbol} ${_overview_element.total.toFixed(2)}`);
|
|
763
773
|
},
|
|
764
774
|
/**
|
|
765
775
|
* Calculate tax based on the provided country code.
|
|
766
776
|
* @param country - The country code to calculate tax for.
|
|
767
777
|
*/
|
|
768
|
-
|
|
769
|
-
|
|
778
|
+
async calc_tax(country) {
|
|
779
|
+
_initialize_paddle();
|
|
770
780
|
try {
|
|
771
781
|
const result = await Paddle.PricePreview({
|
|
772
|
-
items:
|
|
782
|
+
items: Cart.items.map((item) => {
|
|
773
783
|
return { priceId: item.product.price_id, quantity: item.quantity };
|
|
774
784
|
}),
|
|
775
785
|
address: { countryCode: country },
|
|
776
786
|
});
|
|
777
|
-
|
|
787
|
+
_overview_element.tax = 0;
|
|
778
788
|
result.data.details.lineItems.forEach((item) => {
|
|
779
|
-
|
|
789
|
+
_overview_element.tax += parseInt(item.totals.tax) / 100;
|
|
780
790
|
});
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
791
|
+
_overview_tax_container.show();
|
|
792
|
+
_overview_incl_excl_tax.text("incl. tax");
|
|
793
|
+
_overview_subtotal_tax.text(`${_currency_symbol} ${_overview_element.tax.toFixed(2)}`);
|
|
794
|
+
_overview_total.text(`${_currency_symbol} ${(_overview_element.total + _overview_element.tax).toFixed(2)}`);
|
|
785
795
|
}
|
|
786
796
|
catch (error) {
|
|
787
797
|
if (error?.error?.detail) {
|
|
788
|
-
|
|
798
|
+
Payments.on_error(error.error.detail);
|
|
789
799
|
console.error(error);
|
|
790
800
|
}
|
|
791
801
|
else {
|
|
792
802
|
console.error(error);
|
|
793
803
|
}
|
|
794
|
-
|
|
804
|
+
_overview_element.unknown_tax();
|
|
795
805
|
}
|
|
796
806
|
},
|
|
797
807
|
});
|
|
798
808
|
// Append the overview element to the overview container.
|
|
799
|
-
|
|
800
|
-
}
|
|
809
|
+
_overview_container.append(_overview_element);
|
|
810
|
+
}
|
|
801
811
|
/**
|
|
802
812
|
* Render the order element in the UI.
|
|
803
813
|
*/
|
|
804
|
-
|
|
805
|
-
|
|
814
|
+
function _render_order_element() {
|
|
815
|
+
// Render.
|
|
816
|
+
_order_element = VStack()
|
|
806
817
|
.extend({
|
|
807
818
|
/**
|
|
808
819
|
* Refresh the order element by updating the cart and UI elements.
|
|
809
820
|
*/
|
|
810
821
|
refresh() {
|
|
811
822
|
// Refresh the cart.
|
|
812
|
-
|
|
823
|
+
Cart.refresh();
|
|
813
824
|
// Shortcuts.
|
|
814
|
-
const style =
|
|
815
|
-
const
|
|
816
|
-
const cart_items = Payments.cart.items;
|
|
825
|
+
const style = _style;
|
|
826
|
+
const cart_items = Cart.items;
|
|
817
827
|
// Shopping cart view.
|
|
818
828
|
let currency_symbol = null;
|
|
819
829
|
let subtotal = 0;
|
|
820
830
|
cart_items.forEach((item) => {
|
|
821
|
-
if (currency_symbol
|
|
831
|
+
if (currency_symbol == null) {
|
|
822
832
|
currency_symbol = Payments.get_currency_symbol(item.product.currency);
|
|
823
833
|
}
|
|
824
834
|
subtotal += item.product.price * item.quantity;
|
|
825
835
|
});
|
|
826
|
-
if (currency_symbol
|
|
836
|
+
if (currency_symbol == null) {
|
|
827
837
|
currency_symbol = "$";
|
|
828
838
|
}
|
|
829
|
-
|
|
839
|
+
_currency_symbol = currency_symbol;
|
|
830
840
|
// Set the overview prices.
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
841
|
+
_overview_subtotal.text(`${currency_symbol} ${subtotal.toFixed(2)}`);
|
|
842
|
+
_overview_element.total = subtotal;
|
|
843
|
+
_overview_element.unknown_tax();
|
|
834
844
|
// Add the products.
|
|
835
845
|
this.remove_children();
|
|
836
846
|
if (cart_items.length === 0) {
|
|
@@ -904,7 +914,7 @@ const Payments = {
|
|
|
904
914
|
return null;
|
|
905
915
|
}
|
|
906
916
|
item.quantity = quantity;
|
|
907
|
-
|
|
917
|
+
Cart.save();
|
|
908
918
|
this.refresh();
|
|
909
919
|
}, 500);
|
|
910
920
|
})
|
|
@@ -983,11 +993,11 @@ const Payments = {
|
|
|
983
993
|
.on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
|
|
984
994
|
.on_click(async () => {
|
|
985
995
|
if (item.quantity === 1) {
|
|
986
|
-
await
|
|
996
|
+
await Cart.remove(item.product.id, "all");
|
|
987
997
|
this.refresh();
|
|
988
998
|
}
|
|
989
999
|
else {
|
|
990
|
-
await
|
|
1000
|
+
await Cart.remove(item.product.id, 1);
|
|
991
1001
|
this.refresh();
|
|
992
1002
|
}
|
|
993
1003
|
}), ImageMask("/volt_static/payments/plus.webp")
|
|
@@ -1002,7 +1012,7 @@ const Payments = {
|
|
|
1002
1012
|
.transition_mask("background 300ms ease-in-out")
|
|
1003
1013
|
.on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
|
|
1004
1014
|
.on_click(async () => {
|
|
1005
|
-
await
|
|
1015
|
+
await Cart.add(item.product.id, 1);
|
|
1006
1016
|
this.refresh();
|
|
1007
1017
|
}), ImageMask("/volt_static/payments/trash.webp")
|
|
1008
1018
|
.frame(20, 20)
|
|
@@ -1016,7 +1026,7 @@ const Payments = {
|
|
|
1016
1026
|
.transition_mask("background 300ms ease-in-out")
|
|
1017
1027
|
.on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
|
|
1018
1028
|
.on_click(async () => {
|
|
1019
|
-
await
|
|
1029
|
+
await Cart.remove(item.product.id, "all");
|
|
1020
1030
|
this.refresh();
|
|
1021
1031
|
}))
|
|
1022
1032
|
.center_vertical()
|
|
@@ -1042,7 +1052,7 @@ const Payments = {
|
|
|
1042
1052
|
.padding(0)
|
|
1043
1053
|
.flex_shrink(0)))
|
|
1044
1054
|
.overflow_x("scroll")
|
|
1045
|
-
.class("
|
|
1055
|
+
.class("volt_hide_scrollbar")
|
|
1046
1056
|
.width("100%")
|
|
1047
1057
|
.media("width >= 800px", (e) => {
|
|
1048
1058
|
e.wrap(false);
|
|
@@ -1066,13 +1076,13 @@ const Payments = {
|
|
|
1066
1076
|
}
|
|
1067
1077
|
});
|
|
1068
1078
|
// Append the order element to the order container.
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1079
|
+
_order_container.append(_order_element.refresh());
|
|
1080
|
+
}
|
|
1071
1081
|
// Render the refunds element.
|
|
1072
|
-
|
|
1082
|
+
function _render_refunds_element() {
|
|
1073
1083
|
// Render.
|
|
1074
|
-
const style =
|
|
1075
|
-
|
|
1084
|
+
const style = _style;
|
|
1085
|
+
_refunds_element = VStack()
|
|
1076
1086
|
.extend({
|
|
1077
1087
|
/**
|
|
1078
1088
|
* Refresh the refunds element by fetching and displaying refundable, refunding, and refunded payments.
|
|
@@ -1081,29 +1091,56 @@ const Payments = {
|
|
|
1081
1091
|
// Reset.
|
|
1082
1092
|
this.inner_html("");
|
|
1083
1093
|
// Create containers.
|
|
1084
|
-
|
|
1085
|
-
days:
|
|
1094
|
+
const refundable_res = await Payments.get_refundable_payments({
|
|
1095
|
+
days: _days_refundable,
|
|
1086
1096
|
});
|
|
1097
|
+
let refundable = [];
|
|
1098
|
+
if (refundable_res.error) {
|
|
1099
|
+
const e = new Error(refundable_res.error.message);
|
|
1100
|
+
console.error(e);
|
|
1101
|
+
Payments.on_error(e);
|
|
1102
|
+
}
|
|
1103
|
+
else {
|
|
1104
|
+
refundable = refundable_res.data;
|
|
1105
|
+
}
|
|
1087
1106
|
const refundable_container = VStack()
|
|
1088
1107
|
.extend({
|
|
1089
1108
|
title: "Refundable Payments",
|
|
1090
|
-
payments:
|
|
1109
|
+
payments: refundable,
|
|
1091
1110
|
is_refundable: true,
|
|
1092
1111
|
});
|
|
1093
|
-
|
|
1112
|
+
const refunding_res = await Payments.get_refunding_payments();
|
|
1113
|
+
let refunding = [];
|
|
1114
|
+
if (refunding_res.error) {
|
|
1115
|
+
const e = new Error(refunding_res.error.message);
|
|
1116
|
+
console.error(e);
|
|
1117
|
+
Payments.on_error(e);
|
|
1118
|
+
}
|
|
1119
|
+
else {
|
|
1120
|
+
refunding = refunding_res.data;
|
|
1121
|
+
}
|
|
1094
1122
|
const refunding_container = VStack()
|
|
1095
1123
|
.hide()
|
|
1096
1124
|
.extend({
|
|
1097
1125
|
title: "Processing Refunds",
|
|
1098
|
-
payments:
|
|
1126
|
+
payments: refunding,
|
|
1099
1127
|
is_refunding: true,
|
|
1100
1128
|
});
|
|
1101
|
-
|
|
1129
|
+
const refunded_res = await Payments.get_refunded_payments();
|
|
1130
|
+
let refunded = [];
|
|
1131
|
+
if (refunded_res.error) {
|
|
1132
|
+
const e = new Error(refunded_res.error.message);
|
|
1133
|
+
console.error(e);
|
|
1134
|
+
Payments.on_error(e);
|
|
1135
|
+
}
|
|
1136
|
+
else {
|
|
1137
|
+
refunded = refunded_res.data;
|
|
1138
|
+
}
|
|
1102
1139
|
const refunded_container = VStack()
|
|
1103
1140
|
.hide()
|
|
1104
1141
|
.extend({
|
|
1105
1142
|
title: "Refunded Payments",
|
|
1106
|
-
payments:
|
|
1143
|
+
payments: refunded,
|
|
1107
1144
|
is_refunded: true,
|
|
1108
1145
|
});
|
|
1109
1146
|
// Option bar.
|
|
@@ -1127,10 +1164,10 @@ const Payments = {
|
|
|
1127
1164
|
}
|
|
1128
1165
|
})
|
|
1129
1166
|
.on_click((e) => {
|
|
1130
|
-
e.color(
|
|
1131
|
-
e.background(
|
|
1167
|
+
e.color(_style.fg_1);
|
|
1168
|
+
e.background(_style.bg_1);
|
|
1132
1169
|
[e.parentElement.child(1), e.parentElement.child(2)].forEach((child) => {
|
|
1133
|
-
child.color(
|
|
1170
|
+
child.color(_style.fg_1);
|
|
1134
1171
|
child.background("none");
|
|
1135
1172
|
});
|
|
1136
1173
|
refundable_container.show();
|
|
@@ -1156,10 +1193,10 @@ const Payments = {
|
|
|
1156
1193
|
}
|
|
1157
1194
|
})
|
|
1158
1195
|
.on_click((e) => {
|
|
1159
|
-
e.color(
|
|
1160
|
-
e.background(
|
|
1196
|
+
e.color(_style.fg_1);
|
|
1197
|
+
e.background(_style.bg_1);
|
|
1161
1198
|
[e.parentElement.child(0), e.parentElement.child(2)].forEach((child) => {
|
|
1162
|
-
child.color(
|
|
1199
|
+
child.color(_style.fg_1);
|
|
1163
1200
|
child.background("none");
|
|
1164
1201
|
});
|
|
1165
1202
|
refundable_container.hide();
|
|
@@ -1185,10 +1222,10 @@ const Payments = {
|
|
|
1185
1222
|
}
|
|
1186
1223
|
})
|
|
1187
1224
|
.on_click((e) => {
|
|
1188
|
-
e.color(
|
|
1189
|
-
e.background(
|
|
1225
|
+
e.color(_style.fg_1);
|
|
1226
|
+
e.background(_style.bg_1);
|
|
1190
1227
|
[e.parentElement.child(0), e.parentElement.child(1)].forEach((child) => {
|
|
1191
|
-
child.color(
|
|
1228
|
+
child.color(_style.fg_1);
|
|
1192
1229
|
child.background("none");
|
|
1193
1230
|
});
|
|
1194
1231
|
refundable_container.hide();
|
|
@@ -1240,7 +1277,11 @@ const Payments = {
|
|
|
1240
1277
|
else {
|
|
1241
1278
|
await Promise.all(container.payments.map(async (payment) => {
|
|
1242
1279
|
await Promise.all(payment.line_items.map(async (item) => {
|
|
1243
|
-
|
|
1280
|
+
const res = await Payments.get_product(item.product);
|
|
1281
|
+
if (res.error) {
|
|
1282
|
+
throw new Error(res.error.message);
|
|
1283
|
+
}
|
|
1284
|
+
item.product = res.data;
|
|
1244
1285
|
}));
|
|
1245
1286
|
}));
|
|
1246
1287
|
container.append(Title(container.title)
|
|
@@ -1324,19 +1365,25 @@ const Payments = {
|
|
|
1324
1365
|
animation_duration: 300,
|
|
1325
1366
|
on_yes: async () => {
|
|
1326
1367
|
try {
|
|
1327
|
-
await Payments.create_refund(payment);
|
|
1368
|
+
const res = await Payments.create_refund(payment);
|
|
1369
|
+
if (res.error) {
|
|
1370
|
+
const e = new Error(res.error.message);
|
|
1371
|
+
console.error(e);
|
|
1372
|
+
Payments.on_error(e);
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1328
1375
|
}
|
|
1329
1376
|
catch (err) {
|
|
1330
1377
|
console.error(err);
|
|
1331
1378
|
Payments.on_error(err);
|
|
1332
|
-
return
|
|
1379
|
+
return;
|
|
1333
1380
|
}
|
|
1334
1381
|
this.refresh().then(() => {
|
|
1335
1382
|
refunding_option.click();
|
|
1336
1383
|
});
|
|
1337
1384
|
},
|
|
1338
1385
|
})
|
|
1339
|
-
.font(window.getComputedStyle(
|
|
1386
|
+
.font(window.getComputedStyle(_refunds_container).font)
|
|
1340
1387
|
.widget
|
|
1341
1388
|
.background(style.bg)
|
|
1342
1389
|
.color(style.fg_1)
|
|
@@ -1419,65 +1466,65 @@ const Payments = {
|
|
|
1419
1466
|
}
|
|
1420
1467
|
});
|
|
1421
1468
|
// Append.
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
}
|
|
1469
|
+
_refunds_element.refresh();
|
|
1470
|
+
_refunds_container.append(_refunds_element);
|
|
1471
|
+
}
|
|
1425
1472
|
// Render the address element.
|
|
1426
|
-
|
|
1427
|
-
if (
|
|
1473
|
+
function _render_billing_element() {
|
|
1474
|
+
if (_billing_element !== undefined) {
|
|
1428
1475
|
return;
|
|
1429
1476
|
}
|
|
1430
1477
|
// Utils.
|
|
1431
1478
|
const CreateInput = (args) => {
|
|
1432
1479
|
return ExtendedInput(args)
|
|
1433
|
-
.color(
|
|
1434
|
-
.font_size(
|
|
1435
|
-
.missing_color(
|
|
1436
|
-
.focus_color(
|
|
1437
|
-
.border_color(
|
|
1438
|
-
.border_radius(
|
|
1480
|
+
.color(_style.fg)
|
|
1481
|
+
.font_size(_style.font_size)
|
|
1482
|
+
.missing_color(_style.missing_fg)
|
|
1483
|
+
.focus_color(_style.theme_fg)
|
|
1484
|
+
.border_color(_style.divider_bg)
|
|
1485
|
+
.border_radius(_style.border_radius)
|
|
1439
1486
|
.input
|
|
1440
|
-
.color(
|
|
1487
|
+
.color(_style.fg_1)
|
|
1441
1488
|
.parent();
|
|
1442
1489
|
};
|
|
1443
1490
|
const CreateSelect = (args) => {
|
|
1444
1491
|
return ExtendedSelect(args)
|
|
1445
|
-
.background(
|
|
1446
|
-
.color(
|
|
1447
|
-
.font_size(
|
|
1448
|
-
.
|
|
1449
|
-
.focus_color(
|
|
1450
|
-
.border_color(
|
|
1451
|
-
.border_radius(
|
|
1492
|
+
.background(_style.bg)
|
|
1493
|
+
.color(_style.fg)
|
|
1494
|
+
.font_size(_style.font_size)
|
|
1495
|
+
.error_color(_style.missing_fg)
|
|
1496
|
+
.focus_color(_style.theme_fg)
|
|
1497
|
+
.border_color(_style.divider_bg)
|
|
1498
|
+
.border_radius(_style.border_radius)
|
|
1452
1499
|
.dropdown_height(150)
|
|
1453
1500
|
.background("transparent")
|
|
1454
1501
|
.dropdown
|
|
1455
|
-
.background(
|
|
1502
|
+
.background(_style.bg_1)
|
|
1456
1503
|
.background_blur(20)
|
|
1457
1504
|
.parent()
|
|
1458
1505
|
.input
|
|
1459
1506
|
.white_space("pre")
|
|
1460
1507
|
// .border_radius(0)
|
|
1461
|
-
.color(
|
|
1508
|
+
.color(_style.fg_1)
|
|
1462
1509
|
.parent();
|
|
1463
1510
|
};
|
|
1464
1511
|
// Create element.
|
|
1465
1512
|
const input_spacing = 15;
|
|
1466
1513
|
let country_code;
|
|
1467
|
-
|
|
1468
|
-
.color(
|
|
1514
|
+
_billing_element = Form(Title("Billing Details")
|
|
1515
|
+
.color(_style.fg)
|
|
1469
1516
|
.width("fit-content")
|
|
1470
|
-
.font_size(
|
|
1517
|
+
.font_size(_style.font_size - 2)
|
|
1471
1518
|
.flex_shrink(0)
|
|
1472
1519
|
.margin(0, 0, 0, 0)
|
|
1473
1520
|
.letter_spacing("1px")
|
|
1474
1521
|
.text_transform("uppercase")
|
|
1475
1522
|
.ellipsis_overflow(true), Divider()
|
|
1476
|
-
.background(
|
|
1523
|
+
.background(_style.divider_bg)
|
|
1477
1524
|
.margin(10, 0, 10, 0), HStack(Text("Personal")
|
|
1478
|
-
.font_size(
|
|
1479
|
-
.color(
|
|
1480
|
-
.background(
|
|
1525
|
+
.font_size(_style.font_size)
|
|
1526
|
+
.color(_style.fg)
|
|
1527
|
+
.background(_style.bg_1)
|
|
1481
1528
|
.padding(8, 6)
|
|
1482
1529
|
.margin(0)
|
|
1483
1530
|
.stretch(true)
|
|
@@ -1485,29 +1532,29 @@ const Payments = {
|
|
|
1485
1532
|
.transition("color 350ms ease, background 350ms ease")
|
|
1486
1533
|
.on_mouse_over((e) => {
|
|
1487
1534
|
if (e.background() === "transparent") {
|
|
1488
|
-
e.color(
|
|
1535
|
+
e.color(_style.fg);
|
|
1489
1536
|
}
|
|
1490
1537
|
})
|
|
1491
1538
|
.on_mouse_out((e) => {
|
|
1492
1539
|
if (e.background() === "transparent") {
|
|
1493
|
-
e.color(
|
|
1540
|
+
e.color(_style.fg_1);
|
|
1494
1541
|
}
|
|
1495
1542
|
})
|
|
1496
1543
|
.on_click((e) => {
|
|
1497
|
-
e.color(
|
|
1498
|
-
e.background(
|
|
1544
|
+
e.color(_style.fg_1);
|
|
1545
|
+
e.background(_style.bg_1);
|
|
1499
1546
|
const other = e.parentElement.child(1);
|
|
1500
|
-
other.color(
|
|
1547
|
+
other.color(_style.fg_1);
|
|
1501
1548
|
other.background("none");
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1549
|
+
_billing_element.name_input.show();
|
|
1550
|
+
_billing_element.name_input.required(true);
|
|
1551
|
+
_billing_element.business_input.hide();
|
|
1552
|
+
_billing_element.business_input.required(false);
|
|
1553
|
+
_billing_element.vat_id_input.hide();
|
|
1554
|
+
_billing_element.vat_id_input.required(false);
|
|
1508
1555
|
}), Text("Business")
|
|
1509
|
-
.font_size(
|
|
1510
|
-
.color(
|
|
1556
|
+
.font_size(_style.font_size)
|
|
1557
|
+
.color(_style.fg_1)
|
|
1511
1558
|
.background("transparent")
|
|
1512
1559
|
.padding(8, 6)
|
|
1513
1560
|
.margin(0)
|
|
@@ -1516,30 +1563,30 @@ const Payments = {
|
|
|
1516
1563
|
.transition("color 350ms ease, background 350ms ease")
|
|
1517
1564
|
.on_mouse_over((e) => {
|
|
1518
1565
|
if (e.background() === "transparent") {
|
|
1519
|
-
e.color(
|
|
1566
|
+
e.color(_style.fg);
|
|
1520
1567
|
}
|
|
1521
1568
|
})
|
|
1522
1569
|
.on_mouse_out((e) => {
|
|
1523
1570
|
if (e.background() === "transparent") {
|
|
1524
|
-
e.color(
|
|
1571
|
+
e.color(_style.fg_1);
|
|
1525
1572
|
}
|
|
1526
1573
|
})
|
|
1527
1574
|
.on_click((e) => {
|
|
1528
|
-
e.color(
|
|
1529
|
-
e.background(
|
|
1575
|
+
e.color(_style.fg_1);
|
|
1576
|
+
e.background(_style.bg_1);
|
|
1530
1577
|
const other = e.parentElement.child(0);
|
|
1531
|
-
other.color(
|
|
1578
|
+
other.color(_style.fg_1);
|
|
1532
1579
|
other.background("transparent");
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1580
|
+
_billing_element.name_input.hide();
|
|
1581
|
+
_billing_element.name_input.required(false);
|
|
1582
|
+
_billing_element.business_input.show();
|
|
1583
|
+
_billing_element.business_input.required(true);
|
|
1584
|
+
_billing_element.vat_id_input.show();
|
|
1585
|
+
_billing_element.vat_id_input.required(true);
|
|
1539
1586
|
}))
|
|
1540
1587
|
.overflow("hidden")
|
|
1541
|
-
.border(1,
|
|
1542
|
-
.border_radius(
|
|
1588
|
+
.border(1, _style.divider_bg)
|
|
1589
|
+
.border_radius(_style.border_radius)
|
|
1543
1590
|
.margin_top(10)
|
|
1544
1591
|
.margin_bottom(10)
|
|
1545
1592
|
.flex_shrink(0), CreateInput({
|
|
@@ -1609,7 +1656,7 @@ const Payments = {
|
|
|
1609
1656
|
items: Object.fromEntries(Object.entries(Payments.countries).map(([key, value]) => [key, value.name])),
|
|
1610
1657
|
})
|
|
1611
1658
|
.on_change((_, country) => {
|
|
1612
|
-
|
|
1659
|
+
_overview_element.calc_tax(country);
|
|
1613
1660
|
country_code.value(Payments.countries[country].calling_code);
|
|
1614
1661
|
})
|
|
1615
1662
|
.margin_top(input_spacing)
|
|
@@ -1637,58 +1684,63 @@ const Payments = {
|
|
|
1637
1684
|
.id("phone_number"))
|
|
1638
1685
|
.width("100%"));
|
|
1639
1686
|
// Append.
|
|
1640
|
-
|
|
1641
|
-
}
|
|
1687
|
+
_billing_container.append(_billing_element);
|
|
1688
|
+
}
|
|
1642
1689
|
// Render the payment element.
|
|
1643
|
-
|
|
1690
|
+
async function _render_payment_element() {
|
|
1644
1691
|
return new Promise((resolve, reject) => {
|
|
1645
|
-
|
|
1646
|
-
|
|
1692
|
+
_render_payment_element_resolve = resolve;
|
|
1693
|
+
_render_payment_element_reject = reject;
|
|
1647
1694
|
// Already rendered.
|
|
1648
|
-
if (
|
|
1695
|
+
if (_payment_element !== undefined) {
|
|
1649
1696
|
return resolve();
|
|
1650
1697
|
}
|
|
1651
1698
|
// Checks.
|
|
1652
|
-
if (
|
|
1699
|
+
if (client_key == null) {
|
|
1653
1700
|
return reject(new Error(`No client key has been assigned to "Payments.client_key".`));
|
|
1654
1701
|
}
|
|
1655
|
-
if (
|
|
1702
|
+
if (Cart.items.length === 0) {
|
|
1656
1703
|
return reject(new Error("Shopping cart is empty."));
|
|
1657
1704
|
}
|
|
1658
1705
|
// Check subscription or one time payment.
|
|
1659
1706
|
let is_subscription = false;
|
|
1660
|
-
|
|
1707
|
+
Cart.items.forEach((item) => {
|
|
1661
1708
|
if (item.is_subscription === true) {
|
|
1662
1709
|
is_subscription = true;
|
|
1663
1710
|
return false;
|
|
1664
1711
|
}
|
|
1665
1712
|
});
|
|
1666
1713
|
// Initialize paddle.
|
|
1667
|
-
|
|
1714
|
+
_initialize_paddle();
|
|
1668
1715
|
// Create element.
|
|
1669
|
-
|
|
1716
|
+
_payment_element = VStack()
|
|
1670
1717
|
.class("checkout-container");
|
|
1671
1718
|
// Append.
|
|
1672
|
-
|
|
1719
|
+
_payment_container.append(_payment_element);
|
|
1720
|
+
if (!_billing_details) {
|
|
1721
|
+
const e = new Error("Billing details are not yet defined.");
|
|
1722
|
+
Payments.on_error(e);
|
|
1723
|
+
throw e;
|
|
1724
|
+
}
|
|
1673
1725
|
// Initialize.
|
|
1674
1726
|
let custom_data = {
|
|
1675
|
-
customer_name:
|
|
1727
|
+
customer_name: _billing_details.name,
|
|
1676
1728
|
};
|
|
1677
1729
|
if (User.is_authenticated()) {
|
|
1678
1730
|
custom_data.uid = User.uid();
|
|
1679
1731
|
}
|
|
1680
1732
|
try {
|
|
1681
1733
|
let business = undefined;
|
|
1682
|
-
if (
|
|
1734
|
+
if (_billing_details.business !== "") {
|
|
1683
1735
|
business = {
|
|
1684
|
-
name:
|
|
1685
|
-
taxIdentifier:
|
|
1736
|
+
name: _billing_details.business,
|
|
1737
|
+
taxIdentifier: _billing_details.vat_id === "" ? undefined : _billing_details.vat_id,
|
|
1686
1738
|
};
|
|
1687
1739
|
}
|
|
1688
1740
|
Paddle.Checkout.open({
|
|
1689
1741
|
settings: {
|
|
1690
1742
|
displayMode: "inline",
|
|
1691
|
-
theme:
|
|
1743
|
+
theme: _theme,
|
|
1692
1744
|
locale: "en",
|
|
1693
1745
|
frameTarget: "checkout-container",
|
|
1694
1746
|
frameInitialHeight: "450",
|
|
@@ -1696,15 +1748,15 @@ const Payments = {
|
|
|
1696
1748
|
// successUrl: this.return_url,
|
|
1697
1749
|
// successUrl: "http://test.vandenberghinc.com/checkout?payment_status=success",
|
|
1698
1750
|
},
|
|
1699
|
-
items:
|
|
1751
|
+
items: Cart.items.map((item) => { return { priceId: item.product.price_id, quantity: item.quantity }; }),
|
|
1700
1752
|
customer: {
|
|
1701
|
-
email:
|
|
1753
|
+
email: _billing_details.email,
|
|
1702
1754
|
address: {
|
|
1703
|
-
countryCode:
|
|
1704
|
-
postalCode:
|
|
1705
|
-
region:
|
|
1706
|
-
city:
|
|
1707
|
-
firstLine: `${
|
|
1755
|
+
countryCode: _billing_details.country,
|
|
1756
|
+
postalCode: _billing_details.postal_code,
|
|
1757
|
+
region: _billing_details.province,
|
|
1758
|
+
city: _billing_details.city,
|
|
1759
|
+
firstLine: `${_billing_details.street} ${_billing_details.house_number}`,
|
|
1708
1760
|
},
|
|
1709
1761
|
business,
|
|
1710
1762
|
},
|
|
@@ -1714,7 +1766,7 @@ const Payments = {
|
|
|
1714
1766
|
catch (err) {
|
|
1715
1767
|
return reject(err);
|
|
1716
1768
|
}
|
|
1717
|
-
// const iframe =
|
|
1769
|
+
// const iframe = _payment_element.children[0];
|
|
1718
1770
|
// iframe.onload = () => {
|
|
1719
1771
|
// console.log("ON LOAD");
|
|
1720
1772
|
// let doc = iframe.contentDocument || iframe.contentWindow.document;
|
|
@@ -1722,18 +1774,18 @@ const Payments = {
|
|
|
1722
1774
|
// elementInsideIframe.style.background = 'red'; // Example of editing an element
|
|
1723
1775
|
// }
|
|
1724
1776
|
});
|
|
1725
|
-
}
|
|
1777
|
+
}
|
|
1726
1778
|
// Render the processing element.
|
|
1727
|
-
|
|
1779
|
+
function _render_processing_element() {
|
|
1728
1780
|
// Already defined.
|
|
1729
|
-
if (
|
|
1730
|
-
|
|
1781
|
+
if (_processing_element !== undefined) {
|
|
1782
|
+
_processing_element.set_processing();
|
|
1731
1783
|
return;
|
|
1732
1784
|
}
|
|
1733
1785
|
// Create element.
|
|
1734
|
-
|
|
1735
|
-
.color(
|
|
1736
|
-
.font_size(
|
|
1786
|
+
_processing_element = VStack(Title("Processing")
|
|
1787
|
+
.color(_style.fg)
|
|
1788
|
+
.font_size(_style.font_size - 2)
|
|
1737
1789
|
.flex_shrink(0)
|
|
1738
1790
|
.letter_spacing("1px")
|
|
1739
1791
|
.text_transform("uppercase")
|
|
@@ -1741,9 +1793,9 @@ const Payments = {
|
|
|
1741
1793
|
.margin(0)
|
|
1742
1794
|
.padding(0)
|
|
1743
1795
|
.assign_to_parent_as("title_e"), Text("Processing your payment, please wait.")
|
|
1744
|
-
.color(
|
|
1745
|
-
.font_size(
|
|
1746
|
-
.line_height(
|
|
1796
|
+
.color(_style.fg_1)
|
|
1797
|
+
.font_size(_style.font_size - 2)
|
|
1798
|
+
.line_height(_style.font_size)
|
|
1747
1799
|
.margin(5, 0, 0, 0)
|
|
1748
1800
|
.padding(0)
|
|
1749
1801
|
.assign_to_parent_as("text_e")
|
|
@@ -1753,14 +1805,14 @@ const Payments = {
|
|
|
1753
1805
|
.hide()
|
|
1754
1806
|
.frame(40, 40)
|
|
1755
1807
|
.padding(5)
|
|
1756
|
-
.mask_color(
|
|
1808
|
+
.mask_color(_style.missing_fg)
|
|
1757
1809
|
.margin_top(15)
|
|
1758
1810
|
.assign_to_parent_as("error_image_e"), Image("/volt_static/payments/party.webp")
|
|
1759
1811
|
.hide()
|
|
1760
1812
|
.frame(40, 40)
|
|
1761
1813
|
.margin_top(15)
|
|
1762
1814
|
.assign_to_parent_as("success_image_e"), RingLoader()
|
|
1763
|
-
.background(
|
|
1815
|
+
.background(_style.theme_fg)
|
|
1764
1816
|
.frame(40, 40)
|
|
1765
1817
|
.update()
|
|
1766
1818
|
.margin_top(15)
|
|
@@ -1818,51 +1870,51 @@ const Payments = {
|
|
|
1818
1870
|
},
|
|
1819
1871
|
});
|
|
1820
1872
|
// Append.
|
|
1821
|
-
|
|
1822
|
-
}
|
|
1873
|
+
_processing_container.append(_processing_element);
|
|
1874
|
+
}
|
|
1823
1875
|
// Show the processing container.
|
|
1824
|
-
|
|
1876
|
+
async function _show_processing(status = null) {
|
|
1825
1877
|
// Select step.
|
|
1826
|
-
|
|
1827
|
-
|
|
1878
|
+
_payment_step = 3;
|
|
1879
|
+
_steps_element.select(_payment_step);
|
|
1828
1880
|
// Render the processing element.
|
|
1829
|
-
|
|
1881
|
+
_render_processing_element();
|
|
1830
1882
|
// Set elements.
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1883
|
+
_order_container.hide();
|
|
1884
|
+
_billing_container.hide();
|
|
1885
|
+
_payment_container.hide();
|
|
1886
|
+
_processing_container.show();
|
|
1887
|
+
_overview_container.hide();
|
|
1888
|
+
_prev_step_button.hide();
|
|
1837
1889
|
// Update.
|
|
1838
1890
|
if (status != null) {
|
|
1839
|
-
|
|
1891
|
+
_update_processing(status);
|
|
1840
1892
|
}
|
|
1841
|
-
}
|
|
1893
|
+
}
|
|
1842
1894
|
// Update the processing container.
|
|
1843
|
-
|
|
1895
|
+
async function _update_processing(status) {
|
|
1844
1896
|
// Handle result code.
|
|
1845
1897
|
switch (status) {
|
|
1846
1898
|
case "success":
|
|
1847
|
-
|
|
1899
|
+
_processing_element.set_success();
|
|
1848
1900
|
break;
|
|
1849
1901
|
case "processing":
|
|
1850
|
-
|
|
1902
|
+
_processing_element.set_processing();
|
|
1851
1903
|
break;
|
|
1852
1904
|
case "cancelled":
|
|
1853
|
-
|
|
1905
|
+
_processing_element.set_cancelled();
|
|
1854
1906
|
break;
|
|
1855
1907
|
case "error":
|
|
1856
|
-
|
|
1908
|
+
_processing_element.set_error();
|
|
1857
1909
|
break;
|
|
1858
1910
|
default:
|
|
1859
1911
|
console.error(`Unknown session result code "${status}".`);
|
|
1860
|
-
|
|
1912
|
+
_processing_element.set_error("An unknown error has occurred.");
|
|
1861
1913
|
break;
|
|
1862
1914
|
}
|
|
1863
|
-
}
|
|
1915
|
+
}
|
|
1864
1916
|
// Initialize checkout page.
|
|
1865
|
-
|
|
1917
|
+
function style({ theme = "light", // light or dark
|
|
1866
1918
|
font_size = 16, border_radius = 10, bg = "#FFFFFF", bg_1 = "#00000099", divider_bg = "gray", fg = "#687282", fg_1 = "black", fg_2 = "#6D6E77", theme_fg = "#8EB8EB", missing_fg = "#E8454E", selected = {
|
|
1867
1919
|
fg: null,
|
|
1868
1920
|
bg: null,
|
|
@@ -1904,34 +1956,35 @@ const Payments = {
|
|
|
1904
1956
|
button.border_width = `${button.border_width}px`;
|
|
1905
1957
|
}
|
|
1906
1958
|
// Save style.
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1959
|
+
_style = {};
|
|
1960
|
+
_theme = theme;
|
|
1961
|
+
_style.font_size = font_size;
|
|
1962
|
+
_style.border_radius = border_radius;
|
|
1963
|
+
_style.bg = bg;
|
|
1964
|
+
_style.bg_1 = bg_1;
|
|
1965
|
+
_style.divider_bg = divider_bg;
|
|
1966
|
+
_style.fg = fg;
|
|
1967
|
+
_style.fg_1 = fg_1;
|
|
1968
|
+
_style.fg_2 = fg_2;
|
|
1969
|
+
_style.theme_fg = theme_fg;
|
|
1970
|
+
_style.missing_fg = missing_fg;
|
|
1971
|
+
_style.selected = selected;
|
|
1972
|
+
_style.button = button;
|
|
1921
1973
|
// Set CSS variables.
|
|
1922
|
-
Object.keys(
|
|
1923
|
-
if (typeof
|
|
1924
|
-
document.documentElement.style.setProperty(`--vpayments_${key}`, `${
|
|
1974
|
+
Object.keys(_style).forEach((key) => {
|
|
1975
|
+
if (typeof _style[key] === "number") {
|
|
1976
|
+
document.documentElement.style.setProperty(`--vpayments_${key}`, `${_style[key]}px`);
|
|
1925
1977
|
}
|
|
1926
1978
|
else {
|
|
1927
|
-
document.documentElement.style.setProperty(`--vpayments_${key}`,
|
|
1979
|
+
document.documentElement.style.setProperty(`--vpayments_${key}`, _style[key]);
|
|
1928
1980
|
}
|
|
1929
1981
|
});
|
|
1930
|
-
document.documentElement.style.setProperty(`--vpayments_theme_fg_80`, `${
|
|
1931
|
-
document.documentElement.style.setProperty(`--vpayments_missing_fg_80`, `${
|
|
1932
|
-
}
|
|
1982
|
+
document.documentElement.style.setProperty(`--vpayments_theme_fg_80`, `${_style.theme_fg}80`);
|
|
1983
|
+
document.documentElement.style.setProperty(`--vpayments_missing_fg_80`, `${_style.missing_fg}80`);
|
|
1984
|
+
}
|
|
1985
|
+
Payments.style = style;
|
|
1933
1986
|
// Initialize checkout page.
|
|
1934
|
-
|
|
1987
|
+
function create_checkout_dropin({ steps_container, order_container, billing_container, payment_container, processing_container, overview_container, sign_in_redirect = null, on_error = (error) => { }, }) {
|
|
1935
1988
|
// Check args.
|
|
1936
1989
|
if (!(steps_container instanceof Node)) {
|
|
1937
1990
|
throw new Error('The "steps_container" must be assigned with a container node.');
|
|
@@ -1952,42 +2005,42 @@ const Payments = {
|
|
|
1952
2005
|
throw new Error('The "overview_container" must be assigned with a container node.');
|
|
1953
2006
|
}
|
|
1954
2007
|
// Args.
|
|
1955
|
-
|
|
1956
|
-
|
|
2008
|
+
_steps_container = steps_container;
|
|
2009
|
+
_order_container = order_container;
|
|
1957
2010
|
// @ts-ignore
|
|
1958
|
-
|
|
2011
|
+
_billing_container = billing_container.hide();
|
|
1959
2012
|
// @ts-ignore
|
|
1960
|
-
|
|
2013
|
+
_payment_container = payment_container.hide();
|
|
1961
2014
|
// @ts-ignore
|
|
1962
|
-
|
|
1963
|
-
|
|
2015
|
+
_processing_container = processing_container.hide();
|
|
2016
|
+
_overview_container = overview_container;
|
|
1964
2017
|
// Settings.
|
|
1965
|
-
|
|
2018
|
+
_sign_in_redirect = sign_in_redirect;
|
|
1966
2019
|
// Events.
|
|
1967
|
-
|
|
2020
|
+
Payments.on_error = on_error;
|
|
1968
2021
|
// Check style.
|
|
1969
|
-
if (
|
|
1970
|
-
|
|
2022
|
+
if (_style === undefined) {
|
|
2023
|
+
Payments.style();
|
|
1971
2024
|
}
|
|
1972
2025
|
// Other attributes.
|
|
1973
|
-
|
|
2026
|
+
_payment_step = 0;
|
|
1974
2027
|
// Render the steps element.
|
|
1975
|
-
|
|
2028
|
+
_render_steps_element();
|
|
1976
2029
|
// When the user was redirected the URL params are defined, if so only render the processing view.
|
|
1977
2030
|
if (Utils.url_param("payment_status", null) != null) {
|
|
1978
|
-
|
|
2031
|
+
_show_processing(Utils.url_param("payment_status", null));
|
|
1979
2032
|
}
|
|
1980
2033
|
// No redirect.
|
|
1981
2034
|
else {
|
|
1982
2035
|
// Render the overview element.
|
|
1983
|
-
|
|
2036
|
+
_render_overview_element();
|
|
1984
2037
|
// Render the order element.
|
|
1985
2038
|
// Must be rendered after the overview element is rendered.
|
|
1986
|
-
|
|
2039
|
+
_render_order_element();
|
|
1987
2040
|
}
|
|
1988
|
-
}
|
|
2041
|
+
}
|
|
1989
2042
|
// Initialize refund page.
|
|
1990
|
-
|
|
2043
|
+
function create_refunds_dropin({
|
|
1991
2044
|
// The element containers.
|
|
1992
2045
|
refunds_container,
|
|
1993
2046
|
// Refundable settings.
|
|
@@ -1999,19 +2052,19 @@ const Payments = {
|
|
|
1999
2052
|
throw new Error('The "refunds_container" must be assigned with a container node.');
|
|
2000
2053
|
}
|
|
2001
2054
|
// Args.
|
|
2002
|
-
|
|
2003
|
-
|
|
2055
|
+
_refunds_container = refunds_container;
|
|
2056
|
+
_days_refundable = days_refundable;
|
|
2004
2057
|
// Events.
|
|
2005
|
-
|
|
2058
|
+
Payments.on_error = on_error;
|
|
2006
2059
|
// Check style.
|
|
2007
|
-
if (
|
|
2008
|
-
|
|
2060
|
+
if (_style === undefined) {
|
|
2061
|
+
Payments.style();
|
|
2009
2062
|
}
|
|
2010
2063
|
// Other attributes.
|
|
2011
|
-
|
|
2064
|
+
_payment_step = 0;
|
|
2012
2065
|
// Render the refunds element.
|
|
2013
|
-
|
|
2014
|
-
}
|
|
2066
|
+
_render_refunds_element();
|
|
2067
|
+
}
|
|
2015
2068
|
// Backend API.
|
|
2016
2069
|
// Get the currency symbol for a product currency.
|
|
2017
2070
|
// Returns `null` when the currency is not supported.
|
|
@@ -2027,7 +2080,7 @@ const Payments = {
|
|
|
2027
2080
|
* @name: currency
|
|
2028
2081
|
* @description: The currency from the product object.
|
|
2029
2082
|
*/
|
|
2030
|
-
|
|
2083
|
+
function get_currency_symbol(currency) {
|
|
2031
2084
|
switch (currency.toLowerCase()) {
|
|
2032
2085
|
case "aed": return "د.إ";
|
|
2033
2086
|
case "afn": return "Af";
|
|
@@ -2184,7 +2237,8 @@ const Payments = {
|
|
|
2184
2237
|
case "zmw": return "ZK";
|
|
2185
2238
|
}
|
|
2186
2239
|
return null;
|
|
2187
|
-
}
|
|
2240
|
+
}
|
|
2241
|
+
Payments.get_currency_symbol = get_currency_symbol;
|
|
2188
2242
|
// Fetch the payment products.
|
|
2189
2243
|
/**
|
|
2190
2244
|
* @docs:
|
|
@@ -2195,24 +2249,16 @@ const Payments = {
|
|
|
2195
2249
|
* @type: array[object]
|
|
2196
2250
|
* @return: Returns the backend defined payment products.
|
|
2197
2251
|
*/
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
url: "/volt/payments/products",
|
|
2206
|
-
})
|
|
2207
|
-
.then((products) => {
|
|
2208
|
-
this._products = products;
|
|
2209
|
-
resolve(this._products);
|
|
2210
|
-
})
|
|
2211
|
-
.catch((err) => {
|
|
2212
|
-
reject(err);
|
|
2213
|
-
});
|
|
2252
|
+
function get_products() {
|
|
2253
|
+
if (_products !== undefined) {
|
|
2254
|
+
return _products;
|
|
2255
|
+
}
|
|
2256
|
+
return request({
|
|
2257
|
+
method: "GET",
|
|
2258
|
+
url: "/volt/api/v1/payments/products",
|
|
2214
2259
|
});
|
|
2215
|
-
}
|
|
2260
|
+
}
|
|
2261
|
+
Payments.get_products = get_products;
|
|
2216
2262
|
// Fetch a payment product by id.
|
|
2217
2263
|
/**
|
|
2218
2264
|
* @docs:
|
|
@@ -2228,32 +2274,42 @@ const Payments = {
|
|
|
2228
2274
|
* @type: string
|
|
2229
2275
|
* @desc: The id of the payment product.
|
|
2230
2276
|
*/
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
}
|
|
2247
|
-
if (product)
|
|
2277
|
+
async function get_product(id) {
|
|
2278
|
+
// APPLY_NEW_RESPONSE
|
|
2279
|
+
const products = await get_products();
|
|
2280
|
+
if (products.error)
|
|
2281
|
+
return products;
|
|
2282
|
+
let product = undefined;
|
|
2283
|
+
for (const p of products.data) {
|
|
2284
|
+
if (p.id === id) {
|
|
2285
|
+
product = p;
|
|
2286
|
+
break;
|
|
2287
|
+
}
|
|
2288
|
+
if (p.is_subscription && p.plans) {
|
|
2289
|
+
for (const plan of p.plans) {
|
|
2290
|
+
if (plan.id === id) {
|
|
2291
|
+
product = plan;
|
|
2248
2292
|
break;
|
|
2293
|
+
}
|
|
2249
2294
|
}
|
|
2295
|
+
if (product)
|
|
2296
|
+
break;
|
|
2250
2297
|
}
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2298
|
+
}
|
|
2299
|
+
if (product == null) {
|
|
2300
|
+
return {
|
|
2301
|
+
error: {
|
|
2302
|
+
message: `Product "${id}" does not exist.`
|
|
2303
|
+
},
|
|
2304
|
+
status: 400,
|
|
2305
|
+
};
|
|
2306
|
+
}
|
|
2307
|
+
return {
|
|
2308
|
+
status: 200,
|
|
2309
|
+
data: product
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
Payments.get_product = get_product;
|
|
2257
2313
|
// Fetch a payment object by id.
|
|
2258
2314
|
/**
|
|
2259
2315
|
* @docs:
|
|
@@ -2267,15 +2323,14 @@ const Payments = {
|
|
|
2267
2323
|
* @type: string
|
|
2268
2324
|
* @desc: The id of the payment.
|
|
2269
2325
|
*/
|
|
2270
|
-
|
|
2271
|
-
return
|
|
2326
|
+
function get_payment(payload) {
|
|
2327
|
+
return request({
|
|
2272
2328
|
method: "GET",
|
|
2273
|
-
url: "/volt/payments/payment",
|
|
2274
|
-
data:
|
|
2275
|
-
id: id,
|
|
2276
|
-
}
|
|
2329
|
+
url: "/volt/api/v1/payments/payment",
|
|
2330
|
+
data: payload,
|
|
2277
2331
|
});
|
|
2278
|
-
}
|
|
2332
|
+
}
|
|
2333
|
+
Payments.get_payment = get_payment;
|
|
2279
2334
|
// Get all payments.
|
|
2280
2335
|
/**
|
|
2281
2336
|
* @docs:
|
|
@@ -2305,17 +2360,14 @@ const Payments = {
|
|
|
2305
2360
|
* @value: "paid"
|
|
2306
2361
|
* @desc: Payments that are paid.
|
|
2307
2362
|
*/
|
|
2308
|
-
|
|
2309
|
-
return
|
|
2363
|
+
function get_payments(payload) {
|
|
2364
|
+
return request({
|
|
2310
2365
|
method: "GET",
|
|
2311
|
-
url: "/volt/payments/payments",
|
|
2312
|
-
data:
|
|
2313
|
-
days,
|
|
2314
|
-
limit,
|
|
2315
|
-
status,
|
|
2316
|
-
}
|
|
2366
|
+
url: "/volt/api/v1/payments/payments",
|
|
2367
|
+
data: payload
|
|
2317
2368
|
});
|
|
2318
|
-
}
|
|
2369
|
+
}
|
|
2370
|
+
Payments.get_payments = get_payments;
|
|
2319
2371
|
// Get refundable payments.
|
|
2320
2372
|
/**
|
|
2321
2373
|
* @docs:
|
|
@@ -2332,16 +2384,14 @@ const Payments = {
|
|
|
2332
2384
|
* @type: number
|
|
2333
2385
|
* @desc: Limit the amount of response payment objects.
|
|
2334
2386
|
*/
|
|
2335
|
-
|
|
2336
|
-
return
|
|
2387
|
+
function get_refundable_payments(payload) {
|
|
2388
|
+
return request({
|
|
2337
2389
|
method: "GET",
|
|
2338
|
-
url: "/volt/payments/payments/refundable",
|
|
2339
|
-
data:
|
|
2340
|
-
days,
|
|
2341
|
-
limit,
|
|
2342
|
-
}
|
|
2390
|
+
url: "/volt/api/v1/payments/payments/refundable",
|
|
2391
|
+
data: payload
|
|
2343
2392
|
});
|
|
2344
|
-
}
|
|
2393
|
+
}
|
|
2394
|
+
Payments.get_refundable_payments = get_refundable_payments;
|
|
2345
2395
|
// Get refunded payments.
|
|
2346
2396
|
/**
|
|
2347
2397
|
* @docs:
|
|
@@ -2358,16 +2408,14 @@ const Payments = {
|
|
|
2358
2408
|
* @type: number
|
|
2359
2409
|
* @desc: Limit the amount of response payment objects.
|
|
2360
2410
|
*/
|
|
2361
|
-
|
|
2362
|
-
return
|
|
2411
|
+
function get_refunded_payments(payload) {
|
|
2412
|
+
return request({
|
|
2363
2413
|
method: "GET",
|
|
2364
|
-
url: "/volt/payments/payments/refunded",
|
|
2365
|
-
data:
|
|
2366
|
-
days,
|
|
2367
|
-
limit,
|
|
2368
|
-
}
|
|
2414
|
+
url: "/volt/api/v1/payments/payments/refunded",
|
|
2415
|
+
data: payload
|
|
2369
2416
|
});
|
|
2370
|
-
}
|
|
2417
|
+
}
|
|
2418
|
+
Payments.get_refunded_payments = get_refunded_payments;
|
|
2371
2419
|
// Get refunding payments.
|
|
2372
2420
|
/**
|
|
2373
2421
|
* @docs:
|
|
@@ -2384,16 +2432,14 @@ const Payments = {
|
|
|
2384
2432
|
* @type: number
|
|
2385
2433
|
* @desc: Limit the amount of response payment objects.
|
|
2386
2434
|
*/
|
|
2387
|
-
|
|
2388
|
-
return
|
|
2435
|
+
function get_refunding_payments(payload) {
|
|
2436
|
+
return request({
|
|
2389
2437
|
method: "GET",
|
|
2390
|
-
url: "/volt/payments/payments/refunding",
|
|
2391
|
-
data:
|
|
2392
|
-
days,
|
|
2393
|
-
limit,
|
|
2394
|
-
}
|
|
2438
|
+
url: "/volt/api/v1/payments/payments/refunding",
|
|
2439
|
+
data: payload
|
|
2395
2440
|
});
|
|
2396
|
-
}
|
|
2441
|
+
}
|
|
2442
|
+
Payments.get_refunding_payments = get_refunding_payments;
|
|
2397
2443
|
// Create refund.
|
|
2398
2444
|
/**
|
|
2399
2445
|
* @docs:
|
|
@@ -2417,17 +2463,14 @@ const Payments = {
|
|
|
2417
2463
|
* @type: string
|
|
2418
2464
|
* @desc: The refund reason.
|
|
2419
2465
|
*/
|
|
2420
|
-
|
|
2421
|
-
return
|
|
2466
|
+
function create_refund(payload) {
|
|
2467
|
+
return request({
|
|
2422
2468
|
method: "POST",
|
|
2423
|
-
url: "/volt/payments/refund",
|
|
2424
|
-
data:
|
|
2425
|
-
payment,
|
|
2426
|
-
line_items,
|
|
2427
|
-
reason,
|
|
2428
|
-
}
|
|
2469
|
+
url: "/volt/api/v1/payments/refund",
|
|
2470
|
+
data: payload
|
|
2429
2471
|
});
|
|
2430
|
-
}
|
|
2472
|
+
}
|
|
2473
|
+
Payments.create_refund = create_refund;
|
|
2431
2474
|
// Cancel subscription.
|
|
2432
2475
|
/**
|
|
2433
2476
|
* @docs:
|
|
@@ -2442,15 +2485,14 @@ const Payments = {
|
|
|
2442
2485
|
* @type: string
|
|
2443
2486
|
* @desc: The product id.
|
|
2444
2487
|
*/
|
|
2445
|
-
|
|
2446
|
-
return
|
|
2488
|
+
function cancel_subscription(payload) {
|
|
2489
|
+
return request({
|
|
2447
2490
|
method: "DELETE",
|
|
2448
|
-
url: "/volt/payments/subscription",
|
|
2449
|
-
data:
|
|
2450
|
-
product,
|
|
2451
|
-
}
|
|
2491
|
+
url: "/volt/api/v1/payments/subscription",
|
|
2492
|
+
data: payload
|
|
2452
2493
|
});
|
|
2453
|
-
}
|
|
2494
|
+
}
|
|
2495
|
+
Payments.cancel_subscription = cancel_subscription;
|
|
2454
2496
|
// Is subscribed.
|
|
2455
2497
|
/**
|
|
2456
2498
|
* @docs:
|
|
@@ -2464,15 +2506,14 @@ const Payments = {
|
|
|
2464
2506
|
* @type: string
|
|
2465
2507
|
* @desc: The product id.
|
|
2466
2508
|
*/
|
|
2467
|
-
|
|
2468
|
-
return
|
|
2509
|
+
function is_subscribed(payload) {
|
|
2510
|
+
return request({
|
|
2469
2511
|
method: "GET",
|
|
2470
|
-
url: "/volt/payments/subscribed",
|
|
2471
|
-
data:
|
|
2472
|
-
product,
|
|
2473
|
-
}
|
|
2512
|
+
url: "/volt/api/v1/payments/subscribed",
|
|
2513
|
+
data: payload
|
|
2474
2514
|
});
|
|
2475
|
-
}
|
|
2515
|
+
}
|
|
2516
|
+
Payments.is_subscribed = is_subscribed;
|
|
2476
2517
|
// Get active subscriptions.
|
|
2477
2518
|
/**
|
|
2478
2519
|
* @docs:
|
|
@@ -2481,16 +2522,18 @@ const Payments = {
|
|
|
2481
2522
|
* @title: Get active subscriptions
|
|
2482
2523
|
* @desc: Get the active subscriptions of the authenticated user.
|
|
2483
2524
|
*/
|
|
2484
|
-
|
|
2485
|
-
return
|
|
2525
|
+
function get_active_subscriptions() {
|
|
2526
|
+
return request({
|
|
2486
2527
|
method: "GET",
|
|
2487
|
-
url: "/volt/payments/active_subscriptions",
|
|
2528
|
+
url: "/volt/api/v1/payments/active_subscriptions",
|
|
2488
2529
|
});
|
|
2489
|
-
}
|
|
2530
|
+
}
|
|
2531
|
+
Payments.get_active_subscriptions = get_active_subscriptions;
|
|
2490
2532
|
// Shopping cart.
|
|
2491
2533
|
// The shopping cart object.
|
|
2492
|
-
|
|
2493
|
-
|
|
2534
|
+
let Cart;
|
|
2535
|
+
(function (Cart) {
|
|
2536
|
+
Cart.items = [];
|
|
2494
2537
|
// Refresh the shopping cart.
|
|
2495
2538
|
/**
|
|
2496
2539
|
* @docs:
|
|
@@ -2502,17 +2545,18 @@ const Payments = {
|
|
|
2502
2545
|
*
|
|
2503
2546
|
* The current cart items are accessible as `Payments.cart.items`.
|
|
2504
2547
|
*/
|
|
2505
|
-
|
|
2548
|
+
function refresh() {
|
|
2506
2549
|
// Load from local storage.
|
|
2507
2550
|
try {
|
|
2508
|
-
|
|
2551
|
+
Cart.items = JSON.parse(localStorage.getItem("volt_shopping_cart")) || [];
|
|
2509
2552
|
}
|
|
2510
2553
|
catch (err) {
|
|
2511
|
-
|
|
2554
|
+
Cart.items = [];
|
|
2512
2555
|
}
|
|
2513
2556
|
// Reset the charge objects.
|
|
2514
|
-
|
|
2515
|
-
}
|
|
2557
|
+
_reset_payment_element();
|
|
2558
|
+
}
|
|
2559
|
+
Cart.refresh = refresh;
|
|
2516
2560
|
// Save the shopping cart.
|
|
2517
2561
|
/**
|
|
2518
2562
|
* @docs:
|
|
@@ -2524,12 +2568,13 @@ const Payments = {
|
|
|
2524
2568
|
*
|
|
2525
2569
|
* The current cart items are accessible as `Payments.cart.items`.
|
|
2526
2570
|
*/
|
|
2527
|
-
|
|
2571
|
+
function save() {
|
|
2528
2572
|
// Save to local storage.
|
|
2529
|
-
localStorage.setItem("volt_shopping_cart", JSON.stringify(
|
|
2573
|
+
localStorage.setItem("volt_shopping_cart", JSON.stringify(Cart.items));
|
|
2530
2574
|
// Reset the charge objects.
|
|
2531
|
-
|
|
2532
|
-
}
|
|
2575
|
+
_reset_payment_element();
|
|
2576
|
+
}
|
|
2577
|
+
Cart.save = save;
|
|
2533
2578
|
// Add a product to the shopping cart.
|
|
2534
2579
|
/**
|
|
2535
2580
|
* @docs:
|
|
@@ -2553,9 +2598,9 @@ const Payments = {
|
|
|
2553
2598
|
* @description: The quantity to add.
|
|
2554
2599
|
* @type: number
|
|
2555
2600
|
*/
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
const found =
|
|
2601
|
+
async function add(id, quantity = 1) {
|
|
2602
|
+
Cart.refresh(); // Update in case another window has updated the cart.
|
|
2603
|
+
const found = Cart.items.some((item) => {
|
|
2559
2604
|
if (item.product.id === id) {
|
|
2560
2605
|
item.quantity += quantity;
|
|
2561
2606
|
return true;
|
|
@@ -2565,8 +2610,10 @@ const Payments = {
|
|
|
2565
2610
|
if (!found) {
|
|
2566
2611
|
try {
|
|
2567
2612
|
const product = await Payments.get_product(id);
|
|
2568
|
-
|
|
2569
|
-
|
|
2613
|
+
if (product.error)
|
|
2614
|
+
throw new Error(product.error.message);
|
|
2615
|
+
Cart.items.push({
|
|
2616
|
+
product: product.data,
|
|
2570
2617
|
quantity: quantity,
|
|
2571
2618
|
});
|
|
2572
2619
|
}
|
|
@@ -2576,8 +2623,9 @@ const Payments = {
|
|
|
2576
2623
|
throw new Error(`Failed to add product with id "${id}" to the cart.`);
|
|
2577
2624
|
}
|
|
2578
2625
|
}
|
|
2579
|
-
|
|
2580
|
-
}
|
|
2626
|
+
Cart.save();
|
|
2627
|
+
}
|
|
2628
|
+
Cart.add = add;
|
|
2581
2629
|
// Remove a product from the shopping cart.
|
|
2582
2630
|
/**
|
|
2583
2631
|
* @docs:
|
|
@@ -2599,10 +2647,10 @@ const Payments = {
|
|
|
2599
2647
|
* @description: The quantity to remove. When the quantity value is "all", the entire product will be removed from the shopping cart.
|
|
2600
2648
|
* @type: number | "all"
|
|
2601
2649
|
*/
|
|
2602
|
-
|
|
2603
|
-
|
|
2650
|
+
async function remove(id, quantity = 1) {
|
|
2651
|
+
Cart.refresh(); // Update in case another window has updated the cart.
|
|
2604
2652
|
let new_cart = [];
|
|
2605
|
-
|
|
2653
|
+
Cart.items.forEach((item) => {
|
|
2606
2654
|
if (item.product.id === id) {
|
|
2607
2655
|
if (quantity === "all") {
|
|
2608
2656
|
item.quantity = 0;
|
|
@@ -2615,9 +2663,10 @@ const Payments = {
|
|
|
2615
2663
|
new_cart.push(item);
|
|
2616
2664
|
}
|
|
2617
2665
|
});
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
}
|
|
2666
|
+
Cart.items = new_cart;
|
|
2667
|
+
Cart.save();
|
|
2668
|
+
}
|
|
2669
|
+
Cart.remove = remove;
|
|
2621
2670
|
// Clear the shopping cart.
|
|
2622
2671
|
/**
|
|
2623
2672
|
* @docs:
|
|
@@ -2631,12 +2680,15 @@ const Payments = {
|
|
|
2631
2680
|
*
|
|
2632
2681
|
* The current cart items are accessible as `Payments.cart.items`.
|
|
2633
2682
|
*/
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2683
|
+
async function clear() {
|
|
2684
|
+
Cart.items = [];
|
|
2685
|
+
Cart.save();
|
|
2637
2686
|
}
|
|
2638
|
-
|
|
2639
|
-
};
|
|
2640
|
-
|
|
2641
|
-
|
|
2687
|
+
Cart.clear = clear;
|
|
2688
|
+
})(Cart = Payments.Cart || (Payments.Cart = {}));
|
|
2689
|
+
})(Payments || (Payments = {}));
|
|
2690
|
+
;
|
|
2642
2691
|
export { Payments as payments }; // also export as lowercase for compatibility.
|
|
2692
|
+
// APPLY_FIX // @todo if undeprecate: convert to namespace
|
|
2693
|
+
// APPLY_FIX // @todo if undeprecate: audit by claude
|
|
2694
|
+
// APPLY_FIX // @todo if undeprecate: remove request_v1 everywhere in volt, return Utils.RequestResult instead
|