@vandenberghinc/volt 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/frontend/assets/admin/admin.png +0 -0
- package/frontend/assets/admin/password.webp +0 -0
- package/frontend/assets/icons/arrow.v1.webp +0 -0
- package/frontend/assets/icons/copy.webp +0 -0
- package/frontend/assets/payments/arrow.long.webp +0 -0
- package/frontend/assets/payments/arrow.long2.webp +0 -0
- package/frontend/assets/payments/cancelled.webp +0 -0
- package/frontend/assets/payments/check.sign.webp +0 -0
- package/frontend/assets/payments/check.webp +0 -0
- package/frontend/assets/payments/close.webp +0 -0
- package/frontend/assets/payments/error.webp +0 -0
- package/frontend/assets/payments/exclamation.webp +0 -0
- package/frontend/assets/payments/minus.webp +0 -0
- package/frontend/assets/payments/party.webp +0 -0
- package/frontend/assets/payments/plus.webp +0 -0
- package/frontend/assets/payments/shopping_cart.webp +0 -0
- package/frontend/assets/payments/trash.webp +0 -0
- package/package.json +5 -1
- package/.libris/config.json +0 -82
- package/backend/dist/cjs/backend/src/blacklist.d.ts +0 -12
- package/backend/dist/cjs/backend/src/blacklist.js +0 -78
- package/backend/dist/cjs/backend/src/cli.d.ts +0 -2
- package/backend/dist/cjs/backend/src/cli.js +0 -198
- package/backend/dist/cjs/backend/src/database/collection.d.ts +0 -1765
- package/backend/dist/cjs/backend/src/database/collection.js +0 -3301
- package/backend/dist/cjs/backend/src/database/database.d.ts +0 -92
- package/backend/dist/cjs/backend/src/database/database.js +0 -170
- package/backend/dist/cjs/backend/src/database/document.d.ts +0 -1
- package/backend/dist/cjs/backend/src/database/document.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +0 -6
- package/backend/dist/cjs/backend/src/database/filters/filters.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +0 -223
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.d.ts +0 -1
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +0 -443
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.d.ts +0 -1
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +0 -50
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +0 -76
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +0 -75
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +0 -219
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +0 -165
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +0 -15
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +0 -5
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +0 -355
- package/backend/dist/cjs/backend/src/database/flatten.d.ts +0 -78
- package/backend/dist/cjs/backend/src/database/flatten.js +0 -53
- package/backend/dist/cjs/backend/src/database/flatten_test.d.ts +0 -1
- package/backend/dist/cjs/backend/src/database/flatten_test.js +0 -175
- package/backend/dist/cjs/backend/src/database/quota/quoata_v2.d.ts +0 -533
- package/backend/dist/cjs/backend/src/database/quota/quoata_v2.js +0 -1046
- package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +0 -551
- package/backend/dist/cjs/backend/src/database/quota/quota.js +0 -1108
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +0 -534
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +0 -1087
- package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +0 -412
- package/backend/dist/cjs/backend/src/database/quota/safe_int.js +0 -745
- package/backend/dist/cjs/backend/src/endpoint.d.ts +0 -346
- package/backend/dist/cjs/backend/src/endpoint.js +0 -468
- package/backend/dist/cjs/backend/src/errors/index.d.ts +0 -7
- package/backend/dist/cjs/backend/src/errors/index.js +0 -25
- package/backend/dist/cjs/backend/src/errors/internal_external.d.ts +0 -52
- package/backend/dist/cjs/backend/src/errors/internal_external.js +0 -95
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +0 -41
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.js +0 -47
- package/backend/dist/cjs/backend/src/errors/system_error.d.ts +0 -261
- package/backend/dist/cjs/backend/src/errors/system_error.js +0 -436
- package/backend/dist/cjs/backend/src/events.d.ts +0 -97
- package/backend/dist/cjs/backend/src/events.js +0 -15
- package/backend/dist/cjs/backend/src/frontend.d.ts +0 -11
- package/backend/dist/cjs/backend/src/frontend.js +0 -37
- package/backend/dist/cjs/backend/src/image_endpoint.d.ts +0 -44
- package/backend/dist/cjs/backend/src/image_endpoint.js +0 -185
- package/backend/dist/cjs/backend/src/index.d.ts +0 -23
- package/backend/dist/cjs/backend/src/index.js +0 -70
- package/backend/dist/cjs/backend/src/logger.d.ts +0 -5
- package/backend/dist/cjs/backend/src/logger.js +0 -15
- package/backend/dist/cjs/backend/src/meta.d.ts +0 -112
- package/backend/dist/cjs/backend/src/meta.js +0 -181
- package/backend/dist/cjs/backend/src/payments/paddle.d.ts +0 -329
- package/backend/dist/cjs/backend/src/payments/paddle.js +0 -1996
- package/backend/dist/cjs/backend/src/payments/stripe/checkout.d.ts +0 -113
- package/backend/dist/cjs/backend/src/payments/stripe/checkout.js +0 -295
- package/backend/dist/cjs/backend/src/payments/stripe/customers.d.ts +0 -17
- package/backend/dist/cjs/backend/src/payments/stripe/customers.js +0 -164
- package/backend/dist/cjs/backend/src/payments/stripe/error.d.ts +0 -74
- package/backend/dist/cjs/backend/src/payments/stripe/error.js +0 -64
- package/backend/dist/cjs/backend/src/payments/stripe/events.d.ts +0 -155
- package/backend/dist/cjs/backend/src/payments/stripe/events.js +0 -15
- package/backend/dist/cjs/backend/src/payments/stripe/meters.d.ts +0 -105
- package/backend/dist/cjs/backend/src/payments/stripe/meters.js +0 -230
- package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.d.ts +0 -58
- package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.js +0 -109
- package/backend/dist/cjs/backend/src/payments/stripe/products.d.ts +0 -519
- package/backend/dist/cjs/backend/src/payments/stripe/products.js +0 -650
- package/backend/dist/cjs/backend/src/payments/stripe/stripe.d.ts +0 -215
- package/backend/dist/cjs/backend/src/payments/stripe/stripe.js +0 -468
- package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.d.ts +0 -172
- package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.js +0 -557
- package/backend/dist/cjs/backend/src/payments/stripe/utils.d.ts +0 -63
- package/backend/dist/cjs/backend/src/payments/stripe/utils.js +0 -118
- package/backend/dist/cjs/backend/src/payments/stripe/webhooks.d.ts +0 -105
- package/backend/dist/cjs/backend/src/payments/stripe/webhooks.js +0 -627
- package/backend/dist/cjs/backend/src/plugins/browser.d.ts +0 -1
- package/backend/dist/cjs/backend/src/plugins/browser.js +0 -15
- package/backend/dist/cjs/backend/src/plugins/communication.d.ts +0 -70
- package/backend/dist/cjs/backend/src/plugins/communication.js +0 -196
- package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +0 -255
- package/backend/dist/cjs/backend/src/plugins/mail/mail.js +0 -381
- package/backend/dist/cjs/backend/src/plugins/mail/ui.d.ts +0 -297
- package/backend/dist/cjs/backend/src/plugins/mail/ui.js +0 -1370
- package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +0 -1
- package/backend/dist/cjs/backend/src/plugins/pdf.js +0 -1456
- package/backend/dist/cjs/backend/src/plugins/thread_monitor.d.ts +0 -18
- package/backend/dist/cjs/backend/src/plugins/thread_monitor.js +0 -116
- package/backend/dist/cjs/backend/src/rate_limit.d.ts +0 -148
- package/backend/dist/cjs/backend/src/rate_limit.js +0 -543
- package/backend/dist/cjs/backend/src/route.d.ts +0 -39
- package/backend/dist/cjs/backend/src/route.js +0 -172
- package/backend/dist/cjs/backend/src/server.d.ts +0 -502
- package/backend/dist/cjs/backend/src/server.js +0 -1713
- package/backend/dist/cjs/backend/src/server.old.d.ts +0 -594
- package/backend/dist/cjs/backend/src/server.old.js +0 -2058
- package/backend/dist/cjs/backend/src/splash_screen.d.ts +0 -93
- package/backend/dist/cjs/backend/src/splash_screen.js +0 -119
- package/backend/dist/cjs/backend/src/status.d.ts +0 -89
- package/backend/dist/cjs/backend/src/status.js +0 -211
- package/backend/dist/cjs/backend/src/stream.d.ts +0 -494
- package/backend/dist/cjs/backend/src/stream.js +0 -1370
- package/backend/dist/cjs/backend/src/users.d.ts +0 -926
- package/backend/dist/cjs/backend/src/users.js +0 -2223
- package/backend/dist/cjs/backend/src/utils.d.ts +0 -22
- package/backend/dist/cjs/backend/src/utils.js +0 -626
- package/backend/dist/cjs/backend/src/view.d.ts +0 -115
- package/backend/dist/cjs/backend/src/view.js +0 -519
- package/backend/dist/cjs/backend/src/vinc.d.ts +0 -6
- package/backend/dist/cjs/backend/src/vinc.js +0 -40
- package/backend/dist/cjs/backend/src/volt.d.ts +0 -24
- package/backend/dist/cjs/backend/src/volt.js +0 -72
- package/backend/dist/cjs/frontend/src/modules/request.d.ts +0 -70
- package/backend/dist/cjs/frontend/src/modules/request.js +0 -99
- package/backend/dist/cjs/package.json +0 -1
- package/backend/dist/esm/backend/src/blacklist.d.ts +0 -12
- package/backend/dist/esm/backend/src/blacklist.js +0 -52
- package/backend/dist/esm/backend/src/cli.d.ts +0 -2
- package/backend/dist/esm/backend/src/cli.js +0 -211
- package/backend/dist/esm/backend/src/database/collection.d.ts +0 -1765
- package/backend/dist/esm/backend/src/database/collection.js +0 -3779
- package/backend/dist/esm/backend/src/database/database.d.ts +0 -92
- package/backend/dist/esm/backend/src/database/database.js +0 -214
- package/backend/dist/esm/backend/src/database/document.d.ts +0 -1
- package/backend/dist/esm/backend/src/database/document.js +0 -558
- package/backend/dist/esm/backend/src/database/filters/filters.d.ts +0 -6
- package/backend/dist/esm/backend/src/database/filters/filters.js +0 -1
- package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +0 -223
- package/backend/dist/esm/backend/src/database/filters/strict_filter.js +0 -3
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +0 -1
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +0 -505
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +0 -1
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +0 -712
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +0 -50
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +0 -5
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +0 -76
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +0 -44
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +0 -75
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +0 -5
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +0 -219
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +0 -1
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +0 -165
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +0 -5
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +0 -5
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +0 -415
- package/backend/dist/esm/backend/src/database/flatten.d.ts +0 -78
- package/backend/dist/esm/backend/src/database/flatten.js +0 -22
- package/backend/dist/esm/backend/src/database/flatten_test.d.ts +0 -1
- package/backend/dist/esm/backend/src/database/flatten_test.js +0 -174
- package/backend/dist/esm/backend/src/database/quota/quoata_v2.d.ts +0 -533
- package/backend/dist/esm/backend/src/database/quota/quoata_v2.js +0 -1155
- package/backend/dist/esm/backend/src/database/quota/quota.d.ts +0 -551
- package/backend/dist/esm/backend/src/database/quota/quota.js +0 -1219
- package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +0 -534
- package/backend/dist/esm/backend/src/database/quota/quota_v1.js +0 -1242
- package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +0 -412
- package/backend/dist/esm/backend/src/database/quota/safe_int.js +0 -810
- package/backend/dist/esm/backend/src/endpoint.d.ts +0 -346
- package/backend/dist/esm/backend/src/endpoint.js +0 -479
- package/backend/dist/esm/backend/src/errors/index.d.ts +0 -7
- package/backend/dist/esm/backend/src/errors/index.js +0 -7
- package/backend/dist/esm/backend/src/errors/internal_external.d.ts +0 -52
- package/backend/dist/esm/backend/src/errors/internal_external.js +0 -86
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +0 -41
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +0 -33
- package/backend/dist/esm/backend/src/errors/system_error.d.ts +0 -261
- package/backend/dist/esm/backend/src/errors/system_error.js +0 -444
- package/backend/dist/esm/backend/src/events.d.ts +0 -97
- package/backend/dist/esm/backend/src/events.js +0 -5
- package/backend/dist/esm/backend/src/frontend.d.ts +0 -11
- package/backend/dist/esm/backend/src/frontend.js +0 -12
- package/backend/dist/esm/backend/src/image_endpoint.d.ts +0 -44
- package/backend/dist/esm/backend/src/image_endpoint.js +0 -196
- package/backend/dist/esm/backend/src/index.d.ts +0 -23
- package/backend/dist/esm/backend/src/index.js +0 -26
- package/backend/dist/esm/backend/src/logger.d.ts +0 -5
- package/backend/dist/esm/backend/src/logger.js +0 -8
- package/backend/dist/esm/backend/src/meta.d.ts +0 -112
- package/backend/dist/esm/backend/src/meta.js +0 -152
- package/backend/dist/esm/backend/src/payments/paddle.d.ts +0 -329
- package/backend/dist/esm/backend/src/payments/paddle.js +0 -2276
- package/backend/dist/esm/backend/src/payments/stripe/checkout.d.ts +0 -113
- package/backend/dist/esm/backend/src/payments/stripe/checkout.js +0 -356
- package/backend/dist/esm/backend/src/payments/stripe/customers.d.ts +0 -17
- package/backend/dist/esm/backend/src/payments/stripe/customers.js +0 -193
- package/backend/dist/esm/backend/src/payments/stripe/error.d.ts +0 -74
- package/backend/dist/esm/backend/src/payments/stripe/error.js +0 -51
- package/backend/dist/esm/backend/src/payments/stripe/events.d.ts +0 -155
- package/backend/dist/esm/backend/src/payments/stripe/events.js +0 -5
- package/backend/dist/esm/backend/src/payments/stripe/meters.d.ts +0 -105
- package/backend/dist/esm/backend/src/payments/stripe/meters.js +0 -318
- package/backend/dist/esm/backend/src/payments/stripe/payment_methods.d.ts +0 -58
- package/backend/dist/esm/backend/src/payments/stripe/payment_methods.js +0 -135
- package/backend/dist/esm/backend/src/payments/stripe/products.d.ts +0 -519
- package/backend/dist/esm/backend/src/payments/stripe/products.js +0 -896
- package/backend/dist/esm/backend/src/payments/stripe/stripe.d.ts +0 -215
- package/backend/dist/esm/backend/src/payments/stripe/stripe.js +0 -464
- package/backend/dist/esm/backend/src/payments/stripe/subscriptions.d.ts +0 -172
- package/backend/dist/esm/backend/src/payments/stripe/subscriptions.js +0 -754
- package/backend/dist/esm/backend/src/payments/stripe/utils.d.ts +0 -63
- package/backend/dist/esm/backend/src/payments/stripe/utils.js +0 -131
- package/backend/dist/esm/backend/src/payments/stripe/webhooks.d.ts +0 -105
- package/backend/dist/esm/backend/src/payments/stripe/webhooks.js +0 -752
- package/backend/dist/esm/backend/src/plugins/browser.d.ts +0 -1
- package/backend/dist/esm/backend/src/plugins/browser.js +0 -170
- package/backend/dist/esm/backend/src/plugins/communication.d.ts +0 -70
- package/backend/dist/esm/backend/src/plugins/communication.js +0 -169
- package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +0 -255
- package/backend/dist/esm/backend/src/plugins/mail/mail.js +0 -396
- package/backend/dist/esm/backend/src/plugins/mail/ui.d.ts +0 -297
- package/backend/dist/esm/backend/src/plugins/mail/ui.js +0 -1400
- package/backend/dist/esm/backend/src/plugins/pdf.d.ts +0 -1
- package/backend/dist/esm/backend/src/plugins/pdf.js +0 -1694
- package/backend/dist/esm/backend/src/plugins/thread_monitor.d.ts +0 -18
- package/backend/dist/esm/backend/src/plugins/thread_monitor.js +0 -120
- package/backend/dist/esm/backend/src/rate_limit.d.ts +0 -148
- package/backend/dist/esm/backend/src/rate_limit.js +0 -667
- package/backend/dist/esm/backend/src/route.d.ts +0 -39
- package/backend/dist/esm/backend/src/route.js +0 -222
- package/backend/dist/esm/backend/src/server.d.ts +0 -502
- package/backend/dist/esm/backend/src/server.js +0 -2034
- package/backend/dist/esm/backend/src/server.old.d.ts +0 -594
- package/backend/dist/esm/backend/src/server.old.js +0 -2630
- package/backend/dist/esm/backend/src/splash_screen.d.ts +0 -93
- package/backend/dist/esm/backend/src/splash_screen.js +0 -156
- package/backend/dist/esm/backend/src/status.d.ts +0 -89
- package/backend/dist/esm/backend/src/status.js +0 -213
- package/backend/dist/esm/backend/src/stream.d.ts +0 -494
- package/backend/dist/esm/backend/src/stream.js +0 -1611
- package/backend/dist/esm/backend/src/users.d.ts +0 -926
- package/backend/dist/esm/backend/src/users.js +0 -2423
- package/backend/dist/esm/backend/src/utils.d.ts +0 -22
- package/backend/dist/esm/backend/src/utils.js +0 -463
- package/backend/dist/esm/backend/src/view.d.ts +0 -115
- package/backend/dist/esm/backend/src/view.js +0 -584
- package/backend/dist/esm/backend/src/vinc.d.ts +0 -6
- package/backend/dist/esm/backend/src/vinc.js +0 -6
- package/backend/dist/esm/backend/src/volt.d.ts +0 -24
- package/backend/dist/esm/backend/src/volt.js +0 -27
- package/backend/dist/esm/frontend/src/modules/request.d.ts +0 -70
- package/backend/dist/esm/frontend/src/modules/request.js +0 -117
- package/backend/old/file_watcher.ts +0 -359
- package/backend/old/request.deprc.js +0 -626
- package/backend/old/response.deprc.js +0 -354
- package/frontend/dist/backend/src/database/collection.d.ts +0 -1765
- package/frontend/dist/backend/src/database/collection.js +0 -3779
- package/frontend/dist/backend/src/database/database.d.ts +0 -92
- package/frontend/dist/backend/src/database/database.js +0 -214
- package/frontend/dist/backend/src/database/filters/filters.d.ts +0 -6
- package/frontend/dist/backend/src/database/filters/filters.js +0 -1
- package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +0 -223
- package/frontend/dist/backend/src/database/filters/strict_filter.js +0 -3
- package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +0 -165
- package/frontend/dist/backend/src/database/filters/strict_update_filter.js +0 -5
- package/frontend/dist/backend/src/database/flatten.d.ts +0 -78
- package/frontend/dist/backend/src/database/flatten.js +0 -22
- package/frontend/dist/backend/src/endpoint.d.ts +0 -346
- package/frontend/dist/backend/src/endpoint.js +0 -479
- package/frontend/dist/backend/src/errors/index.d.ts +0 -7
- package/frontend/dist/backend/src/errors/index.js +0 -7
- package/frontend/dist/backend/src/errors/internal_external.d.ts +0 -52
- package/frontend/dist/backend/src/errors/internal_external.js +0 -86
- package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +0 -41
- package/frontend/dist/backend/src/errors/invalid_usage_error.js +0 -33
- package/frontend/dist/backend/src/errors/system_error.d.ts +0 -261
- package/frontend/dist/backend/src/errors/system_error.js +0 -444
- package/frontend/dist/backend/src/events.d.ts +0 -97
- package/frontend/dist/backend/src/events.js +0 -5
- package/frontend/dist/backend/src/frontend.d.ts +0 -11
- package/frontend/dist/backend/src/frontend.js +0 -12
- package/frontend/dist/backend/src/image_endpoint.d.ts +0 -44
- package/frontend/dist/backend/src/image_endpoint.js +0 -196
- package/frontend/dist/backend/src/meta.d.ts +0 -112
- package/frontend/dist/backend/src/meta.js +0 -152
- package/frontend/dist/backend/src/payments/paddle.d.ts +0 -329
- package/frontend/dist/backend/src/payments/paddle.js +0 -2276
- package/frontend/dist/backend/src/payments/stripe/checkout.d.ts +0 -113
- package/frontend/dist/backend/src/payments/stripe/checkout.js +0 -356
- package/frontend/dist/backend/src/payments/stripe/customers.d.ts +0 -17
- package/frontend/dist/backend/src/payments/stripe/customers.js +0 -193
- package/frontend/dist/backend/src/payments/stripe/error.d.ts +0 -74
- package/frontend/dist/backend/src/payments/stripe/error.js +0 -51
- package/frontend/dist/backend/src/payments/stripe/events.d.ts +0 -155
- package/frontend/dist/backend/src/payments/stripe/events.js +0 -5
- package/frontend/dist/backend/src/payments/stripe/meters.d.ts +0 -105
- package/frontend/dist/backend/src/payments/stripe/meters.js +0 -318
- package/frontend/dist/backend/src/payments/stripe/payment_methods.d.ts +0 -58
- package/frontend/dist/backend/src/payments/stripe/payment_methods.js +0 -135
- package/frontend/dist/backend/src/payments/stripe/products.d.ts +0 -519
- package/frontend/dist/backend/src/payments/stripe/products.js +0 -896
- package/frontend/dist/backend/src/payments/stripe/stripe.d.ts +0 -215
- package/frontend/dist/backend/src/payments/stripe/stripe.js +0 -464
- package/frontend/dist/backend/src/payments/stripe/subscriptions.d.ts +0 -172
- package/frontend/dist/backend/src/payments/stripe/subscriptions.js +0 -754
- package/frontend/dist/backend/src/payments/stripe/utils.d.ts +0 -63
- package/frontend/dist/backend/src/payments/stripe/utils.js +0 -131
- package/frontend/dist/backend/src/payments/stripe/webhooks.d.ts +0 -105
- package/frontend/dist/backend/src/payments/stripe/webhooks.js +0 -752
- package/frontend/dist/backend/src/plugins/mail/mail.d.ts +0 -255
- package/frontend/dist/backend/src/plugins/mail/mail.js +0 -396
- package/frontend/dist/backend/src/plugins/mail/ui.d.ts +0 -297
- package/frontend/dist/backend/src/plugins/mail/ui.js +0 -1400
- package/frontend/dist/backend/src/rate_limit.d.ts +0 -148
- package/frontend/dist/backend/src/rate_limit.js +0 -667
- package/frontend/dist/backend/src/route.d.ts +0 -39
- package/frontend/dist/backend/src/route.js +0 -222
- package/frontend/dist/backend/src/server.d.ts +0 -502
- package/frontend/dist/backend/src/server.js +0 -2034
- package/frontend/dist/backend/src/splash_screen.d.ts +0 -93
- package/frontend/dist/backend/src/splash_screen.js +0 -156
- package/frontend/dist/backend/src/status.d.ts +0 -89
- package/frontend/dist/backend/src/status.js +0 -213
- package/frontend/dist/backend/src/stream.d.ts +0 -494
- package/frontend/dist/backend/src/stream.js +0 -1611
- package/frontend/dist/backend/src/users.d.ts +0 -926
- package/frontend/dist/backend/src/users.js +0 -2423
- package/frontend/dist/backend/src/utils.d.ts +0 -22
- package/frontend/dist/backend/src/utils.js +0 -463
- package/frontend/dist/backend/src/view.d.ts +0 -115
- package/frontend/dist/backend/src/view.js +0 -584
- package/frontend/dist/frontend/src/elements/base.d.ts +0 -3743
- package/frontend/dist/frontend/src/elements/base.js +0 -12151
- package/frontend/dist/frontend/src/elements/module.d.ts +0 -95
- package/frontend/dist/frontend/src/elements/module.js +0 -216
- package/frontend/dist/frontend/src/elements/register_element.d.ts +0 -3
- package/frontend/dist/frontend/src/elements/register_element.js +0 -22
- package/frontend/dist/frontend/src/elements/resize_query_manager.d.ts +0 -0
- package/frontend/dist/frontend/src/elements/resize_query_manager.js +0 -150
- package/frontend/dist/frontend/src/elements/types.d.ts +0 -52
- package/frontend/dist/frontend/src/elements/types.js +0 -5
- package/frontend/dist/frontend/src/index.d.ts +0 -21
- package/frontend/dist/frontend/src/index.js +0 -29
- package/frontend/dist/frontend/src/modules/attachment.d.ts +0 -126
- package/frontend/dist/frontend/src/modules/attachment.js +0 -306
- package/frontend/dist/frontend/src/modules/auth.d.ts +0 -44
- package/frontend/dist/frontend/src/modules/auth.js +0 -80
- package/frontend/dist/frontend/src/modules/color.d.ts +0 -160
- package/frontend/dist/frontend/src/modules/color.js +0 -316
- package/frontend/dist/frontend/src/modules/compression.d.ts +0 -39
- package/frontend/dist/frontend/src/modules/compression.js +0 -102
- package/frontend/dist/frontend/src/modules/cookies.d.ts +0 -44
- package/frontend/dist/frontend/src/modules/cookies.js +0 -143
- package/frontend/dist/frontend/src/modules/events.d.ts +0 -31
- package/frontend/dist/frontend/src/modules/events.js +0 -79
- package/frontend/dist/frontend/src/modules/google.d.ts +0 -23
- package/frontend/dist/frontend/src/modules/google.js +0 -52
- package/frontend/dist/frontend/src/modules/meta.d.ts +0 -14
- package/frontend/dist/frontend/src/modules/meta.js +0 -48
- package/frontend/dist/frontend/src/modules/paddle.d.ts +0 -1207
- package/frontend/dist/frontend/src/modules/paddle.js +0 -2594
- package/frontend/dist/frontend/src/modules/request.d.ts +0 -70
- package/frontend/dist/frontend/src/modules/request.js +0 -117
- package/frontend/dist/frontend/src/modules/settings.d.ts +0 -3
- package/frontend/dist/frontend/src/modules/settings.js +0 -5
- package/frontend/dist/frontend/src/modules/statics.d.ts +0 -21
- package/frontend/dist/frontend/src/modules/statics.js +0 -43
- package/frontend/dist/frontend/src/modules/stripe/cart.d.ts +0 -112
- package/frontend/dist/frontend/src/modules/stripe/cart.js +0 -321
- package/frontend/dist/frontend/src/modules/stripe/checkout.d.ts +0 -7
- package/frontend/dist/frontend/src/modules/stripe/checkout.js +0 -37
- package/frontend/dist/frontend/src/modules/stripe/index.m.d.ts +0 -6
- package/frontend/dist/frontend/src/modules/stripe/index.m.js +0 -6
- package/frontend/dist/frontend/src/modules/stripe/payments.d.ts +0 -58
- package/frontend/dist/frontend/src/modules/stripe/payments.js +0 -92
- package/frontend/dist/frontend/src/modules/support.d.ts +0 -30
- package/frontend/dist/frontend/src/modules/support.js +0 -53
- package/frontend/dist/frontend/src/modules/theme.d.ts +0 -133
- package/frontend/dist/frontend/src/modules/theme.js +0 -406
- package/frontend/dist/frontend/src/modules/themes.d.ts +0 -12
- package/frontend/dist/frontend/src/modules/themes.js +0 -22
- package/frontend/dist/frontend/src/modules/user.d.ts +0 -164
- package/frontend/dist/frontend/src/modules/user.js +0 -270
- package/frontend/dist/frontend/src/modules/utils.d.ts +0 -176
- package/frontend/dist/frontend/src/modules/utils.js +0 -569
- package/frontend/dist/frontend/src/types/gradient.d.ts +0 -29
- package/frontend/dist/frontend/src/types/gradient.js +0 -79
- package/frontend/dist/frontend/src/ui/border_button.d.ts +0 -94
- package/frontend/dist/frontend/src/ui/border_button.js +0 -228
- package/frontend/dist/frontend/src/ui/button.d.ts +0 -241
- package/frontend/dist/frontend/src/ui/button.js +0 -682
- package/frontend/dist/frontend/src/ui/canvas.d.ts +0 -138
- package/frontend/dist/frontend/src/ui/canvas.js +0 -444
- package/frontend/dist/frontend/src/ui/checkbox.d.ts +0 -74
- package/frontend/dist/frontend/src/ui/checkbox.js +0 -321
- package/frontend/dist/frontend/src/ui/code.d.ts +0 -235
- package/frontend/dist/frontend/src/ui/code.js +0 -1007
- package/frontend/dist/frontend/src/ui/context_menu.d.ts +0 -36
- package/frontend/dist/frontend/src/ui/context_menu.js +0 -205
- package/frontend/dist/frontend/src/ui/css.d.ts +0 -16
- package/frontend/dist/frontend/src/ui/css.js +0 -48
- package/frontend/dist/frontend/src/ui/divider.d.ts +0 -15
- package/frontend/dist/frontend/src/ui/divider.js +0 -78
- package/frontend/dist/frontend/src/ui/dropdown.d.ts +0 -176
- package/frontend/dist/frontend/src/ui/dropdown.js +0 -481
- package/frontend/dist/frontend/src/ui/for_each.d.ts +0 -37
- package/frontend/dist/frontend/src/ui/for_each.js +0 -92
- package/frontend/dist/frontend/src/ui/form.d.ts +0 -34
- package/frontend/dist/frontend/src/ui/form.js +0 -233
- package/frontend/dist/frontend/src/ui/frame_modes.d.ts +0 -37
- package/frontend/dist/frontend/src/ui/frame_modes.js +0 -108
- package/frontend/dist/frontend/src/ui/google_map.d.ts +0 -24
- package/frontend/dist/frontend/src/ui/google_map.js +0 -106
- package/frontend/dist/frontend/src/ui/gradient.d.ts +0 -25
- package/frontend/dist/frontend/src/ui/gradient.js +0 -131
- package/frontend/dist/frontend/src/ui/image.d.ts +0 -111
- package/frontend/dist/frontend/src/ui/image.js +0 -576
- package/frontend/dist/frontend/src/ui/input.d.ts +0 -392
- package/frontend/dist/frontend/src/ui/input.js +0 -1201
- package/frontend/dist/frontend/src/ui/link.d.ts +0 -25
- package/frontend/dist/frontend/src/ui/link.js +0 -140
- package/frontend/dist/frontend/src/ui/list.d.ts +0 -37
- package/frontend/dist/frontend/src/ui/list.js +0 -170
- package/frontend/dist/frontend/src/ui/loader_button.d.ts +0 -80
- package/frontend/dist/frontend/src/ui/loader_button.js +0 -193
- package/frontend/dist/frontend/src/ui/loaders.d.ts +0 -57
- package/frontend/dist/frontend/src/ui/loaders.js +0 -157
- package/frontend/dist/frontend/src/ui/popup.d.ts +0 -94
- package/frontend/dist/frontend/src/ui/popup.js +0 -510
- package/frontend/dist/frontend/src/ui/pseudo.d.ts +0 -44
- package/frontend/dist/frontend/src/ui/pseudo.js +0 -154
- package/frontend/dist/frontend/src/ui/scroller.d.ts +0 -105
- package/frontend/dist/frontend/src/ui/scroller.js +0 -1253
- package/frontend/dist/frontend/src/ui/slider.d.ts +0 -45
- package/frontend/dist/frontend/src/ui/slider.js +0 -217
- package/frontend/dist/frontend/src/ui/spacer.d.ts +0 -15
- package/frontend/dist/frontend/src/ui/spacer.js +0 -78
- package/frontend/dist/frontend/src/ui/span.d.ts +0 -15
- package/frontend/dist/frontend/src/ui/span.js +0 -73
- package/frontend/dist/frontend/src/ui/stack.d.ts +0 -66
- package/frontend/dist/frontend/src/ui/stack.js +0 -335
- package/frontend/dist/frontend/src/ui/steps.d.ts +0 -131
- package/frontend/dist/frontend/src/ui/steps.js +0 -308
- package/frontend/dist/frontend/src/ui/style.d.ts +0 -17
- package/frontend/dist/frontend/src/ui/style.js +0 -73
- package/frontend/dist/frontend/src/ui/switch.d.ts +0 -69
- package/frontend/dist/frontend/src/ui/switch.js +0 -357
- package/frontend/dist/frontend/src/ui/table.d.ts +0 -100
- package/frontend/dist/frontend/src/ui/table.js +0 -405
- package/frontend/dist/frontend/src/ui/tabs.d.ts +0 -111
- package/frontend/dist/frontend/src/ui/tabs.js +0 -424
- package/frontend/dist/frontend/src/ui/text.d.ts +0 -15
- package/frontend/dist/frontend/src/ui/text.js +0 -83
- package/frontend/dist/frontend/src/ui/title.d.ts +0 -91
- package/frontend/dist/frontend/src/ui/title.js +0 -272
- package/frontend/dist/frontend/src/ui/ui.d.ts +0 -35
- package/frontend/dist/frontend/src/ui/ui.js +0 -38
- package/frontend/dist/frontend/src/ui/view.d.ts +0 -15
- package/frontend/dist/frontend/src/ui/view.js +0 -88
- package/frontend/dist/frontend/src/volt.d.ts +0 -20
- package/frontend/dist/frontend/src/volt.js +0 -27
- package/frontend/examples/theme/theme.ts +0 -58
- package/frontend/tools/bundle_d_ts.js +0 -71
- package/frontend/tools/convert_to_jsdoc_input.txt +0 -9452
- package/frontend/tools/convert_to_jsdoc_output.txt +0 -7626
- package/frontend/tools/convert_to_jsdoc_tmp.js +0 -345
- package/frontend/tools/scan_mixed_imports.js +0 -69
- /package/frontend/{dist/frontend/src/css → css}/adyen.css +0 -0
- /package/frontend/{dist/frontend/src/css → css}/volt.css +0 -0
|
@@ -1,2594 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/*
|
|
3
|
-
* @author: Daan van den Bergh
|
|
4
|
-
* @copyright: © 2022 - 2024 Daan van den Bergh.
|
|
5
|
-
*/
|
|
6
|
-
// Imports.
|
|
7
|
-
import { Utils } from "./utils.js";
|
|
8
|
-
import { User } from "./user.js";
|
|
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";
|
|
22
|
-
import { Span } from "../ui/span.js";
|
|
23
|
-
import { request } from "./request.js";
|
|
24
|
-
// ---------------------------------------------------------
|
|
25
|
-
// Payments Object.
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated using stripe from now on.
|
|
28
|
-
*/
|
|
29
|
-
export var Payments;
|
|
30
|
-
(function (Payments) {
|
|
31
|
-
// ---------------------------------------------------------
|
|
32
|
-
// Private Properties.
|
|
33
|
-
const client_key = "{{PADDLE_CLIENT_KEY}}";
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
Payments.sandbox = "{{PADDLE_SANDBOX}}" === "true";
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
Payments.tax_inclusive = "{{PADDLE_INCLUSIVE_TAX}}" === "true";
|
|
38
|
-
Payments.countries = {
|
|
39
|
-
"AD": { name: "🇦🇩 Andorra", calling_code: "+376" },
|
|
40
|
-
"AE": { name: "🇦🇪 United Arab Emirates", calling_code: "+971" },
|
|
41
|
-
"AF": { name: "🇦🇫 Afghanistan", calling_code: "+93" },
|
|
42
|
-
"AG": { name: "🇦🇬 Antigua and Barbuda", calling_code: "+1-268" },
|
|
43
|
-
"AI": { name: "🇦🇮 Anguilla", calling_code: "+1-264" },
|
|
44
|
-
"AL": { name: "🇦🇱 Albania", calling_code: "+355" },
|
|
45
|
-
"AM": { name: "🇦🇲 Armenia", calling_code: "+374" },
|
|
46
|
-
"AO": { name: "🇦🇴 Angola", calling_code: "+244" },
|
|
47
|
-
"AQ": { name: "🇦🇶 Antarctica", calling_code: "+672" },
|
|
48
|
-
"AR": { name: "🇦🇷 Argentina", calling_code: "+54" },
|
|
49
|
-
"AS": { name: "🇦🇸 American Samoa", calling_code: "+1-684" },
|
|
50
|
-
"AT": { name: "🇦🇹 Austria", calling_code: "+43" },
|
|
51
|
-
"AU": { name: "🇦🇺 Australia", calling_code: "+61" },
|
|
52
|
-
"AW": { name: "🇦🇼 Aruba", calling_code: "+297" },
|
|
53
|
-
"AX": { name: "🇦🇽 Åland Islands", calling_code: "+358-18" },
|
|
54
|
-
"AZ": { name: "🇦🇿 Azerbaijan", calling_code: "+994" },
|
|
55
|
-
"BA": { name: "🇧🇦 Bosnia and Herzegovina", calling_code: "+387" },
|
|
56
|
-
"BB": { name: "🇧🇧 Barbados", calling_code: "+1-246" },
|
|
57
|
-
"BD": { name: "🇧🇩 Bangladesh", calling_code: "+880" },
|
|
58
|
-
"BE": { name: "🇧🇪 Belgium", calling_code: "+32" },
|
|
59
|
-
"BF": { name: "🇧🇫 Burkina Faso", calling_code: "+226" },
|
|
60
|
-
"BG": { name: "🇧🇬 Bulgaria", calling_code: "+359" },
|
|
61
|
-
"BH": { name: "🇧🇭 Bahrain", calling_code: "+973" },
|
|
62
|
-
"BI": { name: "🇧🇮 Burundi", calling_code: "+257" },
|
|
63
|
-
"BJ": { name: "🇧🇯 Benin", calling_code: "+229" },
|
|
64
|
-
"BL": { name: "🇧🇱 Saint Barthélemy", calling_code: "+590" },
|
|
65
|
-
"BM": { name: "🇧🇲 Bermuda", calling_code: "+1-441" },
|
|
66
|
-
"BN": { name: "🇧🇳 Brunei", calling_code: "+673" },
|
|
67
|
-
"BO": { name: "🇧🇴 Bolivia", calling_code: "+591" },
|
|
68
|
-
"BQ": { name: "🇧🇶 Caribbean Netherlands", calling_code: "+599" },
|
|
69
|
-
"BR": { name: "🇧🇷 Brazil", calling_code: "+55" },
|
|
70
|
-
"BS": { name: "🇧🇸 Bahamas", calling_code: "+1-242" },
|
|
71
|
-
"BT": { name: "🇧🇹 Bhutan", calling_code: "+975" },
|
|
72
|
-
"BV": { name: "🇧🇻 Bouvet Island", calling_code: "+47" },
|
|
73
|
-
"BW": { name: "🇧🇼 Botswana", calling_code: "+267" },
|
|
74
|
-
"BY": { name: "🇧🇾 Belarus", calling_code: "+375" },
|
|
75
|
-
"BZ": { name: "🇧🇿 Belize", calling_code: "+501" },
|
|
76
|
-
"CA": { name: "🇨🇦 Canada", calling_code: "+1" },
|
|
77
|
-
"CC": { name: "🇨🇨 Cocos (Keeling) Islands", calling_code: "+61" },
|
|
78
|
-
"CD": { name: "🇨🇩 Congo (DRC)", calling_code: "+243" },
|
|
79
|
-
"CF": { name: "🇨🇫 Central African Republic", calling_code: "+236" },
|
|
80
|
-
"CG": { name: "🇨🇬 Congo (Republic)", calling_code: "+242" },
|
|
81
|
-
"CH": { name: "🇨🇭 Switzerland", calling_code: "+41" },
|
|
82
|
-
"CI": { name: "🇨🇮 Côte d'Ivoire", calling_code: "+225" },
|
|
83
|
-
"CK": { name: "🇨🇰 Cook Islands", calling_code: "+682" },
|
|
84
|
-
"CL": { name: "🇨🇱 Chile", calling_code: "+56" },
|
|
85
|
-
"CM": { name: "🇨🇲 Cameroon", calling_code: "+237" },
|
|
86
|
-
"CN": { name: "🇨🇳 China", calling_code: "+86" },
|
|
87
|
-
"CO": { name: "🇨🇴 Colombia", calling_code: "+57" },
|
|
88
|
-
"CR": { name: "🇨🇷 Costa Rica", calling_code: "+506" },
|
|
89
|
-
"CU": { name: "🇨🇺 Cuba", calling_code: "+53" },
|
|
90
|
-
"CV": { name: "🇨🇻 Cape Verde", calling_code: "+238" },
|
|
91
|
-
"CW": { name: "🇨🇼 Curaçao", calling_code: "+599" },
|
|
92
|
-
"CX": { name: "🇨🇽 Christmas Island", calling_code: "+61" },
|
|
93
|
-
"CY": { name: "🇨🇾 Cyprus", calling_code: "+357" },
|
|
94
|
-
"CZ": { name: "🇨🇿 Czech Republic", calling_code: "+420" },
|
|
95
|
-
"DE": { name: "🇩🇪 Germany", calling_code: "+49" },
|
|
96
|
-
"DJ": { name: "🇩🇯 Djibouti", calling_code: "+253" },
|
|
97
|
-
"DK": { name: "🇩🇰 Denmark", calling_code: "+45" },
|
|
98
|
-
"DM": { name: "🇩🇲 Dominica", calling_code: "+1-767" },
|
|
99
|
-
"DO": { name: "🇩🇴 Dominican Republic", calling_code: "+1-809" },
|
|
100
|
-
"DZ": { name: "🇩🇿 Algeria", calling_code: "+213" },
|
|
101
|
-
"EC": { name: "🇪🇨 Ecuador", calling_code: "+593" },
|
|
102
|
-
"EE": { name: "🇪🇪 Estonia", calling_code: "+372" },
|
|
103
|
-
"EG": { name: "🇪🇬 Egypt", calling_code: "+20" },
|
|
104
|
-
"EH": { name: "🇪🇭 Western Sahara", calling_code: "+212" },
|
|
105
|
-
"ER": { name: "🇪🇷 Eritrea", calling_code: "+291" },
|
|
106
|
-
"ES": { name: "🇪🇸 Spain", calling_code: "+34" },
|
|
107
|
-
"ET": { name: "🇪🇹 Ethiopia", calling_code: "+251" },
|
|
108
|
-
"FI": { name: "🇫🇮 Finland", calling_code: "+358" },
|
|
109
|
-
"FJ": { name: "🇫🇯 Fiji", calling_code: "+679" },
|
|
110
|
-
"FK": { name: "🇫🇰 Falkland Islands (Malvinas)", calling_code: "+500" },
|
|
111
|
-
"FM": { name: "🇫🇲 Micronesia", calling_code: "+691" },
|
|
112
|
-
"FO": { name: "🇫🇴 Faroe Islands", calling_code: "+298" },
|
|
113
|
-
"FR": { name: "🇫🇷 France", calling_code: "+33" },
|
|
114
|
-
"GA": { name: "🇬🇦 Gabon", calling_code: "+241" },
|
|
115
|
-
"GB": { name: "🇬🇧 United Kingdom", calling_code: "+44" },
|
|
116
|
-
"GD": { name: "🇬🇩 Grenada", calling_code: "+1-473" },
|
|
117
|
-
"GE": { name: "🇬🇪 Georgia", calling_code: "+995" },
|
|
118
|
-
"GF": { name: "🇬🇫 French Guiana", calling_code: "+594" },
|
|
119
|
-
"GG": { name: "🇬🇬 Guernsey", calling_code: "+44" },
|
|
120
|
-
"GH": { name: "🇬🇭 Ghana", calling_code: "+233" },
|
|
121
|
-
"GI": { name: "🇬🇮 Gibraltar", calling_code: "+350" },
|
|
122
|
-
"GL": { name: "🇬🇱 Greenland", calling_code: "+299" },
|
|
123
|
-
"GM": { name: "🇬🇲 Gambia", calling_code: "+220" },
|
|
124
|
-
"GN": { name: "🇬🇳 Guinea", calling_code: "+224" },
|
|
125
|
-
"GP": { name: "🇬🇵 Guadeloupe", calling_code: "+590" },
|
|
126
|
-
"GQ": { name: "🇬🇶 Equatorial Guinea", calling_code: "+240" },
|
|
127
|
-
"GR": { name: "🇬🇷 Greece", calling_code: "+30" },
|
|
128
|
-
"GS": { name: "🇬🇸 South Georgia and the South Sandwich Islands", calling_code: "+500" },
|
|
129
|
-
"GT": { name: "🇬🇹 Guatemala", calling_code: "+502" },
|
|
130
|
-
"GU": { name: "🇬🇺 Guam", calling_code: "+1-671" },
|
|
131
|
-
"GW": { name: "🇬🇼 Guinea-Bissau", calling_code: "+245" },
|
|
132
|
-
"GY": { name: "🇬🇾 Guyana", calling_code: "+592" },
|
|
133
|
-
"HK": { name: "🇭🇰 Hong Kong", calling_code: "+852" },
|
|
134
|
-
"HM": { name: "🇭🇲 Heard Island and McDonald Islands", calling_code: "+672" },
|
|
135
|
-
"HN": { name: "🇭🇳 Honduras", calling_code: "+504" },
|
|
136
|
-
"HR": { name: "🇭🇷 Croatia", calling_code: "+385" },
|
|
137
|
-
"HT": { name: "🇭🇹 Haiti", calling_code: "+509" },
|
|
138
|
-
"HU": { name: "🇭🇺 Hungary", calling_code: "+36" },
|
|
139
|
-
"ID": { name: "🇮🇩 Indonesia", calling_code: "+62" },
|
|
140
|
-
"IE": { name: "🇮🇪 Ireland", calling_code: "+353" },
|
|
141
|
-
"IL": { name: "🇮🇱 Israel", calling_code: "+972" },
|
|
142
|
-
"IM": { name: "🇮🇲 Isle of Man", calling_code: "+44" },
|
|
143
|
-
"IN": { name: "🇮🇳 India", calling_code: "+91" },
|
|
144
|
-
"IO": { name: "🇮🇴 British Indian Ocean Territory", calling_code: "+246" },
|
|
145
|
-
"IQ": { name: "🇮🇶 Iraq", calling_code: "+964" },
|
|
146
|
-
"IR": { name: "🇮🇷 Iran", calling_code: "+98" },
|
|
147
|
-
"IS": { name: "🇮🇸 Iceland", calling_code: "+354" },
|
|
148
|
-
"IT": { name: "🇮🇹 Italy", calling_code: "+39" },
|
|
149
|
-
"JE": { name: "🇯🇪 Jersey", calling_code: "+44" },
|
|
150
|
-
"JM": { name: "🇯🇲 Jamaica", calling_code: "+1-876" },
|
|
151
|
-
"JO": { name: "🇯🇴 Jordan", calling_code: "+962" },
|
|
152
|
-
"JP": { name: "🇯🇵 Japan", calling_code: "+81" },
|
|
153
|
-
"KE": { name: "🇰🇪 Kenya", calling_code: "+254" },
|
|
154
|
-
"KG": { name: "🇰🇬 Kyrgyzstan", calling_code: "+996" },
|
|
155
|
-
"KH": { name: "🇰🇭 Cambodia", calling_code: "+855" },
|
|
156
|
-
"KI": { name: "🇰🇮 Kiribati", calling_code: "+686" },
|
|
157
|
-
"KM": { name: "🇰🇲 Comoros", calling_code: "+269" },
|
|
158
|
-
"KN": { name: "🇰🇳 Saint Kitts and Nevis", calling_code: "+1-869" },
|
|
159
|
-
"KP": { name: "🇰🇵 North Korea", calling_code: "+850" },
|
|
160
|
-
"KR": { name: "🇰🇷 South Korea", calling_code: "+82" },
|
|
161
|
-
"KW": { name: "🇰🇼 Kuwait", calling_code: "+965" },
|
|
162
|
-
"KY": { name: "🇰🇾 Cayman Islands", calling_code: "+1-345" },
|
|
163
|
-
"KZ": { name: "🇰🇿 Kazakhstan", calling_code: "+7" },
|
|
164
|
-
"LA": { name: "🇱🇦 Laos", calling_code: "+856" },
|
|
165
|
-
"LB": { name: "🇱🇧 Lebanon", calling_code: "+961" },
|
|
166
|
-
"LC": { name: "🇱🇨 Saint Lucia", calling_code: "+1-758" },
|
|
167
|
-
"LI": { name: "🇱🇮 Liechtenstein", calling_code: "+423" },
|
|
168
|
-
"LK": { name: "🇱🇰 Sri Lanka", calling_code: "+94" },
|
|
169
|
-
"LR": { name: "🇱🇷 Liberia", calling_code: "+231" },
|
|
170
|
-
"LS": { name: "🇱🇸 Lesotho", calling_code: "+266" },
|
|
171
|
-
"LT": { name: "🇱🇹 Lithuania", calling_code: "+370" },
|
|
172
|
-
"LU": { name: "🇱🇺 Luxembourg", calling_code: "+352" },
|
|
173
|
-
"LV": { name: "🇱🇻 Latvia", calling_code: "+371" },
|
|
174
|
-
"LY": { name: "🇱🇾 Libya", calling_code: "+218" },
|
|
175
|
-
"MA": { name: "🇲🇦 Morocco", calling_code: "+212" },
|
|
176
|
-
"MC": { name: "🇲🇨 Monaco", calling_code: "+377" },
|
|
177
|
-
"MD": { name: "🇲🇩 Moldova", calling_code: "+373" },
|
|
178
|
-
"ME": { name: "🇲🇪 Montenegro", calling_code: "+382" },
|
|
179
|
-
"MF": { name: "🇲🇫 Saint Martin", calling_code: "+590" },
|
|
180
|
-
"MG": { name: "🇲🇬 Madagascar", calling_code: "+261" },
|
|
181
|
-
"MH": { name: "🇲🇭 Marshall Islands", calling_code: "+692" },
|
|
182
|
-
"MK": { name: "🇲🇰 North Macedonia", calling_code: "+389" },
|
|
183
|
-
"ML": { name: "🇲🇱 Mali", calling_code: "+223" },
|
|
184
|
-
"MM": { name: "🇲🇲 Myanmar (Burma)", calling_code: "+95" },
|
|
185
|
-
"MN": { name: "🇲🇳 Mongolia", calling_code: "+976" },
|
|
186
|
-
"MO": { name: "🇲🇴 Macao", calling_code: "+853" },
|
|
187
|
-
"MP": { name: "🇲🇵 Northern Mariana Islands", calling_code: "+1-670" },
|
|
188
|
-
"MQ": { name: "🇲🇶 Martinique", calling_code: "+596" },
|
|
189
|
-
"MR": { name: "🇲🇷 Mauritania", calling_code: "+222" },
|
|
190
|
-
"MS": { name: "🇲🇸 Montserrat", calling_code: "+1-664" },
|
|
191
|
-
"MT": { name: "🇲🇹 Malta", calling_code: "+356" },
|
|
192
|
-
"MU": { name: "🇲🇺 Mauritius", calling_code: "+230" },
|
|
193
|
-
"MV": { name: "🇲🇻 Maldives", calling_code: "+960" },
|
|
194
|
-
"MW": { name: "🇲🇼 Malawi", calling_code: "+265" },
|
|
195
|
-
"MX": { name: "🇲🇽 Mexico", calling_code: "+52" },
|
|
196
|
-
"MY": { name: "🇲🇾 Malaysia", calling_code: "+60" },
|
|
197
|
-
"MZ": { name: "🇲🇿 Mozambique", calling_code: "+258" },
|
|
198
|
-
"NA": { name: "🇳🇦 Namibia", calling_code: "+264" },
|
|
199
|
-
"NC": { name: "🇳🇨 New Caledonia", calling_code: "+687" },
|
|
200
|
-
"NE": { name: "🇳🇪 Niger", calling_code: "+227" },
|
|
201
|
-
"NF": { name: "🇳🇫 Norfolk Island", calling_code: "+672" },
|
|
202
|
-
"NG": { name: "🇳🇬 Nigeria", calling_code: "+234" },
|
|
203
|
-
"NI": { name: "🇳🇮 Nicaragua", calling_code: "+505" },
|
|
204
|
-
"NL": { name: "🇳🇱 Netherlands", calling_code: "+31" },
|
|
205
|
-
"NO": { name: "🇳🇴 Norway", calling_code: "+47" },
|
|
206
|
-
"NP": { name: "🇳🇵 Nepal", calling_code: "+977" },
|
|
207
|
-
"NR": { name: "🇳🇷 Nauru", calling_code: "+674" },
|
|
208
|
-
"NU": { name: "🇳🇺 Niue", calling_code: "+683" },
|
|
209
|
-
"NZ": { name: "🇳🇿 New Zealand", calling_code: "+64" },
|
|
210
|
-
"OM": { name: "🇴🇲 Oman", calling_code: "+968" },
|
|
211
|
-
"PA": { name: "🇵🇦 Panama", calling_code: "+507" },
|
|
212
|
-
"PE": { name: "🇵🇪 Peru", calling_code: "+51" },
|
|
213
|
-
"PF": { name: "🇵🇫 French Polynesia", calling_code: "+689" },
|
|
214
|
-
"PG": { name: "🇵🇬 Papua New Guinea", calling_code: "+675" },
|
|
215
|
-
"PH": { name: "🇵🇭 Philippines", calling_code: "+63" },
|
|
216
|
-
"PK": { name: "🇵🇰 Pakistan", calling_code: "+92" },
|
|
217
|
-
"PL": { name: "🇵🇱 Poland", calling_code: "+48" },
|
|
218
|
-
"PM": { name: "🇵🇲 Saint Pierre and Miquelon", calling_code: "+508" },
|
|
219
|
-
"PN": { name: "🇵🇳 Pitcairn Islands", calling_code: "+64" },
|
|
220
|
-
"PR": { name: "🇵🇷 Puerto Rico", calling_code: "+1-787" },
|
|
221
|
-
"PS": { name: "🇵🇸 Palestine", calling_code: "+970" },
|
|
222
|
-
"PT": { name: "🇵🇹 Portugal", calling_code: "+351" },
|
|
223
|
-
"PW": { name: "🇵🇼 Palau", calling_code: "+680" },
|
|
224
|
-
"PY": { name: "🇵🇾 Paraguay", calling_code: "+595" },
|
|
225
|
-
"QA": { name: "🇶🇦 Qatar", calling_code: "+974" },
|
|
226
|
-
"RE": { name: "🇷🇪 Réunion", calling_code: "+262" },
|
|
227
|
-
"RO": { name: "🇷🇴 Romania", calling_code: "+40" },
|
|
228
|
-
"RS": { name: "🇷🇸 Serbia", calling_code: "+381" },
|
|
229
|
-
"RU": { name: "🇷🇺 Russia", calling_code: "+7" },
|
|
230
|
-
"RW": { name: "🇷🇼 Rwanda", calling_code: "+250" },
|
|
231
|
-
"SA": { name: "🇸🇦 Saudi Arabia", calling_code: "+966" },
|
|
232
|
-
"SB": { name: "🇸🇧 Solomon Islands", calling_code: "+677" },
|
|
233
|
-
"SC": { name: "🇸🇨 Seychelles", calling_code: "+248" },
|
|
234
|
-
"SD": { name: "🇸🇩 Sudan", calling_code: "+249" },
|
|
235
|
-
"SE": { name: "🇸🇪 Sweden", calling_code: "+46" },
|
|
236
|
-
"SG": { name: "🇸🇬 Singapore", calling_code: "+65" },
|
|
237
|
-
"SH": { name: "🇸🇭 Saint Helena, Ascension and Tristan da Cunha", calling_code: "+290" },
|
|
238
|
-
"SI": { name: "🇸🇮 Slovenia", calling_code: "+386" },
|
|
239
|
-
"SJ": { name: "🇸🇯 Svalbard and Jan Mayen", calling_code: "+47" },
|
|
240
|
-
"SK": { name: "🇸🇰 Slovakia", calling_code: "+421" },
|
|
241
|
-
"SL": { name: "🇸🇱 Sierra Leone", calling_code: "+232" },
|
|
242
|
-
"SM": { name: "🇸🇲 San Marino", calling_code: "+378" },
|
|
243
|
-
"SN": { name: "🇸🇳 Senegal", calling_code: "+221" },
|
|
244
|
-
"SO": { name: "🇸🇴 Somalia", calling_code: "+252" },
|
|
245
|
-
"SR": { name: "🇸🇷 Suriname", calling_code: "+597" },
|
|
246
|
-
"SS": { name: "🇸🇸 South Sudan", calling_code: "+211" },
|
|
247
|
-
"ST": { name: "🇸🇹 São Tomé and Príncipe", calling_code: "+239" },
|
|
248
|
-
"SV": { name: "🇸🇻 El Salvador", calling_code: "+503" },
|
|
249
|
-
"SX": { name: "🇸🇽 Sint Maarten", calling_code: "+1-721" },
|
|
250
|
-
"SY": { name: "🇸🇾 Syria", calling_code: "+963" },
|
|
251
|
-
"SZ": { name: "🇸🇿 Eswatini", calling_code: "+268" },
|
|
252
|
-
"TC": { name: "🇹🇨 Turks and Caicos Islands", calling_code: "+1-649" },
|
|
253
|
-
"TD": { name: "🇹🇩 Chad", calling_code: "+235" },
|
|
254
|
-
"TF": { name: "🇹🇫 French Southern and Antarctic Lands", calling_code: "+262" },
|
|
255
|
-
"TG": { name: "🇹🇬 Togo", calling_code: "+228" },
|
|
256
|
-
"TH": { name: "🇹🇭 Thailand", calling_code: "+66" },
|
|
257
|
-
"TJ": { name: "🇹🇯 Tajikistan", calling_code: "+992" },
|
|
258
|
-
"TK": { name: "🇹🇰 Tokelau", calling_code: "+690" },
|
|
259
|
-
"TL": { name: "🇹🇱 Timor-Leste", calling_code: "+670" },
|
|
260
|
-
"TM": { name: "🇹🇲 Turkmenistan", calling_code: "+993" },
|
|
261
|
-
"TN": { name: "🇹🇳 Tunisia", calling_code: "+216" },
|
|
262
|
-
"TO": { name: "🇹🇴 Tonga", calling_code: "+676" },
|
|
263
|
-
"TR": { name: "🇹🇷 Turkey", calling_code: "+90" },
|
|
264
|
-
"TT": { name: "🇹🇹 Trinidad and Tobago", calling_code: "+1-868" },
|
|
265
|
-
"TV": { name: "🇹🇻 Tuvalu", calling_code: "+688" },
|
|
266
|
-
"TW": { name: "🇹🇼 Taiwan", calling_code: "+886" },
|
|
267
|
-
"TZ": { name: "🇹🇿 Tanzania", calling_code: "+255" },
|
|
268
|
-
"UA": { name: "🇺🇦 Ukraine", calling_code: "+380" },
|
|
269
|
-
"UG": { name: "🇺🇬 Uganda", calling_code: "+256" },
|
|
270
|
-
"UM": { name: "🇺🇲 U.S. Minor Outlying Islands", calling_code: "+1" },
|
|
271
|
-
"US": { name: "🇺🇸 United States", calling_code: "+1" },
|
|
272
|
-
"UY": { name: "🇺🇾 Uruguay", calling_code: "+598" },
|
|
273
|
-
"UZ": { name: "🇺🇿 Uzbekistan", calling_code: "+998" },
|
|
274
|
-
"VA": { name: "🇻🇦 Vatican City", calling_code: "+379" },
|
|
275
|
-
"VC": { name: "🇻🇨 Saint Vincent and the Grenadines", calling_code: "+1-784" },
|
|
276
|
-
"VE": { name: "🇻🇪 Venezuela", calling_code: "+58" },
|
|
277
|
-
"VG": { name: "🇻🇬 British Virgin Islands", calling_code: "+1-284" },
|
|
278
|
-
"VI": { name: "🇻🇮 U.S. Virgin Islands", calling_code: "+1-340" },
|
|
279
|
-
"VN": { name: "🇻🇳 Vietnam", calling_code: "+84" },
|
|
280
|
-
"VU": { name: "🇻🇺 Vanuatu", calling_code: "+678" },
|
|
281
|
-
"WF": { name: "🇼🇫 Wallis and Futuna", calling_code: "+681" },
|
|
282
|
-
"WS": { name: "🇼🇸 Samoa", calling_code: "+685" },
|
|
283
|
-
"YE": { name: "🇾🇪 Yemen", calling_code: "+967" },
|
|
284
|
-
"YT": { name: "🇾🇹 Mayotte", calling_code: "+262" },
|
|
285
|
-
"ZA": { name: "🇿🇦 South Africa", calling_code: "+27" },
|
|
286
|
-
"ZM": { name: "🇿🇲 Zambia", calling_code: "+260" },
|
|
287
|
-
"ZW": { name: "🇿🇼 Zimbabwe", calling_code: "+263" }
|
|
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 = () => { };
|
|
313
|
-
// Additional properties that might be inferred from function bodies:
|
|
314
|
-
let _refund_policy; // Used in commented code
|
|
315
|
-
let _cancellation_policy; // Used in commented code
|
|
316
|
-
// cart: {
|
|
317
|
-
// items: [] as any[], // Replace 'any' with the actual item type.
|
|
318
|
-
// refresh: function() { /* Implement refresh logic */ },
|
|
319
|
-
// save: function() { /* Implement save logic */ },
|
|
320
|
-
// add: async function(productId: string, quantity: number) { /* Implement add logic */ },
|
|
321
|
-
// remove: async function(productId: string, quantity: number | "all") { /* Implement remove logic */ },
|
|
322
|
-
// },
|
|
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.
|
|
332
|
-
// ---------------------------------------------------------
|
|
333
|
-
// Private Methods.
|
|
334
|
-
/**
|
|
335
|
-
* Initialize Paddle with the provided client key and set up event callbacks.
|
|
336
|
-
*/
|
|
337
|
-
function _initialize_paddle() {
|
|
338
|
-
if (_paddle_initialized !== true) {
|
|
339
|
-
if (Payments.sandbox) {
|
|
340
|
-
Paddle.Environment.set("sandbox");
|
|
341
|
-
}
|
|
342
|
-
Paddle.Setup({
|
|
343
|
-
token: client_key,
|
|
344
|
-
eventCallback: (data) => {
|
|
345
|
-
if (data.name === "checkout.loaded") {
|
|
346
|
-
_render_payment_element_resolve();
|
|
347
|
-
}
|
|
348
|
-
else if (data.name === "checkout.completed") {
|
|
349
|
-
_show_processing("success");
|
|
350
|
-
}
|
|
351
|
-
else if (data.name === "checkout.payment.initiated") {
|
|
352
|
-
// Uncomment and implement if needed.
|
|
353
|
-
// _show_processing("processing");
|
|
354
|
-
}
|
|
355
|
-
else if (data.name === "checkout.payment.failed") {
|
|
356
|
-
_show_processing("error");
|
|
357
|
-
}
|
|
358
|
-
else if (data.type === "checkout.error") {
|
|
359
|
-
if (data.error?.detail) {
|
|
360
|
-
console.error(data);
|
|
361
|
-
Payments.on_error(data.error.detail);
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
console.error(data);
|
|
365
|
-
Payments.on_error(new Error("Unknown error"));
|
|
366
|
-
}
|
|
367
|
-
_render_payment_element_reject(data.detail.split("|")[0]);
|
|
368
|
-
}
|
|
369
|
-
else if (data.type === "checkout.warning") {
|
|
370
|
-
if (Payments.sandbox) {
|
|
371
|
-
console.log("Checkout warning:", data);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
// Handle other events if necessary.
|
|
376
|
-
// Uncomment for debugging.
|
|
377
|
-
// if (sandbox) {
|
|
378
|
-
// console.log("Event", data);
|
|
379
|
-
// }
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
_paddle_initialized = true;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Reset the payment element by removing it if it exists.
|
|
388
|
-
*/
|
|
389
|
-
function _reset_payment_element() {
|
|
390
|
-
if (_payment_element !== undefined) {
|
|
391
|
-
_payment_element.remove();
|
|
392
|
-
}
|
|
393
|
-
_payment_element = undefined;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Initialize the order by verifying authentication and making a POST request.
|
|
397
|
-
*/
|
|
398
|
-
async function _init_order() {
|
|
399
|
-
try {
|
|
400
|
-
if (_sign_in_redirect != null && !User.is_authenticated()) {
|
|
401
|
-
Utils.redirect(_sign_in_redirect);
|
|
402
|
-
}
|
|
403
|
-
const payload = {
|
|
404
|
-
items: Cart.items,
|
|
405
|
-
};
|
|
406
|
-
const response = await request({
|
|
407
|
-
method: "POST",
|
|
408
|
-
url: "/volt/api/v1/payments/init",
|
|
409
|
-
data: payload,
|
|
410
|
-
});
|
|
411
|
-
if (response.error) {
|
|
412
|
-
throw new Error(response.error.message);
|
|
413
|
-
}
|
|
414
|
-
// Handle response if necessary.
|
|
415
|
-
}
|
|
416
|
-
catch (err) {
|
|
417
|
-
if (typeof err === "object" && err.error != null) {
|
|
418
|
-
err = err.error;
|
|
419
|
-
}
|
|
420
|
-
throw new Error(err);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Set the current step in the payment process.
|
|
425
|
-
*/
|
|
426
|
-
async function _set_step() {
|
|
427
|
-
// Switch step.
|
|
428
|
-
switch (_payment_step) {
|
|
429
|
-
// Order.
|
|
430
|
-
case 0: {
|
|
431
|
-
// Select the current step.
|
|
432
|
-
_steps_element.select(_payment_step);
|
|
433
|
-
// Show and hide relevant containers.
|
|
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();
|
|
442
|
-
break;
|
|
443
|
-
}
|
|
444
|
-
// Address.
|
|
445
|
-
case 1: {
|
|
446
|
-
// Minimum duration for the loader.
|
|
447
|
-
const min_duration = new Promise(resolve => setTimeout(resolve, 350));
|
|
448
|
-
// Verify the order.
|
|
449
|
-
try {
|
|
450
|
-
await _init_order();
|
|
451
|
-
}
|
|
452
|
-
catch (err) {
|
|
453
|
-
--_payment_step;
|
|
454
|
-
console.error(err);
|
|
455
|
-
Payments.on_error(err);
|
|
456
|
-
return null;
|
|
457
|
-
}
|
|
458
|
-
// Render billing element.
|
|
459
|
-
_render_billing_element();
|
|
460
|
-
// Await minimum duration.
|
|
461
|
-
await min_duration;
|
|
462
|
-
// Select the current step.
|
|
463
|
-
_steps_element.select(_payment_step);
|
|
464
|
-
// Show and hide relevant containers.
|
|
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();
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
// Payment.
|
|
476
|
-
case 2: {
|
|
477
|
-
// Check if the billing details are entered correctly.
|
|
478
|
-
try {
|
|
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;
|
|
482
|
-
}
|
|
483
|
-
catch (error) {
|
|
484
|
-
--_payment_step;
|
|
485
|
-
console.error(error);
|
|
486
|
-
Payments.on_error(error);
|
|
487
|
-
return null;
|
|
488
|
-
}
|
|
489
|
-
// Render payment element.
|
|
490
|
-
try {
|
|
491
|
-
await _render_payment_element();
|
|
492
|
-
}
|
|
493
|
-
catch (error) {
|
|
494
|
-
--_payment_step;
|
|
495
|
-
console.error(error);
|
|
496
|
-
Payments.on_error(error);
|
|
497
|
-
return null;
|
|
498
|
-
}
|
|
499
|
-
// Select the current step.
|
|
500
|
-
_steps_element.select(_payment_step);
|
|
501
|
-
// Show and hide relevant containers.
|
|
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();
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Navigate to the next step in the payment process.
|
|
516
|
-
*/
|
|
517
|
-
async function _next() {
|
|
518
|
-
if (_payment_step < 3) {
|
|
519
|
-
++_payment_step;
|
|
520
|
-
return _set_step();
|
|
521
|
-
}
|
|
522
|
-
else if (_payment_step === 3) {
|
|
523
|
-
return _set_step();
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Navigate to the previous step in the payment process.
|
|
528
|
-
*/
|
|
529
|
-
async function _prev() {
|
|
530
|
-
if (_payment_step > 0) {
|
|
531
|
-
--_payment_step;
|
|
532
|
-
return _set_step();
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Render the steps element in the UI.
|
|
537
|
-
*/
|
|
538
|
-
function _render_steps_element() {
|
|
539
|
-
// Shortcuts.
|
|
540
|
-
const style = _style;
|
|
541
|
-
// The previous step button.
|
|
542
|
-
_prev_step_button = HStack(ImageMask("/volt/assets/payments/arrow.long.webp")
|
|
543
|
-
.frame(15, 15)
|
|
544
|
-
.mask_color(_style.fg_1)
|
|
545
|
-
.transition_mask("background 300ms ease-in-out")
|
|
546
|
-
.transform("rotate(180deg)")
|
|
547
|
-
.margin_right(10), Text("Previous Step")
|
|
548
|
-
.color(_style.fg_1)
|
|
549
|
-
.transition("color 300ms ease-in-out")
|
|
550
|
-
.padding(0)
|
|
551
|
-
.margin(0)
|
|
552
|
-
.font_size(14))
|
|
553
|
-
.hide()
|
|
554
|
-
.on_mouse_over_out((e) => {
|
|
555
|
-
e.child(0).color(_style.fg);
|
|
556
|
-
e.child(1).color(_style.fg);
|
|
557
|
-
}, (e) => {
|
|
558
|
-
e.child(0).color(_style.fg_1);
|
|
559
|
-
e.child(1).color(_style.fg_1);
|
|
560
|
-
})
|
|
561
|
-
.on_click(() => {
|
|
562
|
-
_prev()
|
|
563
|
-
.catch((err) => console.error(err));
|
|
564
|
-
})
|
|
565
|
-
.center_vertical();
|
|
566
|
-
// The steps element.
|
|
567
|
-
_steps_element = HStack(ForEach(["Order Details", "Billing Details", "Payment Details", "Processing Details"], (item, index) => {
|
|
568
|
-
const stack = HStack(VStack((index + 1).toString())
|
|
569
|
-
.font_size(11)
|
|
570
|
-
.padding(0)
|
|
571
|
-
.margin(0)
|
|
572
|
-
.color(index === 0 ? _style.selected.fg : _style.fg_1)
|
|
573
|
-
.frame(17.5, 17.5)
|
|
574
|
-
.background(index === 0 ? _style.selected.bg : _style.bg_1)
|
|
575
|
-
.transition("color 300ms ease-in-out, background 300ms ease-in-out")
|
|
576
|
-
.border_radius("50%")
|
|
577
|
-
.margin_right(15)
|
|
578
|
-
.flex_shrink(0)
|
|
579
|
-
.center()
|
|
580
|
-
.center_vertical()
|
|
581
|
-
.border(1, _style.divider_bg), Text(item)
|
|
582
|
-
.color(index === 0 ? _style.fg : _style.fg_1)
|
|
583
|
-
.transition("color 300ms ease-in-out")
|
|
584
|
-
.padding(0)
|
|
585
|
-
.font_size(14)
|
|
586
|
-
.line_height(16))
|
|
587
|
-
.center_vertical()
|
|
588
|
-
.margin_right(25);
|
|
589
|
-
return stack;
|
|
590
|
-
}), Spacer().min_frame(10, 1), _prev_step_button)
|
|
591
|
-
.overflow_x("scroll")
|
|
592
|
-
.class("volt_hide_scrollbar")
|
|
593
|
-
.extend({
|
|
594
|
-
selected_index: 0,
|
|
595
|
-
/**
|
|
596
|
-
* Select the current step index and update UI accordingly.
|
|
597
|
-
* @param index - The index of the step to select.
|
|
598
|
-
*/
|
|
599
|
-
select(index) {
|
|
600
|
-
let e = this.child(this.selected_index);
|
|
601
|
-
e.child(0)
|
|
602
|
-
.color(style.fg_1)
|
|
603
|
-
.background(style.bg_1);
|
|
604
|
-
e.child(1)
|
|
605
|
-
.color(style.fg_1);
|
|
606
|
-
this.selected_index = index;
|
|
607
|
-
e = this.child(this.selected_index);
|
|
608
|
-
e.child(0)
|
|
609
|
-
.color(style.selected.fg)
|
|
610
|
-
.background(style.selected.bg);
|
|
611
|
-
e.child(1)
|
|
612
|
-
.color(style.fg);
|
|
613
|
-
return this;
|
|
614
|
-
},
|
|
615
|
-
});
|
|
616
|
-
// Append the steps element to the steps container.
|
|
617
|
-
_steps_container.append(_steps_element);
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Render the overview element in the UI.
|
|
621
|
-
*/
|
|
622
|
-
function _render_overview_element() {
|
|
623
|
-
// The subtotal price from the overview.
|
|
624
|
-
_overview_subtotal = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
|
|
625
|
-
.color(_style.fg)
|
|
626
|
-
.font_size(_style.font_size)
|
|
627
|
-
.flex_shrink(0)
|
|
628
|
-
.margin(0)
|
|
629
|
-
.padding(0);
|
|
630
|
-
// The total price from the overview.
|
|
631
|
-
_overview_total = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
|
|
632
|
-
.font_weight("bold")
|
|
633
|
-
.color(_style.fg)
|
|
634
|
-
.font_size(_style.font_size)
|
|
635
|
-
.flex_shrink(0)
|
|
636
|
-
.margin(0)
|
|
637
|
-
.padding(0);
|
|
638
|
-
// The subtotal VAT price from the overview.
|
|
639
|
-
_overview_subtotal_tax = Text(`${_currency_symbol == null ? "$" : _currency_symbol} 0.00`)
|
|
640
|
-
.color(_style.fg)
|
|
641
|
-
.font_size(_style.font_size)
|
|
642
|
-
.flex_shrink(0)
|
|
643
|
-
.margin(0)
|
|
644
|
-
.padding(0);
|
|
645
|
-
// The tax stack.
|
|
646
|
-
_overview_tax_container = HStack(Text("Tax:")
|
|
647
|
-
.color(_style.fg)
|
|
648
|
-
.font_size(_style.font_size)
|
|
649
|
-
.stretch(true)
|
|
650
|
-
.flex_shrink(0)
|
|
651
|
-
.margin(0, 5, 0, 0)
|
|
652
|
-
.padding(0)
|
|
653
|
-
.wrap(false)
|
|
654
|
-
.overflow("hidden")
|
|
655
|
-
.text_overflow("ellipsis"), _overview_subtotal_tax)
|
|
656
|
-
.margin_top(5);
|
|
657
|
-
// The incl/excl tax text.
|
|
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)
|
|
661
|
-
.margin(2.5, 0, 0, 0)
|
|
662
|
-
.padding(0)
|
|
663
|
-
.flex_shrink(0)
|
|
664
|
-
.text_trailing();
|
|
665
|
-
// The checkout button.
|
|
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)
|
|
672
|
-
.nodes.loader
|
|
673
|
-
.background(_style.button.fg)
|
|
674
|
-
.update()
|
|
675
|
-
.parent()
|
|
676
|
-
.on_click(async () => {
|
|
677
|
-
_checkout_button.show_loader();
|
|
678
|
-
_next()
|
|
679
|
-
.then(() => {
|
|
680
|
-
_checkout_button.hide_loader();
|
|
681
|
-
})
|
|
682
|
-
.catch((err) => {
|
|
683
|
-
console.error(err);
|
|
684
|
-
_checkout_button.hide_loader();
|
|
685
|
-
});
|
|
686
|
-
});
|
|
687
|
-
// Accept agreements (currently commented out).
|
|
688
|
-
// this._policy_checkbox = CheckBox({
|
|
689
|
-
// text: "I agree to the Terms and Conditions and the " +
|
|
690
|
-
// Link("Refund", this._refund_policy) +
|
|
691
|
-
// " and " +
|
|
692
|
-
// Link("Cancellation", this._cancellation_policy) +
|
|
693
|
-
// " policy. I agree that my payment method may be used for recurring subscriptions.",
|
|
694
|
-
// required: true
|
|
695
|
-
// }) // @todo check text.
|
|
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)
|
|
702
|
-
// .margin_bottom(15)
|
|
703
|
-
// .hide();
|
|
704
|
-
// The overview element.
|
|
705
|
-
_overview_element = VStack(Title("Overview")
|
|
706
|
-
.color(_style.fg)
|
|
707
|
-
.width("fit-content")
|
|
708
|
-
.font_size(_style.font_size - 2)
|
|
709
|
-
.flex_shrink(0)
|
|
710
|
-
.margin(0, 0, 15, 0)
|
|
711
|
-
.letter_spacing("1px")
|
|
712
|
-
.text_transform("uppercase")
|
|
713
|
-
.ellipsis_overflow(true), HStack(Text("Subtotal:")
|
|
714
|
-
.color(_style.fg)
|
|
715
|
-
.font_size(_style.font_size)
|
|
716
|
-
.stretch(true)
|
|
717
|
-
.flex_shrink(0)
|
|
718
|
-
.margin(0, 5, 0, 0)
|
|
719
|
-
.padding(0)
|
|
720
|
-
.wrap(false)
|
|
721
|
-
.overflow("hidden")
|
|
722
|
-
.text_overflow("ellipsis"), _overview_subtotal),
|
|
723
|
-
// Uncomment and define Shipping if needed.
|
|
724
|
-
// HStack(
|
|
725
|
-
// Text("Shipping:")
|
|
726
|
-
// .color(_style.fg_1)
|
|
727
|
-
// .font_size(_style.font_size)
|
|
728
|
-
// .stretch(true)
|
|
729
|
-
// .flex_shrink(0)
|
|
730
|
-
// .margin(0, 5, 0, 0)
|
|
731
|
-
// .padding(0)
|
|
732
|
-
// .wrap(false)
|
|
733
|
-
// .overflow("hidden")
|
|
734
|
-
// .text_overflow("ellipsis"),
|
|
735
|
-
// Text("free")
|
|
736
|
-
// .color(_style.fg_1)
|
|
737
|
-
// .font_size(_style.font_size)
|
|
738
|
-
// .flex_shrink(0)
|
|
739
|
-
// .margin(0)
|
|
740
|
-
// .padding(0)
|
|
741
|
-
// .wrap(false)
|
|
742
|
-
// .overflow("hidden")
|
|
743
|
-
// .text_overflow("ellipsis"),
|
|
744
|
-
// )
|
|
745
|
-
// .margin_top(5),
|
|
746
|
-
_overview_tax_container, Divider()
|
|
747
|
-
.margin(20, 0, 20, 0)
|
|
748
|
-
.background(_style.divider_bg), HStack(Text("Total:")
|
|
749
|
-
.font_weight("bold")
|
|
750
|
-
.color(_style.fg)
|
|
751
|
-
.font_size(_style.font_size)
|
|
752
|
-
.stretch(true)
|
|
753
|
-
.flex_shrink(0)
|
|
754
|
-
.margin(0, 5, 0, 0)
|
|
755
|
-
.padding(0)
|
|
756
|
-
.wrap(false)
|
|
757
|
-
.overflow("hidden")
|
|
758
|
-
.text_overflow("ellipsis"), VStack(_overview_total, _overview_incl_excl_tax))
|
|
759
|
-
.margin_bottom(25),
|
|
760
|
-
// this._policy_checkbox,
|
|
761
|
-
_checkout_button)
|
|
762
|
-
.extend({
|
|
763
|
-
total: 0,
|
|
764
|
-
tax: 0,
|
|
765
|
-
/**
|
|
766
|
-
* Handle unknown tax scenarios by updating the UI accordingly.
|
|
767
|
-
*/
|
|
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)}`);
|
|
773
|
-
},
|
|
774
|
-
/**
|
|
775
|
-
* Calculate tax based on the provided country code.
|
|
776
|
-
* @param country - The country code to calculate tax for.
|
|
777
|
-
*/
|
|
778
|
-
async calc_tax(country) {
|
|
779
|
-
_initialize_paddle();
|
|
780
|
-
try {
|
|
781
|
-
const result = await Paddle.PricePreview({
|
|
782
|
-
items: Cart.items.map((item) => {
|
|
783
|
-
return { priceId: item.product.price_id, quantity: item.quantity };
|
|
784
|
-
}),
|
|
785
|
-
address: { countryCode: country },
|
|
786
|
-
});
|
|
787
|
-
_overview_element.tax = 0;
|
|
788
|
-
result.data.details.lineItems.forEach((item) => {
|
|
789
|
-
_overview_element.tax += parseInt(item.totals.tax) / 100;
|
|
790
|
-
});
|
|
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)}`);
|
|
795
|
-
}
|
|
796
|
-
catch (error) {
|
|
797
|
-
if (error?.error?.detail) {
|
|
798
|
-
Payments.on_error(error.error.detail);
|
|
799
|
-
console.error(error);
|
|
800
|
-
}
|
|
801
|
-
else {
|
|
802
|
-
console.error(error);
|
|
803
|
-
}
|
|
804
|
-
_overview_element.unknown_tax();
|
|
805
|
-
}
|
|
806
|
-
},
|
|
807
|
-
});
|
|
808
|
-
// Append the overview element to the overview container.
|
|
809
|
-
_overview_container.append(_overview_element);
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* Render the order element in the UI.
|
|
813
|
-
*/
|
|
814
|
-
function _render_order_element() {
|
|
815
|
-
// Render.
|
|
816
|
-
_order_element = VStack()
|
|
817
|
-
.extend({
|
|
818
|
-
/**
|
|
819
|
-
* Refresh the order element by updating the cart and UI elements.
|
|
820
|
-
*/
|
|
821
|
-
refresh() {
|
|
822
|
-
// Refresh the cart.
|
|
823
|
-
Cart.refresh();
|
|
824
|
-
// Shortcuts.
|
|
825
|
-
const style = _style;
|
|
826
|
-
const cart_items = Cart.items;
|
|
827
|
-
// Shopping cart view.
|
|
828
|
-
let currency_symbol = null;
|
|
829
|
-
let subtotal = 0;
|
|
830
|
-
cart_items.forEach((item) => {
|
|
831
|
-
if (currency_symbol == null) {
|
|
832
|
-
currency_symbol = Payments.get_currency_symbol(item.product.currency);
|
|
833
|
-
}
|
|
834
|
-
subtotal += item.product.price * item.quantity;
|
|
835
|
-
});
|
|
836
|
-
if (currency_symbol == null) {
|
|
837
|
-
currency_symbol = "$";
|
|
838
|
-
}
|
|
839
|
-
_currency_symbol = currency_symbol;
|
|
840
|
-
// Set the overview prices.
|
|
841
|
-
_overview_subtotal.text(`${currency_symbol} ${subtotal.toFixed(2)}`);
|
|
842
|
-
_overview_element.total = subtotal;
|
|
843
|
-
_overview_element.unknown_tax();
|
|
844
|
-
// Add the products.
|
|
845
|
-
this.remove_children();
|
|
846
|
-
if (cart_items.length === 0) {
|
|
847
|
-
this.height(160);
|
|
848
|
-
this.append(VStack(Title("Empty Shopping Cart")
|
|
849
|
-
.color(style.fg_1)
|
|
850
|
-
.font_size(style.font_size - 2)
|
|
851
|
-
.flex_shrink(0)
|
|
852
|
-
.letter_spacing("1px")
|
|
853
|
-
.text_transform("uppercase")
|
|
854
|
-
.ellipsis_overflow(true)
|
|
855
|
-
.margin(0)
|
|
856
|
-
.padding(0)
|
|
857
|
-
.assign_to_parent_as("title_e"), Text(`Your shopping cart is empty.`)
|
|
858
|
-
.color(style.fg_2)
|
|
859
|
-
.font_size(style.font_size - 2)
|
|
860
|
-
.line_height(style.font_size)
|
|
861
|
-
.margin(5, 0, 0, 0)
|
|
862
|
-
.padding(0)
|
|
863
|
-
.assign_to_parent_as("text_e")
|
|
864
|
-
.white_space("pre")
|
|
865
|
-
.line_height("1.4em")
|
|
866
|
-
.center(), ImageMask("/volt/assets/payments/shopping_cart.webp")
|
|
867
|
-
.frame(35, 35)
|
|
868
|
-
.margin_top(20)
|
|
869
|
-
.mask_color(style.theme_fg))
|
|
870
|
-
.frame("100%", "100%")
|
|
871
|
-
.center()
|
|
872
|
-
.center_vertical());
|
|
873
|
-
}
|
|
874
|
-
else {
|
|
875
|
-
// Uncomment and adjust height if necessary.
|
|
876
|
-
// this.height("100%");
|
|
877
|
-
this.append(Title("Order Details")
|
|
878
|
-
.color(style.fg)
|
|
879
|
-
.width("fit-content")
|
|
880
|
-
.font_size(style.font_size - 2)
|
|
881
|
-
.flex_shrink(0)
|
|
882
|
-
.margin(0, 0, 0, 0)
|
|
883
|
-
.letter_spacing("1px")
|
|
884
|
-
.text_transform("uppercase")
|
|
885
|
-
.ellipsis_overflow(true), Divider()
|
|
886
|
-
.background(style.divider_bg)
|
|
887
|
-
.margin(10, 0, 20, 0), ForEach(cart_items, (item, index) => {
|
|
888
|
-
let focus = false, mouse_over = false;
|
|
889
|
-
const quantity_input = Input("Quantity")
|
|
890
|
-
.value(item.quantity)
|
|
891
|
-
.font_size(16)
|
|
892
|
-
.color(style.fg_1)
|
|
893
|
-
.font_size(style.font_size - 2)
|
|
894
|
-
.border(1, style.divider_bg)
|
|
895
|
-
// .padding(12.5, 10, 12.5, 10)
|
|
896
|
-
.padding(2.5, 7.5)
|
|
897
|
-
.margin_right(25)
|
|
898
|
-
.flex_shrink(0)
|
|
899
|
-
.width(`calc(${item.quantity.toString().length}ch + 17.5px)`) // add padding.
|
|
900
|
-
.background(style.bg_1)
|
|
901
|
-
.display("inline")
|
|
902
|
-
.transition("color 300ms ease-in-out")
|
|
903
|
-
.center()
|
|
904
|
-
.on_input((_, event) => {
|
|
905
|
-
const value = quantity_input.value();
|
|
906
|
-
quantity_input.width(`calc(${value.length}ch + 17.5px)`); // add padding.
|
|
907
|
-
clearTimeout(quantity_input._timeout);
|
|
908
|
-
quantity_input._timeout = setTimeout(() => {
|
|
909
|
-
const quantity = parseInt(value);
|
|
910
|
-
if (isNaN(quantity)) {
|
|
911
|
-
console.error(`Specified quantity "${value}" is not a number.`);
|
|
912
|
-
Payments.on_error(new Error(`Specified quantity "${value}" is not a number.`));
|
|
913
|
-
quantity_input.value(item.quantity.toString());
|
|
914
|
-
return null;
|
|
915
|
-
}
|
|
916
|
-
item.quantity = quantity;
|
|
917
|
-
Cart.save();
|
|
918
|
-
this.refresh();
|
|
919
|
-
}, 500);
|
|
920
|
-
})
|
|
921
|
-
.on_mouse_over_out((e) => {
|
|
922
|
-
e.color(style.fg);
|
|
923
|
-
mouse_over = true;
|
|
924
|
-
e.mask_color(style.fg);
|
|
925
|
-
}, (e) => {
|
|
926
|
-
mouse_over = false;
|
|
927
|
-
if (!mouse_over && !focus) {
|
|
928
|
-
e.color(style.fg_1);
|
|
929
|
-
}
|
|
930
|
-
})
|
|
931
|
-
.on_focus((e) => {
|
|
932
|
-
e.color(style.fg);
|
|
933
|
-
focus = true;
|
|
934
|
-
})
|
|
935
|
-
.on_blur((e) => {
|
|
936
|
-
focus = false;
|
|
937
|
-
if (!mouse_over && !focus) {
|
|
938
|
-
e.color(style.fg_1);
|
|
939
|
-
}
|
|
940
|
-
});
|
|
941
|
-
let per_item = " per item" + (Payments.tax_inclusive ? " incl. tax" : " excl. tax") + ",";
|
|
942
|
-
let renews_every = null;
|
|
943
|
-
if (item.product.interval) {
|
|
944
|
-
if (item.product.frequency === 1) {
|
|
945
|
-
renews_every = `renews ${item.product.interval}ly.`;
|
|
946
|
-
}
|
|
947
|
-
else {
|
|
948
|
-
renews_every = `renews every ${item.product.frequency} ${item.product.interval}s.`;
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
let trial_text = null;
|
|
952
|
-
if (item.product.trial) {
|
|
953
|
-
if (item.product.trial.frequency === 1) {
|
|
954
|
-
trial_text = `${item.product.trial.frequency} ${item.product.trial.interval} free`;
|
|
955
|
-
}
|
|
956
|
-
else {
|
|
957
|
-
trial_text = `${item.product.trial.frequency} ${item.product.trial.interval}s free`;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
const stack = HStack(item.product.icon == null ? null :
|
|
961
|
-
ImageMask(item.product.icon)
|
|
962
|
-
.frame(30, 30)
|
|
963
|
-
.flex_shrink(0)
|
|
964
|
-
.margin(0, 25, 0, 0), VStack(Title(item.product.name)
|
|
965
|
-
.color(style.fg)
|
|
966
|
-
.font_size(style.font_size)
|
|
967
|
-
.margin(0, 10, 0, 0)
|
|
968
|
-
.padding(0)
|
|
969
|
-
.wrap(false)
|
|
970
|
-
.overflow("hidden")
|
|
971
|
-
.text_overflow("ellipsis"), Text(item.product.description)
|
|
972
|
-
.color(style.fg_1)
|
|
973
|
-
.font_size(style.font_size - 2)
|
|
974
|
-
.line_height(style.font_size)
|
|
975
|
-
.margin(10, 10, 0, 0)
|
|
976
|
-
.wrap(true)
|
|
977
|
-
.padding(0), HStack(Text("Quantity:")
|
|
978
|
-
.color(style.fg_1)
|
|
979
|
-
.font_size(style.font_size - 2)
|
|
980
|
-
// .line_height(style.font_size)
|
|
981
|
-
.margin(0, 10, 2, 0)
|
|
982
|
-
.padding(0)
|
|
983
|
-
.flex_shrink(0), quantity_input, ImageMask("/volt/assets/payments/minus.webp")
|
|
984
|
-
.frame(20, 20)
|
|
985
|
-
.padding(5)
|
|
986
|
-
.margin_right(5)
|
|
987
|
-
.mask_color(style.fg_1)
|
|
988
|
-
.background(style.bg_1)
|
|
989
|
-
.border(1, style.divider_bg)
|
|
990
|
-
.border_radius("50%")
|
|
991
|
-
.flex_shrink(0)
|
|
992
|
-
.transition_mask("background 300ms ease-in-out")
|
|
993
|
-
.on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
|
|
994
|
-
.on_click(async () => {
|
|
995
|
-
if (item.quantity === 1) {
|
|
996
|
-
await Cart.remove(item.product.id, "all");
|
|
997
|
-
this.refresh();
|
|
998
|
-
}
|
|
999
|
-
else {
|
|
1000
|
-
await Cart.remove(item.product.id, 1);
|
|
1001
|
-
this.refresh();
|
|
1002
|
-
}
|
|
1003
|
-
}), ImageMask("/volt/assets/payments/plus.webp")
|
|
1004
|
-
.frame(20, 20)
|
|
1005
|
-
.padding(5)
|
|
1006
|
-
.margin_right(5)
|
|
1007
|
-
.mask_color(style.fg_1)
|
|
1008
|
-
.background(style.bg_1)
|
|
1009
|
-
.border(1, style.divider_bg)
|
|
1010
|
-
.border_radius("50%")
|
|
1011
|
-
.flex_shrink(0)
|
|
1012
|
-
.transition_mask("background 300ms ease-in-out")
|
|
1013
|
-
.on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
|
|
1014
|
-
.on_click(async () => {
|
|
1015
|
-
await Cart.add(item.product.id, 1);
|
|
1016
|
-
this.refresh();
|
|
1017
|
-
}), ImageMask("/volt/assets/payments/trash.webp")
|
|
1018
|
-
.frame(20, 20)
|
|
1019
|
-
.padding(5)
|
|
1020
|
-
.margin_right(5)
|
|
1021
|
-
.mask_color(style.fg_1)
|
|
1022
|
-
.background(style.bg_1)
|
|
1023
|
-
.border(1, style.divider_bg)
|
|
1024
|
-
.border_radius("50%")
|
|
1025
|
-
.flex_shrink(0)
|
|
1026
|
-
.transition_mask("background 300ms ease-in-out")
|
|
1027
|
-
.on_mouse_over_out((e) => e.mask_color(style.fg), (e) => e.mask_color(style.fg_1))
|
|
1028
|
-
.on_click(async () => {
|
|
1029
|
-
await Cart.remove(item.product.id, "all");
|
|
1030
|
-
this.refresh();
|
|
1031
|
-
}))
|
|
1032
|
-
.center_vertical()
|
|
1033
|
-
.wrap(true)
|
|
1034
|
-
.margin_top(17.5))
|
|
1035
|
-
.stretch(true), VStack(Title(trial_text ? trial_text : `${currency_symbol} ${(item.product.price * item.quantity).toFixed(2)}`)
|
|
1036
|
-
.color(style.fg)
|
|
1037
|
-
.font_size(style.font_size)
|
|
1038
|
-
.margin(0)
|
|
1039
|
-
.padding(0)
|
|
1040
|
-
.flex_shrink(0)
|
|
1041
|
-
.wrap(false)
|
|
1042
|
-
.overflow("hidden")
|
|
1043
|
-
.text_overflow("ellipsis"), Text(`${trial_text ? "Then " : ""}${currency_symbol} ${item.product.price} ${per_item}`)
|
|
1044
|
-
.color(style.fg_1)
|
|
1045
|
-
.font_size(style.font_size - 6)
|
|
1046
|
-
.margin(5, 0, 0, 0)
|
|
1047
|
-
.padding(0)
|
|
1048
|
-
.flex_shrink(0), renews_every == null ? null : Text(renews_every)
|
|
1049
|
-
.color(style.fg_1)
|
|
1050
|
-
.font_size(style.font_size - 6)
|
|
1051
|
-
.margin(2.5, 0, 0, 0)
|
|
1052
|
-
.padding(0)
|
|
1053
|
-
.flex_shrink(0)))
|
|
1054
|
-
.overflow_x("scroll")
|
|
1055
|
-
.class("volt_hide_scrollbar")
|
|
1056
|
-
.width("100%")
|
|
1057
|
-
.media("width >= 800px", (e) => {
|
|
1058
|
-
e.wrap(false);
|
|
1059
|
-
e.child(2).min_width("none")
|
|
1060
|
-
.margin(0);
|
|
1061
|
-
}, (e) => {
|
|
1062
|
-
e.wrap(true);
|
|
1063
|
-
e.child(2)
|
|
1064
|
-
.min_width("100%")
|
|
1065
|
-
.margin(15, 0, 0, 55);
|
|
1066
|
-
});
|
|
1067
|
-
return [
|
|
1068
|
-
stack,
|
|
1069
|
-
index === cart_items.length - 1 ? null : Divider()
|
|
1070
|
-
.background(style.divider_bg)
|
|
1071
|
-
.margin(20, 0, 20, 0)
|
|
1072
|
-
];
|
|
1073
|
-
}));
|
|
1074
|
-
}
|
|
1075
|
-
return this;
|
|
1076
|
-
}
|
|
1077
|
-
});
|
|
1078
|
-
// Append the order element to the order container.
|
|
1079
|
-
_order_container.append(_order_element.refresh());
|
|
1080
|
-
}
|
|
1081
|
-
// Render the refunds element.
|
|
1082
|
-
function _render_refunds_element() {
|
|
1083
|
-
// Render.
|
|
1084
|
-
const style = _style;
|
|
1085
|
-
_refunds_element = VStack()
|
|
1086
|
-
.extend({
|
|
1087
|
-
/**
|
|
1088
|
-
* Refresh the refunds element by fetching and displaying refundable, refunding, and refunded payments.
|
|
1089
|
-
*/
|
|
1090
|
-
async refresh() {
|
|
1091
|
-
// Reset.
|
|
1092
|
-
this.inner_html("");
|
|
1093
|
-
// Create containers.
|
|
1094
|
-
const refundable_res = await Payments.get_refundable_payments({
|
|
1095
|
-
days: _days_refundable,
|
|
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
|
-
}
|
|
1106
|
-
const refundable_container = VStack()
|
|
1107
|
-
.extend({
|
|
1108
|
-
title: "Refundable Payments",
|
|
1109
|
-
payments: refundable,
|
|
1110
|
-
is_refundable: true,
|
|
1111
|
-
});
|
|
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
|
-
}
|
|
1122
|
-
const refunding_container = VStack()
|
|
1123
|
-
.hide()
|
|
1124
|
-
.extend({
|
|
1125
|
-
title: "Processing Refunds",
|
|
1126
|
-
payments: refunding,
|
|
1127
|
-
is_refunding: true,
|
|
1128
|
-
});
|
|
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
|
-
}
|
|
1139
|
-
const refunded_container = VStack()
|
|
1140
|
-
.hide()
|
|
1141
|
-
.extend({
|
|
1142
|
-
title: "Refunded Payments",
|
|
1143
|
-
payments: refunded,
|
|
1144
|
-
is_refunded: true,
|
|
1145
|
-
});
|
|
1146
|
-
// Option bar.
|
|
1147
|
-
const option_bar = HStack(Text("Refundable")
|
|
1148
|
-
.font_size(style.font_size)
|
|
1149
|
-
.color(style.fg_1)
|
|
1150
|
-
.background(style.bg_1)
|
|
1151
|
-
.padding(8, 6)
|
|
1152
|
-
.margin(0)
|
|
1153
|
-
.stretch(true)
|
|
1154
|
-
.text_center()
|
|
1155
|
-
.transition("color 350ms ease, background 350ms ease")
|
|
1156
|
-
.on_mouse_over((e) => {
|
|
1157
|
-
if (e.background() === "transparent") {
|
|
1158
|
-
e.color(style.fg);
|
|
1159
|
-
}
|
|
1160
|
-
})
|
|
1161
|
-
.on_mouse_out((e) => {
|
|
1162
|
-
if (e.background() === "transparent") {
|
|
1163
|
-
e.color(style.fg_1);
|
|
1164
|
-
}
|
|
1165
|
-
})
|
|
1166
|
-
.on_click((e) => {
|
|
1167
|
-
e.color(_style.fg_1);
|
|
1168
|
-
e.background(_style.bg_1);
|
|
1169
|
-
[e.parentElement.child(1), e.parentElement.child(2)].forEach((child) => {
|
|
1170
|
-
child.color(_style.fg_1);
|
|
1171
|
-
child.background("none");
|
|
1172
|
-
});
|
|
1173
|
-
refundable_container.show();
|
|
1174
|
-
refunding_container.hide();
|
|
1175
|
-
refunded_container.hide();
|
|
1176
|
-
}), Text("Processing")
|
|
1177
|
-
.font_size(style.font_size)
|
|
1178
|
-
.color(style.fg_1)
|
|
1179
|
-
.background("transparent")
|
|
1180
|
-
.padding(8, 6)
|
|
1181
|
-
.margin(0)
|
|
1182
|
-
.stretch(true)
|
|
1183
|
-
.text_center()
|
|
1184
|
-
.transition("color 350ms ease, background 350ms ease")
|
|
1185
|
-
.on_mouse_over((e) => {
|
|
1186
|
-
if (e.background() === "transparent") {
|
|
1187
|
-
e.color(style.fg);
|
|
1188
|
-
}
|
|
1189
|
-
})
|
|
1190
|
-
.on_mouse_out((e) => {
|
|
1191
|
-
if (e.background() === "transparent") {
|
|
1192
|
-
e.color(style.fg_1);
|
|
1193
|
-
}
|
|
1194
|
-
})
|
|
1195
|
-
.on_click((e) => {
|
|
1196
|
-
e.color(_style.fg_1);
|
|
1197
|
-
e.background(_style.bg_1);
|
|
1198
|
-
[e.parentElement.child(0), e.parentElement.child(2)].forEach((child) => {
|
|
1199
|
-
child.color(_style.fg_1);
|
|
1200
|
-
child.background("none");
|
|
1201
|
-
});
|
|
1202
|
-
refundable_container.hide();
|
|
1203
|
-
refunding_container.show();
|
|
1204
|
-
refunded_container.hide();
|
|
1205
|
-
}), Text("Refunded")
|
|
1206
|
-
.font_size(style.font_size)
|
|
1207
|
-
.color(style.fg_1)
|
|
1208
|
-
.background("transparent")
|
|
1209
|
-
.padding(8, 6)
|
|
1210
|
-
.margin(0)
|
|
1211
|
-
.stretch(true)
|
|
1212
|
-
.text_center()
|
|
1213
|
-
.transition("color 350ms ease, background 350ms ease")
|
|
1214
|
-
.on_mouse_over((e) => {
|
|
1215
|
-
if (e.background() === "transparent") {
|
|
1216
|
-
e.color(style.fg);
|
|
1217
|
-
}
|
|
1218
|
-
})
|
|
1219
|
-
.on_mouse_out((e) => {
|
|
1220
|
-
if (e.background() === "transparent") {
|
|
1221
|
-
e.color(style.fg_1);
|
|
1222
|
-
}
|
|
1223
|
-
})
|
|
1224
|
-
.on_click((e) => {
|
|
1225
|
-
e.color(_style.fg_1);
|
|
1226
|
-
e.background(_style.bg_1);
|
|
1227
|
-
[e.parentElement.child(0), e.parentElement.child(1)].forEach((child) => {
|
|
1228
|
-
child.color(_style.fg_1);
|
|
1229
|
-
child.background("none");
|
|
1230
|
-
});
|
|
1231
|
-
refundable_container.hide();
|
|
1232
|
-
refunding_container.hide();
|
|
1233
|
-
refunded_container.show();
|
|
1234
|
-
}))
|
|
1235
|
-
.overflow("hidden")
|
|
1236
|
-
.border(1, style.divider_bg)
|
|
1237
|
-
.border_radius(style.border_radius)
|
|
1238
|
-
.margin_bottom(30)
|
|
1239
|
-
.flex_shrink(0);
|
|
1240
|
-
// Assign to parent.
|
|
1241
|
-
const refundable_option = option_bar.child(0);
|
|
1242
|
-
const refunding_option = option_bar.child(1);
|
|
1243
|
-
const refunded_option = option_bar.child(2);
|
|
1244
|
-
// Add elements.
|
|
1245
|
-
this.append(option_bar, refundable_container, refunding_container, refunded_container);
|
|
1246
|
-
// Separate payments.
|
|
1247
|
-
let currency_symbol = null;
|
|
1248
|
-
await Promise.all([refundable_container, refunding_container, refunded_container].map(async (container) => {
|
|
1249
|
-
if (container.payments.length === 0) {
|
|
1250
|
-
container.append(VStack(Title("No Payments")
|
|
1251
|
-
.color(style.fg)
|
|
1252
|
-
.font_size(style.font_size - 2)
|
|
1253
|
-
.flex_shrink(0)
|
|
1254
|
-
.letter_spacing("1px")
|
|
1255
|
-
.text_transform("uppercase")
|
|
1256
|
-
.ellipsis_overflow(true)
|
|
1257
|
-
.margin(0)
|
|
1258
|
-
.padding(0)
|
|
1259
|
-
.assign_to_parent_as("title_e"), Text(`There are no ${container.title.toLowerCase()}.`)
|
|
1260
|
-
.color(style.fg_1)
|
|
1261
|
-
.font_size(style.font_size - 2)
|
|
1262
|
-
.line_height(style.font_size)
|
|
1263
|
-
.margin(5, 0, 0, 0)
|
|
1264
|
-
.padding(0)
|
|
1265
|
-
.assign_to_parent_as("text_e")
|
|
1266
|
-
.white_space("pre")
|
|
1267
|
-
.line_height("1.4em")
|
|
1268
|
-
.center(), Image("/volt/assets/payments/check.webp")
|
|
1269
|
-
.frame(30, 30)
|
|
1270
|
-
.margin_top(15)
|
|
1271
|
-
.assign_to_parent_as("success_image_e"))
|
|
1272
|
-
.min_height(160)
|
|
1273
|
-
.frame("100%", "100%")
|
|
1274
|
-
.center()
|
|
1275
|
-
.center_vertical());
|
|
1276
|
-
}
|
|
1277
|
-
else {
|
|
1278
|
-
await Promise.all(container.payments.map(async (payment) => {
|
|
1279
|
-
await Promise.all(payment.line_items.map(async (item) => {
|
|
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;
|
|
1285
|
-
}));
|
|
1286
|
-
}));
|
|
1287
|
-
container.append(Title(container.title)
|
|
1288
|
-
.color(style.fg)
|
|
1289
|
-
.width("fit-content")
|
|
1290
|
-
.font_size(style.font_size - 2)
|
|
1291
|
-
.flex_shrink(0)
|
|
1292
|
-
.margin(0, 0, 0, 0)
|
|
1293
|
-
.letter_spacing("1px")
|
|
1294
|
-
.text_transform("uppercase")
|
|
1295
|
-
.ellipsis_overflow(true), Divider()
|
|
1296
|
-
.background(style.divider_bg)
|
|
1297
|
-
.margin(10, 0, 20, 0), ForEach(container.payments, (payment, index) => {
|
|
1298
|
-
// Line items.
|
|
1299
|
-
const items = VStack(ForEach(payment.line_items, (item, index) => {
|
|
1300
|
-
if (currency_symbol == null) {
|
|
1301
|
-
currency_symbol = Payments.get_currency_symbol(item.product.currency);
|
|
1302
|
-
}
|
|
1303
|
-
return [
|
|
1304
|
-
HStack(item.product.icon == null ? null :
|
|
1305
|
-
Image(item.product.icon)
|
|
1306
|
-
.frame(25, 25)
|
|
1307
|
-
.flex_shrink(0)
|
|
1308
|
-
.margin(0, 20, 0, 0), VStack(Title(item.product.name)
|
|
1309
|
-
.color(style.fg)
|
|
1310
|
-
.font_size(style.font_size - 2)
|
|
1311
|
-
.line_height(style.font_size)
|
|
1312
|
-
.margin(0, 10, 0, 0)
|
|
1313
|
-
.padding(0)
|
|
1314
|
-
.font_weight("bold")
|
|
1315
|
-
.ellipsis_overflow(true), Text(item.product.description)
|
|
1316
|
-
.color(style.fg_1)
|
|
1317
|
-
.font_size(style.font_size - 4)
|
|
1318
|
-
.line_height(style.font_size - 2)
|
|
1319
|
-
.margin(5, 0, 0, 0)
|
|
1320
|
-
.wrap(true)
|
|
1321
|
-
.padding(0))
|
|
1322
|
-
.stretch(true), VStack(Text(`${currency_symbol} ${(item.total).toFixed(2)}`)
|
|
1323
|
-
.color(style.fg_1)
|
|
1324
|
-
.font_size(style.font_size - 4)
|
|
1325
|
-
.line_height(style.font_size - 2)
|
|
1326
|
-
.margin(0)
|
|
1327
|
-
.padding(0)
|
|
1328
|
-
.flex_shrink(0)
|
|
1329
|
-
.ellipsis_overflow(true))),
|
|
1330
|
-
index === payment.line_items.length - 1 ? null : Divider()
|
|
1331
|
-
.background(style.divider_bg)
|
|
1332
|
-
.margin(15, 0, 15, 0),
|
|
1333
|
-
];
|
|
1334
|
-
}))
|
|
1335
|
-
.background(style.bg_1)
|
|
1336
|
-
.border_radius(style.border_radius)
|
|
1337
|
-
.border(1, style.divider_bg)
|
|
1338
|
-
.padding(20);
|
|
1339
|
-
// Payment.
|
|
1340
|
-
const stack = VStack(HStack(Title("Payment")
|
|
1341
|
-
.color(style.fg)
|
|
1342
|
-
.font_size(style.font_size)
|
|
1343
|
-
.margin(0, 10, 0, 0)
|
|
1344
|
-
.padding(0)
|
|
1345
|
-
.wrap(false)
|
|
1346
|
-
.overflow("hidden")
|
|
1347
|
-
.text_overflow("ellipsis")
|
|
1348
|
-
.stretch(true), !container.is_refundable ? null : BorderButton("Refund")
|
|
1349
|
-
.font_size(style.font_size - 4)
|
|
1350
|
-
.padding(7.5, 10)
|
|
1351
|
-
.margin(0, 5, 0, 0)
|
|
1352
|
-
.color(style.button.bg)
|
|
1353
|
-
.border_radius(style.button.border_radius)
|
|
1354
|
-
.border_color(style.button.bg)
|
|
1355
|
-
.hover_brightness(...style.button.hover_brightness)
|
|
1356
|
-
.font_weight("bold")
|
|
1357
|
-
.on_click(() => {
|
|
1358
|
-
document.body.appendChild(YesNoPopup({
|
|
1359
|
-
title: "Request Refund",
|
|
1360
|
-
text: `You are about to request a refund for payment <span style='border-radius: 7px; background: ${style.bg_1}; padding: 1px 4px; font-size: 0.9em;'>${payment.id}</span>, do you wish to proceed?`,
|
|
1361
|
-
no: "No",
|
|
1362
|
-
yes: "Yes",
|
|
1363
|
-
image: "/volt/assets/payments/error.webp",
|
|
1364
|
-
blur: 5,
|
|
1365
|
-
animation_duration: 300,
|
|
1366
|
-
on_yes: async () => {
|
|
1367
|
-
try {
|
|
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
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
catch (err) {
|
|
1377
|
-
console.error(err);
|
|
1378
|
-
Payments.on_error(err);
|
|
1379
|
-
return;
|
|
1380
|
-
}
|
|
1381
|
-
this.refresh().then(() => {
|
|
1382
|
-
refunding_option.click();
|
|
1383
|
-
});
|
|
1384
|
-
},
|
|
1385
|
-
})
|
|
1386
|
-
.font(window.getComputedStyle(_refunds_container).font)
|
|
1387
|
-
.widget
|
|
1388
|
-
.background(style.bg)
|
|
1389
|
-
.color(style.fg_1)
|
|
1390
|
-
.border_bottom("4px solid #E8454E")
|
|
1391
|
-
// .leading()
|
|
1392
|
-
.parent()
|
|
1393
|
-
.title
|
|
1394
|
-
.color(style.fg)
|
|
1395
|
-
// .width("fit-content")
|
|
1396
|
-
.font_size(style.font_size + 2)
|
|
1397
|
-
.flex_shrink(0)
|
|
1398
|
-
.margin(0, 0, 0, 10)
|
|
1399
|
-
// .letter_spacing("1px")
|
|
1400
|
-
// .text_transform("uppercase")
|
|
1401
|
-
// .ellipsis_overflow(true)
|
|
1402
|
-
// .color(style.fg_1)
|
|
1403
|
-
.center()
|
|
1404
|
-
.parent()
|
|
1405
|
-
.text
|
|
1406
|
-
.color(style.fg_1)
|
|
1407
|
-
.font_size(style.font_size)
|
|
1408
|
-
.margin_left(10)
|
|
1409
|
-
.center()
|
|
1410
|
-
.parent()
|
|
1411
|
-
.image
|
|
1412
|
-
.padding(10)
|
|
1413
|
-
.mask_color(style.bg)
|
|
1414
|
-
.border_radius("50%")
|
|
1415
|
-
.background("#E8454E")
|
|
1416
|
-
.frame(40, 40)
|
|
1417
|
-
.box_shadow('0 0 0 4px #E8454E50')
|
|
1418
|
-
.parent()
|
|
1419
|
-
.no_button
|
|
1420
|
-
.padding(10, 0)
|
|
1421
|
-
.font_size(style.font_size)
|
|
1422
|
-
.background(style.bg_1)
|
|
1423
|
-
.color(style.fg_1)
|
|
1424
|
-
.border(1, style.divider_bg)
|
|
1425
|
-
.hover_brightness(...style.button.hover_brightness)
|
|
1426
|
-
.box_shadow('0px 0px 5px #00000030')
|
|
1427
|
-
.parent()
|
|
1428
|
-
.yes_button
|
|
1429
|
-
.padding(10, 0)
|
|
1430
|
-
.font_size(style.font_size)
|
|
1431
|
-
.background("#E8454E")
|
|
1432
|
-
.color(style.fg_1)
|
|
1433
|
-
.border(1, style.divider_bg)
|
|
1434
|
-
.hover_brightness(...style.button.hover_brightness)
|
|
1435
|
-
.box_shadow('0px 0px 5px #00000030')
|
|
1436
|
-
.parent());
|
|
1437
|
-
}), !container.is_refunding ? null : RingLoader()
|
|
1438
|
-
.frame(20, 20)
|
|
1439
|
-
.background(style.theme_fg)
|
|
1440
|
-
.margin(0, 5, 0, 0)
|
|
1441
|
-
.update(), !container.is_refunded ? null : Image("/volt/assets/payments/check.webp")
|
|
1442
|
-
.frame(20, 20)
|
|
1443
|
-
.margin(0, 5, 0, 0))
|
|
1444
|
-
.min_height(30), Text().append(`Purchased at ${Utils.unix_to_date(payment.timestamp / 1000)} `, Span(payment.id).font_size("0.8em"))
|
|
1445
|
-
.color(style.fg_1)
|
|
1446
|
-
.font_size(style.font_size - 6)
|
|
1447
|
-
.line_height(style.font_size - 4)
|
|
1448
|
-
.margin(-5, 0, 10, 0)
|
|
1449
|
-
.wrap(true)
|
|
1450
|
-
.padding(0)
|
|
1451
|
-
.white_space("pre")
|
|
1452
|
-
.line_height("1.4em")
|
|
1453
|
-
.center(), items)
|
|
1454
|
-
.width("100%");
|
|
1455
|
-
// Elements.
|
|
1456
|
-
return [
|
|
1457
|
-
stack,
|
|
1458
|
-
index === container.payments.length - 1 ? null : Divider()
|
|
1459
|
-
.background(style.divider_bg)
|
|
1460
|
-
.margin(20, 0, 20, 0),
|
|
1461
|
-
];
|
|
1462
|
-
}));
|
|
1463
|
-
}
|
|
1464
|
-
}));
|
|
1465
|
-
return this;
|
|
1466
|
-
}
|
|
1467
|
-
});
|
|
1468
|
-
// Append.
|
|
1469
|
-
_refunds_element.refresh();
|
|
1470
|
-
_refunds_container.append(_refunds_element);
|
|
1471
|
-
}
|
|
1472
|
-
// Render the address element.
|
|
1473
|
-
function _render_billing_element() {
|
|
1474
|
-
if (_billing_element !== undefined) {
|
|
1475
|
-
return;
|
|
1476
|
-
}
|
|
1477
|
-
// Utils.
|
|
1478
|
-
const CreateInput = (args) => {
|
|
1479
|
-
return ExtendedInput(args)
|
|
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)
|
|
1486
|
-
.input
|
|
1487
|
-
.color(_style.fg_1)
|
|
1488
|
-
.parent();
|
|
1489
|
-
};
|
|
1490
|
-
const CreateSelect = (args) => {
|
|
1491
|
-
return ExtendedSelect(args)
|
|
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)
|
|
1499
|
-
.dropdown_height(150)
|
|
1500
|
-
.background("transparent")
|
|
1501
|
-
.dropdown
|
|
1502
|
-
.background(_style.bg_1)
|
|
1503
|
-
.background_blur(20)
|
|
1504
|
-
.parent()
|
|
1505
|
-
.input
|
|
1506
|
-
.white_space("pre")
|
|
1507
|
-
// .border_radius(0)
|
|
1508
|
-
.color(_style.fg_1)
|
|
1509
|
-
.parent();
|
|
1510
|
-
};
|
|
1511
|
-
// Create element.
|
|
1512
|
-
const input_spacing = 15;
|
|
1513
|
-
let country_code;
|
|
1514
|
-
_billing_element = Form(Title("Billing Details")
|
|
1515
|
-
.color(_style.fg)
|
|
1516
|
-
.width("fit-content")
|
|
1517
|
-
.font_size(_style.font_size - 2)
|
|
1518
|
-
.flex_shrink(0)
|
|
1519
|
-
.margin(0, 0, 0, 0)
|
|
1520
|
-
.letter_spacing("1px")
|
|
1521
|
-
.text_transform("uppercase")
|
|
1522
|
-
.ellipsis_overflow(true), Divider()
|
|
1523
|
-
.background(_style.divider_bg)
|
|
1524
|
-
.margin(10, 0, 10, 0), HStack(Text("Personal")
|
|
1525
|
-
.font_size(_style.font_size)
|
|
1526
|
-
.color(_style.fg)
|
|
1527
|
-
.background(_style.bg_1)
|
|
1528
|
-
.padding(8, 6)
|
|
1529
|
-
.margin(0)
|
|
1530
|
-
.stretch(true)
|
|
1531
|
-
.text_center()
|
|
1532
|
-
.transition("color 350ms ease, background 350ms ease")
|
|
1533
|
-
.on_mouse_over((e) => {
|
|
1534
|
-
if (e.background() === "transparent") {
|
|
1535
|
-
e.color(_style.fg);
|
|
1536
|
-
}
|
|
1537
|
-
})
|
|
1538
|
-
.on_mouse_out((e) => {
|
|
1539
|
-
if (e.background() === "transparent") {
|
|
1540
|
-
e.color(_style.fg_1);
|
|
1541
|
-
}
|
|
1542
|
-
})
|
|
1543
|
-
.on_click((e) => {
|
|
1544
|
-
e.color(_style.fg_1);
|
|
1545
|
-
e.background(_style.bg_1);
|
|
1546
|
-
const other = e.parentElement.child(1);
|
|
1547
|
-
other.color(_style.fg_1);
|
|
1548
|
-
other.background("none");
|
|
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);
|
|
1555
|
-
}), Text("Business")
|
|
1556
|
-
.font_size(_style.font_size)
|
|
1557
|
-
.color(_style.fg_1)
|
|
1558
|
-
.background("transparent")
|
|
1559
|
-
.padding(8, 6)
|
|
1560
|
-
.margin(0)
|
|
1561
|
-
.stretch(true)
|
|
1562
|
-
.text_center()
|
|
1563
|
-
.transition("color 350ms ease, background 350ms ease")
|
|
1564
|
-
.on_mouse_over((e) => {
|
|
1565
|
-
if (e.background() === "transparent") {
|
|
1566
|
-
e.color(_style.fg);
|
|
1567
|
-
}
|
|
1568
|
-
})
|
|
1569
|
-
.on_mouse_out((e) => {
|
|
1570
|
-
if (e.background() === "transparent") {
|
|
1571
|
-
e.color(_style.fg_1);
|
|
1572
|
-
}
|
|
1573
|
-
})
|
|
1574
|
-
.on_click((e) => {
|
|
1575
|
-
e.color(_style.fg_1);
|
|
1576
|
-
e.background(_style.bg_1);
|
|
1577
|
-
const other = e.parentElement.child(0);
|
|
1578
|
-
other.color(_style.fg_1);
|
|
1579
|
-
other.background("transparent");
|
|
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);
|
|
1586
|
-
}))
|
|
1587
|
-
.overflow("hidden")
|
|
1588
|
-
.border(1, _style.divider_bg)
|
|
1589
|
-
.border_radius(_style.border_radius)
|
|
1590
|
-
.margin_top(10)
|
|
1591
|
-
.margin_bottom(10)
|
|
1592
|
-
.flex_shrink(0), CreateInput({
|
|
1593
|
-
label: "Full Name",
|
|
1594
|
-
placeholder: "John Doe",
|
|
1595
|
-
})
|
|
1596
|
-
.value(User.first_name() === undefined ? "" : (User.first_name() + " " + User.last_name()))
|
|
1597
|
-
.margin_top(input_spacing)
|
|
1598
|
-
.required(true)
|
|
1599
|
-
.id("name")
|
|
1600
|
-
.assign_to_parent_as("name_input"), CreateInput({
|
|
1601
|
-
label: "Business Name",
|
|
1602
|
-
placeholder: "Company Inc.",
|
|
1603
|
-
})
|
|
1604
|
-
.margin_top(input_spacing)
|
|
1605
|
-
.required(false)
|
|
1606
|
-
.id("business")
|
|
1607
|
-
.hide()
|
|
1608
|
-
.assign_to_parent_as("business_input"), CreateInput({
|
|
1609
|
-
label: "VAT ID",
|
|
1610
|
-
placeholder: "VAT ID",
|
|
1611
|
-
})
|
|
1612
|
-
.margin_top(input_spacing)
|
|
1613
|
-
.required(false)
|
|
1614
|
-
.id("vat_id")
|
|
1615
|
-
.hide()
|
|
1616
|
-
.assign_to_parent_as("vat_id_input"), CreateInput({
|
|
1617
|
-
label: "Email",
|
|
1618
|
-
placeholder: "my@email.com",
|
|
1619
|
-
})
|
|
1620
|
-
.value(User.email() ?? "")
|
|
1621
|
-
.margin_top(input_spacing)
|
|
1622
|
-
.required(true)
|
|
1623
|
-
.id("email"), CreateInput({
|
|
1624
|
-
label: "Street",
|
|
1625
|
-
placeholder: "123 Park Avenue",
|
|
1626
|
-
})
|
|
1627
|
-
.margin_top(input_spacing)
|
|
1628
|
-
.required(true)
|
|
1629
|
-
.id("street"), CreateInput({
|
|
1630
|
-
label: "House Number",
|
|
1631
|
-
placeholder: "Suite 405",
|
|
1632
|
-
})
|
|
1633
|
-
.margin_top(input_spacing)
|
|
1634
|
-
.required(true)
|
|
1635
|
-
.id("house_number"), CreateInput({
|
|
1636
|
-
label: "Postal Code",
|
|
1637
|
-
placeholder: "10001",
|
|
1638
|
-
})
|
|
1639
|
-
.margin_top(input_spacing)
|
|
1640
|
-
.required(true)
|
|
1641
|
-
.id("postal_code"), CreateInput({
|
|
1642
|
-
label: "City",
|
|
1643
|
-
placeholder: "New York",
|
|
1644
|
-
})
|
|
1645
|
-
.margin_top(input_spacing)
|
|
1646
|
-
.required(true)
|
|
1647
|
-
.id("city"), CreateInput({
|
|
1648
|
-
label: "Province",
|
|
1649
|
-
placeholder: "New York",
|
|
1650
|
-
})
|
|
1651
|
-
.margin_top(input_spacing)
|
|
1652
|
-
.required(true)
|
|
1653
|
-
.id("province"), CreateSelect({
|
|
1654
|
-
label: "Country",
|
|
1655
|
-
placeholder: "United States",
|
|
1656
|
-
items: Object.fromEntries(Object.entries(Payments.countries).map(([key, value]) => [key, value.name])),
|
|
1657
|
-
})
|
|
1658
|
-
.on_change((_, country) => {
|
|
1659
|
-
_overview_element.calc_tax(country);
|
|
1660
|
-
country_code.value(Payments.countries[country].calling_code);
|
|
1661
|
-
})
|
|
1662
|
-
.margin_top(input_spacing)
|
|
1663
|
-
.required(true)
|
|
1664
|
-
.id("country"), HStack(country_code = CreateInput({
|
|
1665
|
-
label: "Country Code",
|
|
1666
|
-
placeholder: "+1",
|
|
1667
|
-
type: "tel",
|
|
1668
|
-
})
|
|
1669
|
-
.max_width("fit-content")
|
|
1670
|
-
.margin_top(input_spacing)
|
|
1671
|
-
.margin_right(input_spacing)
|
|
1672
|
-
.required(true)
|
|
1673
|
-
.input
|
|
1674
|
-
.readonly(true)
|
|
1675
|
-
.parent()
|
|
1676
|
-
.id("phone_country_code"), CreateInput({
|
|
1677
|
-
label: "Phone Number",
|
|
1678
|
-
placeholder: "1234567890",
|
|
1679
|
-
type: "tel",
|
|
1680
|
-
})
|
|
1681
|
-
.margin_top(input_spacing)
|
|
1682
|
-
.stretch(true)
|
|
1683
|
-
.required(true)
|
|
1684
|
-
.id("phone_number"))
|
|
1685
|
-
.width("100%"));
|
|
1686
|
-
// Append.
|
|
1687
|
-
_billing_container.append(_billing_element);
|
|
1688
|
-
}
|
|
1689
|
-
// Render the payment element.
|
|
1690
|
-
async function _render_payment_element() {
|
|
1691
|
-
return new Promise((resolve, reject) => {
|
|
1692
|
-
_render_payment_element_resolve = resolve;
|
|
1693
|
-
_render_payment_element_reject = reject;
|
|
1694
|
-
// Already rendered.
|
|
1695
|
-
if (_payment_element !== undefined) {
|
|
1696
|
-
return resolve();
|
|
1697
|
-
}
|
|
1698
|
-
// Checks.
|
|
1699
|
-
if (client_key == null) {
|
|
1700
|
-
return reject(new Error(`No client key has been assigned to "Payments.client_key".`));
|
|
1701
|
-
}
|
|
1702
|
-
if (Cart.items.length === 0) {
|
|
1703
|
-
return reject(new Error("Shopping cart is empty."));
|
|
1704
|
-
}
|
|
1705
|
-
// Check subscription or one time payment.
|
|
1706
|
-
let is_subscription = false;
|
|
1707
|
-
Cart.items.forEach((item) => {
|
|
1708
|
-
if (item.is_subscription === true) {
|
|
1709
|
-
is_subscription = true;
|
|
1710
|
-
return false;
|
|
1711
|
-
}
|
|
1712
|
-
});
|
|
1713
|
-
// Initialize paddle.
|
|
1714
|
-
_initialize_paddle();
|
|
1715
|
-
// Create element.
|
|
1716
|
-
_payment_element = VStack()
|
|
1717
|
-
.class("checkout-container");
|
|
1718
|
-
// Append.
|
|
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
|
-
}
|
|
1725
|
-
// Initialize.
|
|
1726
|
-
let custom_data = {
|
|
1727
|
-
customer_name: _billing_details.name,
|
|
1728
|
-
};
|
|
1729
|
-
if (User.is_authenticated()) {
|
|
1730
|
-
custom_data.uid = User.uid();
|
|
1731
|
-
}
|
|
1732
|
-
try {
|
|
1733
|
-
let business = undefined;
|
|
1734
|
-
if (_billing_details.business !== "") {
|
|
1735
|
-
business = {
|
|
1736
|
-
name: _billing_details.business,
|
|
1737
|
-
taxIdentifier: _billing_details.vat_id === "" ? undefined : _billing_details.vat_id,
|
|
1738
|
-
};
|
|
1739
|
-
}
|
|
1740
|
-
Paddle.Checkout.open({
|
|
1741
|
-
settings: {
|
|
1742
|
-
displayMode: "inline",
|
|
1743
|
-
theme: _theme,
|
|
1744
|
-
locale: "en",
|
|
1745
|
-
frameTarget: "checkout-container",
|
|
1746
|
-
frameInitialHeight: "450",
|
|
1747
|
-
frameStyle: "width: 100%; min-width: 312px; background-color: transparent; border: none;",
|
|
1748
|
-
// successUrl: this.return_url,
|
|
1749
|
-
// successUrl: "http://test.vandenberghinc.com/checkout?payment_status=success",
|
|
1750
|
-
},
|
|
1751
|
-
items: Cart.items.map((item) => { return { priceId: item.product.price_id, quantity: item.quantity }; }),
|
|
1752
|
-
customer: {
|
|
1753
|
-
email: _billing_details.email,
|
|
1754
|
-
address: {
|
|
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}`,
|
|
1760
|
-
},
|
|
1761
|
-
business,
|
|
1762
|
-
},
|
|
1763
|
-
customData: custom_data,
|
|
1764
|
-
});
|
|
1765
|
-
}
|
|
1766
|
-
catch (err) {
|
|
1767
|
-
return reject(err);
|
|
1768
|
-
}
|
|
1769
|
-
// const iframe = _payment_element.children[0];
|
|
1770
|
-
// iframe.onload = () => {
|
|
1771
|
-
// console.log("ON LOAD");
|
|
1772
|
-
// let doc = iframe.contentDocument || iframe.contentWindow.document;
|
|
1773
|
-
// let elementInsideIframe = doc.getElementById('cardNumber');
|
|
1774
|
-
// elementInsideIframe.style.background = 'red'; // Example of editing an element
|
|
1775
|
-
// }
|
|
1776
|
-
});
|
|
1777
|
-
}
|
|
1778
|
-
// Render the processing element.
|
|
1779
|
-
function _render_processing_element() {
|
|
1780
|
-
// Already defined.
|
|
1781
|
-
if (_processing_element !== undefined) {
|
|
1782
|
-
_processing_element.set_processing();
|
|
1783
|
-
return;
|
|
1784
|
-
}
|
|
1785
|
-
// Create element.
|
|
1786
|
-
_processing_element = VStack(Title("Processing")
|
|
1787
|
-
.color(_style.fg)
|
|
1788
|
-
.font_size(_style.font_size - 2)
|
|
1789
|
-
.flex_shrink(0)
|
|
1790
|
-
.letter_spacing("1px")
|
|
1791
|
-
.text_transform("uppercase")
|
|
1792
|
-
.ellipsis_overflow(true)
|
|
1793
|
-
.margin(0)
|
|
1794
|
-
.padding(0)
|
|
1795
|
-
.assign_to_parent_as("title_e"), Text("Processing your payment, please wait.")
|
|
1796
|
-
.color(_style.fg_1)
|
|
1797
|
-
.font_size(_style.font_size - 2)
|
|
1798
|
-
.line_height(_style.font_size)
|
|
1799
|
-
.margin(5, 0, 0, 0)
|
|
1800
|
-
.padding(0)
|
|
1801
|
-
.assign_to_parent_as("text_e")
|
|
1802
|
-
.white_space("pre")
|
|
1803
|
-
.line_height("1.4em")
|
|
1804
|
-
.center(), ImageMask("/volt/assets/payments/error.webp")
|
|
1805
|
-
.hide()
|
|
1806
|
-
.frame(40, 40)
|
|
1807
|
-
.padding(5)
|
|
1808
|
-
.mask_color(_style.missing_fg)
|
|
1809
|
-
.margin_top(15)
|
|
1810
|
-
.assign_to_parent_as("error_image_e"), Image("/volt/assets/payments/party.webp")
|
|
1811
|
-
.hide()
|
|
1812
|
-
.frame(40, 40)
|
|
1813
|
-
.margin_top(15)
|
|
1814
|
-
.assign_to_parent_as("success_image_e"), RingLoader()
|
|
1815
|
-
.background(_style.theme_fg)
|
|
1816
|
-
.frame(40, 40)
|
|
1817
|
-
.update()
|
|
1818
|
-
.margin_top(15)
|
|
1819
|
-
.assign_to_parent_as("loader_e"))
|
|
1820
|
-
.padding(15, 0)
|
|
1821
|
-
.center()
|
|
1822
|
-
.center_vertical()
|
|
1823
|
-
.extend({
|
|
1824
|
-
timestamp: Date.now(),
|
|
1825
|
-
/**
|
|
1826
|
-
* Set the processing element to display an error message.
|
|
1827
|
-
* @param message - The error message to display.
|
|
1828
|
-
*/
|
|
1829
|
-
set_error(message = "The payment has failed, please check your information and try again.\n If the problem persists, contact support for assistance.") {
|
|
1830
|
-
this.loader_e.hide();
|
|
1831
|
-
this.error_image_e.src("/volt/assets/payments/error.webp");
|
|
1832
|
-
this.error_image_e.show();
|
|
1833
|
-
this.success_image_e.hide();
|
|
1834
|
-
this.title_e.text("Error");
|
|
1835
|
-
this.text_e.text(message);
|
|
1836
|
-
},
|
|
1837
|
-
/**
|
|
1838
|
-
* Set the processing element to display a cancelled message.
|
|
1839
|
-
* @param message - The cancellation message to display.
|
|
1840
|
-
*/
|
|
1841
|
-
set_cancelled(message = "The payment has been cancelled.") {
|
|
1842
|
-
this.loader_e.hide();
|
|
1843
|
-
this.error_image_e.src("/volt/assets/payments/cancelled.webp");
|
|
1844
|
-
this.error_image_e.show();
|
|
1845
|
-
this.success_image_e.hide();
|
|
1846
|
-
this.title_e.text("Cancelled");
|
|
1847
|
-
this.text_e.text(message);
|
|
1848
|
-
},
|
|
1849
|
-
/**
|
|
1850
|
-
* Set the processing element to display a success message.
|
|
1851
|
-
* @param message - The success message to display.
|
|
1852
|
-
*/
|
|
1853
|
-
set_success(message = "The payment has succeeded and is currently processing.\n Thank you for your purchase!") {
|
|
1854
|
-
this.loader_e.hide();
|
|
1855
|
-
this.error_image_e.hide();
|
|
1856
|
-
this.success_image_e.show();
|
|
1857
|
-
this.title_e.text("Success");
|
|
1858
|
-
this.text_e.text(message);
|
|
1859
|
-
},
|
|
1860
|
-
/**
|
|
1861
|
-
* Set the processing element to display a processing message.
|
|
1862
|
-
* @param message - The processing message to display.
|
|
1863
|
-
*/
|
|
1864
|
-
set_processing(message = "Processing your payment, please wait.") {
|
|
1865
|
-
this.loader_e.show();
|
|
1866
|
-
this.error_image_e.hide();
|
|
1867
|
-
this.success_image_e.hide();
|
|
1868
|
-
this.title_e.text("Processing");
|
|
1869
|
-
this.text_e.text(message);
|
|
1870
|
-
},
|
|
1871
|
-
});
|
|
1872
|
-
// Append.
|
|
1873
|
-
_processing_container.append(_processing_element);
|
|
1874
|
-
}
|
|
1875
|
-
// Show the processing container.
|
|
1876
|
-
async function _show_processing(status = null) {
|
|
1877
|
-
// Select step.
|
|
1878
|
-
_payment_step = 3;
|
|
1879
|
-
_steps_element.select(_payment_step);
|
|
1880
|
-
// Render the processing element.
|
|
1881
|
-
_render_processing_element();
|
|
1882
|
-
// Set elements.
|
|
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();
|
|
1889
|
-
// Update.
|
|
1890
|
-
if (status != null) {
|
|
1891
|
-
_update_processing(status);
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
// Update the processing container.
|
|
1895
|
-
async function _update_processing(status) {
|
|
1896
|
-
// Handle result code.
|
|
1897
|
-
switch (status) {
|
|
1898
|
-
case "success":
|
|
1899
|
-
_processing_element.set_success();
|
|
1900
|
-
break;
|
|
1901
|
-
case "processing":
|
|
1902
|
-
_processing_element.set_processing();
|
|
1903
|
-
break;
|
|
1904
|
-
case "cancelled":
|
|
1905
|
-
_processing_element.set_cancelled();
|
|
1906
|
-
break;
|
|
1907
|
-
case "error":
|
|
1908
|
-
_processing_element.set_error();
|
|
1909
|
-
break;
|
|
1910
|
-
default:
|
|
1911
|
-
console.error(`Unknown session result code "${status}".`);
|
|
1912
|
-
_processing_element.set_error("An unknown error has occurred.");
|
|
1913
|
-
break;
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
// Initialize checkout page.
|
|
1917
|
-
function style({ theme = "light", // light or dark
|
|
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 = {
|
|
1919
|
-
fg: null,
|
|
1920
|
-
bg: null,
|
|
1921
|
-
}, button = {
|
|
1922
|
-
fg: null,
|
|
1923
|
-
bg: null,
|
|
1924
|
-
border_color: null,
|
|
1925
|
-
border_radius: 25,
|
|
1926
|
-
border_width: 1,
|
|
1927
|
-
border_inset: false,
|
|
1928
|
-
hover_brightness: [1.1, 1.2],
|
|
1929
|
-
}, } = {}) {
|
|
1930
|
-
// Set selected defaults.
|
|
1931
|
-
if (selected == null) {
|
|
1932
|
-
selected = { fg: null, bg: null };
|
|
1933
|
-
}
|
|
1934
|
-
selected.fg ??= fg;
|
|
1935
|
-
selected.bg ??= theme_fg;
|
|
1936
|
-
// Set button defaults.
|
|
1937
|
-
if (button == null) {
|
|
1938
|
-
button = {
|
|
1939
|
-
fg: null,
|
|
1940
|
-
bg: null,
|
|
1941
|
-
border_radius: null,
|
|
1942
|
-
border_color: null,
|
|
1943
|
-
border_width: 1,
|
|
1944
|
-
hover_brightness: [1, 1],
|
|
1945
|
-
border_inset: false,
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
button.fg ??= fg;
|
|
1949
|
-
button.bg ??= bg_1; // Corrected bg_2 to bg_1 as bg_2 is not defined
|
|
1950
|
-
button.border_radius ??= 25;
|
|
1951
|
-
button.border_color ??= fg;
|
|
1952
|
-
button.border_width ??= 1;
|
|
1953
|
-
button.border_inset ??= false;
|
|
1954
|
-
button.hover_brightness ??= [1.1, 1.2];
|
|
1955
|
-
if (typeof button.border_width === "number") {
|
|
1956
|
-
button.border_width = `${button.border_width}px`;
|
|
1957
|
-
}
|
|
1958
|
-
// Save style.
|
|
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;
|
|
1973
|
-
// Set CSS variables.
|
|
1974
|
-
Object.keys(_style).forEach((key) => {
|
|
1975
|
-
if (typeof _style[key] === "number") {
|
|
1976
|
-
document.documentElement.style.setProperty(`--vpayments_${key}`, `${_style[key]}px`);
|
|
1977
|
-
}
|
|
1978
|
-
else {
|
|
1979
|
-
document.documentElement.style.setProperty(`--vpayments_${key}`, _style[key]);
|
|
1980
|
-
}
|
|
1981
|
-
});
|
|
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;
|
|
1986
|
-
// Initialize checkout page.
|
|
1987
|
-
function create_checkout_dropin({ steps_container, order_container, billing_container, payment_container, processing_container, overview_container, sign_in_redirect = null, on_error = (error) => { }, }) {
|
|
1988
|
-
// Check args.
|
|
1989
|
-
if (!(steps_container instanceof Node)) {
|
|
1990
|
-
throw new Error('The "steps_container" must be assigned with a container node.');
|
|
1991
|
-
}
|
|
1992
|
-
if (!(order_container instanceof Node)) {
|
|
1993
|
-
throw new Error('The "order_container" must be assigned with a container node.');
|
|
1994
|
-
}
|
|
1995
|
-
if (!(billing_container instanceof Node)) {
|
|
1996
|
-
throw new Error('The "billing_container" must be assigned with a container node.');
|
|
1997
|
-
}
|
|
1998
|
-
if (!(payment_container instanceof Node)) {
|
|
1999
|
-
throw new Error('The "payment_container" must be assigned with a container node.');
|
|
2000
|
-
}
|
|
2001
|
-
if (!(processing_container instanceof Node)) {
|
|
2002
|
-
throw new Error('The "processing_container" must be assigned with a container node.');
|
|
2003
|
-
}
|
|
2004
|
-
if (!(overview_container instanceof Node)) {
|
|
2005
|
-
throw new Error('The "overview_container" must be assigned with a container node.');
|
|
2006
|
-
}
|
|
2007
|
-
// Args.
|
|
2008
|
-
_steps_container = steps_container;
|
|
2009
|
-
_order_container = order_container;
|
|
2010
|
-
// @ts-ignore
|
|
2011
|
-
_billing_container = billing_container.hide();
|
|
2012
|
-
// @ts-ignore
|
|
2013
|
-
_payment_container = payment_container.hide();
|
|
2014
|
-
// @ts-ignore
|
|
2015
|
-
_processing_container = processing_container.hide();
|
|
2016
|
-
_overview_container = overview_container;
|
|
2017
|
-
// Settings.
|
|
2018
|
-
_sign_in_redirect = sign_in_redirect;
|
|
2019
|
-
// Events.
|
|
2020
|
-
Payments.on_error = on_error;
|
|
2021
|
-
// Check style.
|
|
2022
|
-
if (_style === undefined) {
|
|
2023
|
-
Payments.style();
|
|
2024
|
-
}
|
|
2025
|
-
// Other attributes.
|
|
2026
|
-
_payment_step = 0;
|
|
2027
|
-
// Render the steps element.
|
|
2028
|
-
_render_steps_element();
|
|
2029
|
-
// When the user was redirected the URL params are defined, if so only render the processing view.
|
|
2030
|
-
if (Utils.url_param("payment_status", null) != null) {
|
|
2031
|
-
_show_processing(Utils.url_param("payment_status", null));
|
|
2032
|
-
}
|
|
2033
|
-
// No redirect.
|
|
2034
|
-
else {
|
|
2035
|
-
// Render the overview element.
|
|
2036
|
-
_render_overview_element();
|
|
2037
|
-
// Render the order element.
|
|
2038
|
-
// Must be rendered after the overview element is rendered.
|
|
2039
|
-
_render_order_element();
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
// Initialize refund page.
|
|
2043
|
-
function create_refunds_dropin({
|
|
2044
|
-
// The element containers.
|
|
2045
|
-
refunds_container,
|
|
2046
|
-
// Refundable settings.
|
|
2047
|
-
days_refundable = 30,
|
|
2048
|
-
// Events.
|
|
2049
|
-
on_error = (error) => { }, }) {
|
|
2050
|
-
// Check args.
|
|
2051
|
-
if (!(refunds_container instanceof Node)) {
|
|
2052
|
-
throw new Error('The "refunds_container" must be assigned with a container node.');
|
|
2053
|
-
}
|
|
2054
|
-
// Args.
|
|
2055
|
-
_refunds_container = refunds_container;
|
|
2056
|
-
_days_refundable = days_refundable;
|
|
2057
|
-
// Events.
|
|
2058
|
-
Payments.on_error = on_error;
|
|
2059
|
-
// Check style.
|
|
2060
|
-
if (_style === undefined) {
|
|
2061
|
-
Payments.style();
|
|
2062
|
-
}
|
|
2063
|
-
// Other attributes.
|
|
2064
|
-
_payment_step = 0;
|
|
2065
|
-
// Render the refunds element.
|
|
2066
|
-
_render_refunds_element();
|
|
2067
|
-
}
|
|
2068
|
-
// Backend API.
|
|
2069
|
-
// Get the currency symbol for a product currency.
|
|
2070
|
-
// Returns `null` when the currency is not supported.
|
|
2071
|
-
/**
|
|
2072
|
-
* {Get Currency Symbol}
|
|
2073
|
-
* Get the currency symbol for a product currency.
|
|
2074
|
-
* @nav Frontend/Payments
|
|
2075
|
-
* @parameter currency The currency from the product object.
|
|
2076
|
-
* @returns Returns the currency symbol when the currency is supported, otherwise `null`
|
|
2077
|
-
* @docs
|
|
2078
|
-
*/
|
|
2079
|
-
function get_currency_symbol(currency) {
|
|
2080
|
-
switch (currency.toLowerCase()) {
|
|
2081
|
-
case "aed": return "د.إ";
|
|
2082
|
-
case "afn": return "Af";
|
|
2083
|
-
case "all": return "L";
|
|
2084
|
-
case "amd": return "֏";
|
|
2085
|
-
case "ang": return "ƒ";
|
|
2086
|
-
case "aoa": return "Kz";
|
|
2087
|
-
case "ars": return "$";
|
|
2088
|
-
case "aud": return "$";
|
|
2089
|
-
case "awg": return "ƒ";
|
|
2090
|
-
case "azn": return "₼";
|
|
2091
|
-
case "bam": return "KM";
|
|
2092
|
-
case "bbd": return "Bds$";
|
|
2093
|
-
case "bdt": return "৳";
|
|
2094
|
-
case "bgn": return "лв";
|
|
2095
|
-
case "bhd": return ".د.ب";
|
|
2096
|
-
case "bif": return "FBu";
|
|
2097
|
-
case "bmd": return "BD$";
|
|
2098
|
-
case "bnd": return "B$";
|
|
2099
|
-
case "bob": return "Bs";
|
|
2100
|
-
case "brl": return "R$";
|
|
2101
|
-
case "bsd": return "B$";
|
|
2102
|
-
case "btn": return "Nu.";
|
|
2103
|
-
case "bwp": return "P";
|
|
2104
|
-
case "byn": return "Br";
|
|
2105
|
-
case "bzd": return "BZ$";
|
|
2106
|
-
case "cad": return "$";
|
|
2107
|
-
case "cdf": return "FC";
|
|
2108
|
-
case "chf": return "Fr";
|
|
2109
|
-
case "clf": return "UF";
|
|
2110
|
-
case "clp": return "$";
|
|
2111
|
-
case "cny": return "¥";
|
|
2112
|
-
case "cop": return "$";
|
|
2113
|
-
case "crc": return "₡";
|
|
2114
|
-
case "cuc": return "CUC$";
|
|
2115
|
-
case "cup": return "CUP$";
|
|
2116
|
-
case "cve": return "$";
|
|
2117
|
-
case "czk": return "Kč";
|
|
2118
|
-
case "djf": return "Fdj";
|
|
2119
|
-
case "dkk": return "kr";
|
|
2120
|
-
case "dop": return "RD$";
|
|
2121
|
-
case "dzd": return "دج";
|
|
2122
|
-
case "egp": return "E£";
|
|
2123
|
-
case "ern": return "Nfk";
|
|
2124
|
-
case "etb": return "Br";
|
|
2125
|
-
case "eur": return "€";
|
|
2126
|
-
case "fjd": return "FJ$";
|
|
2127
|
-
case "fkp": return "£";
|
|
2128
|
-
case "fok": return "F$";
|
|
2129
|
-
case "gbp": return "£";
|
|
2130
|
-
case "gel": return "₾";
|
|
2131
|
-
case "ghc": return "₵";
|
|
2132
|
-
case "gip": return "£";
|
|
2133
|
-
case "gmd": return "D";
|
|
2134
|
-
case "gnf": return "FG";
|
|
2135
|
-
case "gtq": return "Q";
|
|
2136
|
-
case "gyd": return "GY$";
|
|
2137
|
-
case "hkd": return "HK$";
|
|
2138
|
-
case "hnl": return "L";
|
|
2139
|
-
case "hrk": return "kn";
|
|
2140
|
-
case "htg": return "G";
|
|
2141
|
-
case "huf": return "Ft";
|
|
2142
|
-
case "idr": return "Rp";
|
|
2143
|
-
case "ils": return "₪";
|
|
2144
|
-
case "inr": return "₹";
|
|
2145
|
-
case "iqd": return "د.ع";
|
|
2146
|
-
case "irr": return "﷼";
|
|
2147
|
-
case "isk": return "kr";
|
|
2148
|
-
case "jmd": return "J$";
|
|
2149
|
-
case "jod": return "JD";
|
|
2150
|
-
case "jpy": return "¥";
|
|
2151
|
-
case "kes": return "Ksh";
|
|
2152
|
-
case "kgs": return "с";
|
|
2153
|
-
case "khr": return "៛";
|
|
2154
|
-
case "kmf": return "CF";
|
|
2155
|
-
case "kpw": return "₩";
|
|
2156
|
-
case "krw": return "₩";
|
|
2157
|
-
case "kwd": return "KD";
|
|
2158
|
-
case "kyd": return "CI$";
|
|
2159
|
-
case "kzt": return "₸";
|
|
2160
|
-
case "lak": return "₭";
|
|
2161
|
-
case "lbp": return "L£";
|
|
2162
|
-
case "lkr": return "Rs";
|
|
2163
|
-
case "lrd": return "L$";
|
|
2164
|
-
case "lsl": return "L";
|
|
2165
|
-
case "lyd": return "ل.د";
|
|
2166
|
-
case "mad": return "د.م.";
|
|
2167
|
-
case "mdl": return "L";
|
|
2168
|
-
case "mnt": return "₮";
|
|
2169
|
-
case "mop": return "MOP$";
|
|
2170
|
-
case "mur": return "Rs";
|
|
2171
|
-
case "mvr": return "Rf";
|
|
2172
|
-
case "mwk": return "MK";
|
|
2173
|
-
case "mxn": return "$";
|
|
2174
|
-
case "myr": return "RM";
|
|
2175
|
-
case "mzn": return "MTn";
|
|
2176
|
-
case "nad": return "N$";
|
|
2177
|
-
case "ngn": return "₦";
|
|
2178
|
-
case "nio": return "C$";
|
|
2179
|
-
case "nok": return "kr";
|
|
2180
|
-
case "npr": return "रू";
|
|
2181
|
-
case "nzd": return "$";
|
|
2182
|
-
case "omr": return "ر.ع.";
|
|
2183
|
-
case "pab": return "B/.";
|
|
2184
|
-
case "pen": return "S/.";
|
|
2185
|
-
case "pgk": return "K";
|
|
2186
|
-
case "php": return "₱";
|
|
2187
|
-
case "pkr": return "Rs";
|
|
2188
|
-
case "pln": return "zł";
|
|
2189
|
-
case "pyg": return "₲";
|
|
2190
|
-
case "qar": return "ر.ق";
|
|
2191
|
-
case "ron": return "lei";
|
|
2192
|
-
case "rsd": return "din.";
|
|
2193
|
-
case "rub": return "₽";
|
|
2194
|
-
case "rwf": return "FRw";
|
|
2195
|
-
case "sar": return "ر.س";
|
|
2196
|
-
case "sbd": return "SI$";
|
|
2197
|
-
case "scr": return "Sr";
|
|
2198
|
-
case "sdg": return "ج.س.";
|
|
2199
|
-
case "sek": return "kr";
|
|
2200
|
-
case "sgd": return "S$";
|
|
2201
|
-
case "shp": return "£";
|
|
2202
|
-
case "sll": return "Le";
|
|
2203
|
-
case "sos": return "S";
|
|
2204
|
-
case "srd": return "SRD$";
|
|
2205
|
-
case "ssp": return "£";
|
|
2206
|
-
case "std": return "Db";
|
|
2207
|
-
case "syp": return "S£";
|
|
2208
|
-
case "szl": return "L";
|
|
2209
|
-
case "thb": return "฿";
|
|
2210
|
-
case "tjs": return "ЅМ";
|
|
2211
|
-
case "tmt": return "m";
|
|
2212
|
-
case "tnd": return "د.ت";
|
|
2213
|
-
case "top": return "T$";
|
|
2214
|
-
case "try": return "₺";
|
|
2215
|
-
case "ttd": return "TT$";
|
|
2216
|
-
case "twd": return "NT$";
|
|
2217
|
-
case "tzs": return "TSh";
|
|
2218
|
-
case "uah": return "₴";
|
|
2219
|
-
case "ugx": return "USh";
|
|
2220
|
-
case "usd": return "$";
|
|
2221
|
-
case "uyu": return "$U";
|
|
2222
|
-
case "uzs": return "лв";
|
|
2223
|
-
case "ves": return "Bs.S.";
|
|
2224
|
-
case "vnd": return "₫";
|
|
2225
|
-
case "vuv": return "VT";
|
|
2226
|
-
case "wst": return "WS$";
|
|
2227
|
-
case "xaf": return "FCFA";
|
|
2228
|
-
case "xcd": return "EC$";
|
|
2229
|
-
case "xof": return "CFA";
|
|
2230
|
-
case "xpf": return "CFP";
|
|
2231
|
-
case "yer": return "﷼";
|
|
2232
|
-
case "zar": return "R";
|
|
2233
|
-
case "zmw": return "ZK";
|
|
2234
|
-
}
|
|
2235
|
-
return null;
|
|
2236
|
-
}
|
|
2237
|
-
Payments.get_currency_symbol = get_currency_symbol;
|
|
2238
|
-
// Fetch the payment products.
|
|
2239
|
-
/**
|
|
2240
|
-
* {Payment Products}
|
|
2241
|
-
* Get the backend defined payment products asynchronously.
|
|
2242
|
-
* @nav Frontend/Payments
|
|
2243
|
-
* @returns Returns the backend defined payment products.
|
|
2244
|
-
* @docs
|
|
2245
|
-
*/
|
|
2246
|
-
function get_products() {
|
|
2247
|
-
if (_products !== undefined) {
|
|
2248
|
-
return _products;
|
|
2249
|
-
}
|
|
2250
|
-
return request({
|
|
2251
|
-
method: "GET",
|
|
2252
|
-
url: "/volt/api/v1/payments/products",
|
|
2253
|
-
});
|
|
2254
|
-
}
|
|
2255
|
-
Payments.get_products = get_products;
|
|
2256
|
-
// Fetch a payment product by id.
|
|
2257
|
-
/**
|
|
2258
|
-
* {Get Payment Product}
|
|
2259
|
-
* Get the backend defined payment product by id asynchronously.
|
|
2260
|
-
* @nav Frontend/Payments
|
|
2261
|
-
* @parameter id The id of the payment product.
|
|
2262
|
-
* @returns Returns the backend defined payment product.
|
|
2263
|
-
* @docs
|
|
2264
|
-
*/
|
|
2265
|
-
async function get_product(id) {
|
|
2266
|
-
// APPLY_NEW_RESPONSE
|
|
2267
|
-
const products = await get_products();
|
|
2268
|
-
if (products.error)
|
|
2269
|
-
return products;
|
|
2270
|
-
let product = undefined;
|
|
2271
|
-
for (const p of products.data) {
|
|
2272
|
-
if (p.id === id) {
|
|
2273
|
-
product = p;
|
|
2274
|
-
break;
|
|
2275
|
-
}
|
|
2276
|
-
if (p.is_subscription && p.plans) {
|
|
2277
|
-
for (const plan of p.plans) {
|
|
2278
|
-
if (plan.id === id) {
|
|
2279
|
-
product = plan;
|
|
2280
|
-
break;
|
|
2281
|
-
}
|
|
2282
|
-
}
|
|
2283
|
-
if (product)
|
|
2284
|
-
break;
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
if (product == null) {
|
|
2288
|
-
return {
|
|
2289
|
-
error: {
|
|
2290
|
-
message: `Product "${id}" does not exist.`
|
|
2291
|
-
},
|
|
2292
|
-
status: 400,
|
|
2293
|
-
};
|
|
2294
|
-
}
|
|
2295
|
-
return {
|
|
2296
|
-
status: 200,
|
|
2297
|
-
data: product
|
|
2298
|
-
};
|
|
2299
|
-
}
|
|
2300
|
-
Payments.get_product = get_product;
|
|
2301
|
-
// Fetch a payment object by id.
|
|
2302
|
-
/**
|
|
2303
|
-
* {Get Payment}
|
|
2304
|
-
* Get a payment by id.
|
|
2305
|
-
* @nav Frontend/Payments
|
|
2306
|
-
* @parameter id The id of the payment.
|
|
2307
|
-
* @docs
|
|
2308
|
-
*/
|
|
2309
|
-
function get_payment(payload) {
|
|
2310
|
-
return request({
|
|
2311
|
-
method: "GET",
|
|
2312
|
-
url: "/volt/api/v1/payments/payment",
|
|
2313
|
-
data: payload,
|
|
2314
|
-
});
|
|
2315
|
-
}
|
|
2316
|
-
Payments.get_payment = get_payment;
|
|
2317
|
-
// Get all payments.
|
|
2318
|
-
/**
|
|
2319
|
-
* {Get Refunded Payments}
|
|
2320
|
-
* Get all payments of the authenticated user
|
|
2321
|
-
*
|
|
2322
|
-
* All failed payments are no longer stored in the database.
|
|
2323
|
-
* @nav Frontend/Payments
|
|
2324
|
-
* @parameter days Retrieve payments from the last amount of days.
|
|
2325
|
-
* @parameter limit Limit the amount of response payment objects.
|
|
2326
|
-
* @parameter status Filter the payments by status. Be aware that the line items of a payment also have a status with possible values of `open`, `cancelled`, `refunding` or `refunded.`
|
|
2327
|
-
* @docs
|
|
2328
|
-
*/
|
|
2329
|
-
function get_payments(payload) {
|
|
2330
|
-
return request({
|
|
2331
|
-
method: "GET",
|
|
2332
|
-
url: "/volt/api/v1/payments/payments",
|
|
2333
|
-
data: payload
|
|
2334
|
-
});
|
|
2335
|
-
}
|
|
2336
|
-
Payments.get_payments = get_payments;
|
|
2337
|
-
// Get refundable payments.
|
|
2338
|
-
/**
|
|
2339
|
-
* {Get Refundable Payments}
|
|
2340
|
-
* Get all payments that are refundable for the authenticated user.
|
|
2341
|
-
* @nav Frontend/Payments
|
|
2342
|
-
* @parameter days Retrieve payments from the last amount of days.
|
|
2343
|
-
* @parameter limit Limit the amount of response payment objects.
|
|
2344
|
-
* @docs
|
|
2345
|
-
*/
|
|
2346
|
-
function get_refundable_payments(payload) {
|
|
2347
|
-
return request({
|
|
2348
|
-
method: "GET",
|
|
2349
|
-
url: "/volt/api/v1/payments/payments/refundable",
|
|
2350
|
-
data: payload
|
|
2351
|
-
});
|
|
2352
|
-
}
|
|
2353
|
-
Payments.get_refundable_payments = get_refundable_payments;
|
|
2354
|
-
// Get refunded payments.
|
|
2355
|
-
/**
|
|
2356
|
-
* {Get Refunded Payments}
|
|
2357
|
-
* Get all successfully refunded payments of the authenticated user.
|
|
2358
|
-
* @nav Frontend/Payments
|
|
2359
|
-
* @parameter days Retrieve payments from the last amount of days.
|
|
2360
|
-
* @parameter limit Limit the amount of response payment objects.
|
|
2361
|
-
* @docs
|
|
2362
|
-
*/
|
|
2363
|
-
function get_refunded_payments(payload) {
|
|
2364
|
-
return request({
|
|
2365
|
-
method: "GET",
|
|
2366
|
-
url: "/volt/api/v1/payments/payments/refunded",
|
|
2367
|
-
data: payload
|
|
2368
|
-
});
|
|
2369
|
-
}
|
|
2370
|
-
Payments.get_refunded_payments = get_refunded_payments;
|
|
2371
|
-
// Get refunding payments.
|
|
2372
|
-
/**
|
|
2373
|
-
* {Get Refunding Payments}
|
|
2374
|
-
* Get all payments that are currently in the refunding process of the authenticated user.
|
|
2375
|
-
* @nav Frontend/Payments
|
|
2376
|
-
* @parameter days Retrieve payments from the last amount of days.
|
|
2377
|
-
* @parameter limit Limit the amount of response payment objects.
|
|
2378
|
-
* @docs
|
|
2379
|
-
*/
|
|
2380
|
-
function get_refunding_payments(payload) {
|
|
2381
|
-
return request({
|
|
2382
|
-
method: "GET",
|
|
2383
|
-
url: "/volt/api/v1/payments/payments/refunding",
|
|
2384
|
-
data: payload
|
|
2385
|
-
});
|
|
2386
|
-
}
|
|
2387
|
-
Payments.get_refunding_payments = get_refunding_payments;
|
|
2388
|
-
// Create refund.
|
|
2389
|
-
/**
|
|
2390
|
-
* {Refund Payment}
|
|
2391
|
-
* Refund a payment based on the payment id for the authenticated user.
|
|
2392
|
-
* @warning Refunding a subscription will also cancel all other subscriptions that were created by the same payment request.
|
|
2393
|
-
* @nav Frontend/Payments
|
|
2394
|
-
* @parameter payment The id of the payment object or the payment object itself.
|
|
2395
|
-
* @parameter line_items The line items to refund, these must be retrieved from the original payment line items otherwise it may cause undefined behaviour. When undefined the entire payment will be refunded.
|
|
2396
|
-
* @parameter reason The refund reason.
|
|
2397
|
-
* @docs
|
|
2398
|
-
*/
|
|
2399
|
-
function create_refund(payload) {
|
|
2400
|
-
return request({
|
|
2401
|
-
method: "POST",
|
|
2402
|
-
url: "/volt/api/v1/payments/refund",
|
|
2403
|
-
data: payload
|
|
2404
|
-
});
|
|
2405
|
-
}
|
|
2406
|
-
Payments.create_refund = create_refund;
|
|
2407
|
-
// Cancel subscription.
|
|
2408
|
-
/**
|
|
2409
|
-
* {Cancel Subscription}
|
|
2410
|
-
* Cancel a subscription based on the product id.
|
|
2411
|
-
* @warning Cancelling a subscription will also cancel all other subscriptions that were created by the same payment request.
|
|
2412
|
-
* @nav Frontend/Payments
|
|
2413
|
-
* @parameter product The product id.
|
|
2414
|
-
* @docs
|
|
2415
|
-
*/
|
|
2416
|
-
function cancel_subscription(payload) {
|
|
2417
|
-
return request({
|
|
2418
|
-
method: "DELETE",
|
|
2419
|
-
url: "/volt/api/v1/payments/subscription",
|
|
2420
|
-
data: payload
|
|
2421
|
-
});
|
|
2422
|
-
}
|
|
2423
|
-
Payments.cancel_subscription = cancel_subscription;
|
|
2424
|
-
// Is subscribed.
|
|
2425
|
-
/**
|
|
2426
|
-
* {Is Subscribed}
|
|
2427
|
-
* Check if the authenticated user is subscribed to a product plan.
|
|
2428
|
-
* @nav Frontend/Payments
|
|
2429
|
-
* @parameter product The product id.
|
|
2430
|
-
* @docs
|
|
2431
|
-
*/
|
|
2432
|
-
function is_subscribed(payload) {
|
|
2433
|
-
return request({
|
|
2434
|
-
method: "GET",
|
|
2435
|
-
url: "/volt/api/v1/payments/subscribed",
|
|
2436
|
-
data: payload
|
|
2437
|
-
});
|
|
2438
|
-
}
|
|
2439
|
-
Payments.is_subscribed = is_subscribed;
|
|
2440
|
-
// Get active subscriptions.
|
|
2441
|
-
/**
|
|
2442
|
-
* {Get active subscriptions}
|
|
2443
|
-
* Get the active subscriptions of the authenticated user.
|
|
2444
|
-
* @nav Frontend/Payments
|
|
2445
|
-
* @docs
|
|
2446
|
-
*/
|
|
2447
|
-
function get_active_subscriptions() {
|
|
2448
|
-
return request({
|
|
2449
|
-
method: "GET",
|
|
2450
|
-
url: "/volt/api/v1/payments/active_subscriptions",
|
|
2451
|
-
});
|
|
2452
|
-
}
|
|
2453
|
-
Payments.get_active_subscriptions = get_active_subscriptions;
|
|
2454
|
-
// Shopping cart.
|
|
2455
|
-
// The shopping cart object.
|
|
2456
|
-
let Cart;
|
|
2457
|
-
(function (Cart) {
|
|
2458
|
-
Cart.items = [];
|
|
2459
|
-
// Refresh the shopping cart.
|
|
2460
|
-
/**
|
|
2461
|
-
* {Refresh Cart}
|
|
2462
|
-
* Refresh the shopping cart.
|
|
2463
|
-
*
|
|
2464
|
-
* The current cart items are accessible as `Payments.cart.items`.
|
|
2465
|
-
* @nav Frontend/Payments
|
|
2466
|
-
* @docs
|
|
2467
|
-
*/
|
|
2468
|
-
function refresh() {
|
|
2469
|
-
// Load from local storage.
|
|
2470
|
-
try {
|
|
2471
|
-
Cart.items = JSON.parse(localStorage.getItem("volt_shopping_cart")) || [];
|
|
2472
|
-
}
|
|
2473
|
-
catch (err) {
|
|
2474
|
-
Cart.items = [];
|
|
2475
|
-
}
|
|
2476
|
-
// Reset the charge objects.
|
|
2477
|
-
_reset_payment_element();
|
|
2478
|
-
}
|
|
2479
|
-
Cart.refresh = refresh;
|
|
2480
|
-
// Save the shopping cart.
|
|
2481
|
-
/**
|
|
2482
|
-
* {Save Cart}
|
|
2483
|
-
* Save the shopping cart in the local storage.
|
|
2484
|
-
*
|
|
2485
|
-
* The current cart items are accessible as `Payments.cart.items`.
|
|
2486
|
-
* @nav Frontend/Payments
|
|
2487
|
-
* @docs
|
|
2488
|
-
*/
|
|
2489
|
-
function save() {
|
|
2490
|
-
// Save to local storage.
|
|
2491
|
-
localStorage.setItem("volt_shopping_cart", JSON.stringify(Cart.items));
|
|
2492
|
-
// Reset the charge objects.
|
|
2493
|
-
_reset_payment_element();
|
|
2494
|
-
}
|
|
2495
|
-
Cart.save = save;
|
|
2496
|
-
// Add a product to the shopping cart.
|
|
2497
|
-
/**
|
|
2498
|
-
* {Add to Cart}
|
|
2499
|
-
* Add a product to the shopping cart.
|
|
2500
|
-
*
|
|
2501
|
-
* When the product was already added to the shopping cart only the quantity will be incremented.
|
|
2502
|
-
*
|
|
2503
|
-
* An error will be thrown if the product id does not exist.
|
|
2504
|
-
*
|
|
2505
|
-
* The current cart items are accessible as `Payments.cart.items`.
|
|
2506
|
-
* @nav Frontend/Payments
|
|
2507
|
-
* @parameter id The product's id.
|
|
2508
|
-
* @parameter quantity The quantity to add.
|
|
2509
|
-
* @docs
|
|
2510
|
-
*/
|
|
2511
|
-
async function add(id, quantity = 1) {
|
|
2512
|
-
Cart.refresh(); // Update in case another window has updated the cart.
|
|
2513
|
-
const found = Cart.items.some((item) => {
|
|
2514
|
-
if (item.product.id === id) {
|
|
2515
|
-
item.quantity += quantity;
|
|
2516
|
-
return true;
|
|
2517
|
-
}
|
|
2518
|
-
return false;
|
|
2519
|
-
});
|
|
2520
|
-
if (!found) {
|
|
2521
|
-
try {
|
|
2522
|
-
const product = await Payments.get_product(id);
|
|
2523
|
-
if (product.error)
|
|
2524
|
-
throw new Error(product.error.message);
|
|
2525
|
-
Cart.items.push({
|
|
2526
|
-
product: product.data,
|
|
2527
|
-
quantity: quantity,
|
|
2528
|
-
});
|
|
2529
|
-
}
|
|
2530
|
-
catch (error) {
|
|
2531
|
-
console.error(error);
|
|
2532
|
-
Payments.on_error(error);
|
|
2533
|
-
throw new Error(`Failed to add product with id "${id}" to the cart.`);
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2536
|
-
Cart.save();
|
|
2537
|
-
}
|
|
2538
|
-
Cart.add = add;
|
|
2539
|
-
// Remove a product from the shopping cart.
|
|
2540
|
-
/**
|
|
2541
|
-
* {Remove from Cart}
|
|
2542
|
-
* Remove a product from the shopping cart.
|
|
2543
|
-
*
|
|
2544
|
-
* Does not throw an error when the product was not added to the shopping cart.
|
|
2545
|
-
*
|
|
2546
|
-
* The current cart items are accessible as `Payments.cart.items`.
|
|
2547
|
-
* @nav Frontend/Payments
|
|
2548
|
-
* @parameter id The product's id.
|
|
2549
|
-
* @parameter quantity The quantity to remove. When the quantity value is "all", the entire product will be removed from the shopping cart.
|
|
2550
|
-
* @docs
|
|
2551
|
-
*/
|
|
2552
|
-
async function remove(id, quantity = 1) {
|
|
2553
|
-
Cart.refresh(); // Update in case another window has updated the cart.
|
|
2554
|
-
let new_cart = [];
|
|
2555
|
-
Cart.items.forEach((item) => {
|
|
2556
|
-
if (item.product.id === id) {
|
|
2557
|
-
if (quantity === "all") {
|
|
2558
|
-
item.quantity = 0;
|
|
2559
|
-
}
|
|
2560
|
-
else {
|
|
2561
|
-
item.quantity -= quantity;
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
if (item.quantity > 0) {
|
|
2565
|
-
new_cart.push(item);
|
|
2566
|
-
}
|
|
2567
|
-
});
|
|
2568
|
-
Cart.items = new_cart;
|
|
2569
|
-
Cart.save();
|
|
2570
|
-
}
|
|
2571
|
-
Cart.remove = remove;
|
|
2572
|
-
// Clear the shopping cart.
|
|
2573
|
-
/**
|
|
2574
|
-
* {Clear Cart}
|
|
2575
|
-
* Clear the shopping cart.
|
|
2576
|
-
*
|
|
2577
|
-
* Will automatically be called if `Payments.confirm_charge()` finishes without any errors.
|
|
2578
|
-
*
|
|
2579
|
-
* The current cart items are accessible as `Payments.cart.items`.
|
|
2580
|
-
* @nav Frontend/Payments
|
|
2581
|
-
* @docs
|
|
2582
|
-
*/
|
|
2583
|
-
async function clear() {
|
|
2584
|
-
Cart.items = [];
|
|
2585
|
-
Cart.save();
|
|
2586
|
-
}
|
|
2587
|
-
Cart.clear = clear;
|
|
2588
|
-
})(Cart = Payments.Cart || (Payments.Cart = {}));
|
|
2589
|
-
})(Payments || (Payments = {}));
|
|
2590
|
-
;
|
|
2591
|
-
export { Payments as payments }; // also export as lowercase for compatibility.
|
|
2592
|
-
// APPLY_FIX // @todo if undeprecate: convert to namespace
|
|
2593
|
-
// APPLY_FIX // @todo if undeprecate: audit by claude
|
|
2594
|
-
// APPLY_FIX // @todo if undeprecate: remove request_v1 everywhere in volt, return Utils.RequestResult instead
|