@etohq/utils 1.4.0 → 1.5.0
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/dist/analytics/abstract-analytics-provider.d.ts +110 -0
- package/dist/analytics/abstract-analytics-provider.d.ts.map +1 -0
- package/dist/analytics/abstract-analytics-provider.js +107 -0
- package/dist/analytics/abstract-analytics-provider.js.map +1 -0
- package/dist/analytics/index.d.ts +2 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +18 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/auth/token.d.ts +4 -2
- package/dist/auth/token.d.ts.map +1 -1
- package/dist/auth/token.js +5 -2
- package/dist/auth/token.js.map +1 -1
- package/dist/bundles.d.ts +1 -0
- package/dist/bundles.d.ts.map +1 -1
- package/dist/bundles.js +2 -1
- package/dist/bundles.js.map +1 -1
- package/dist/common/build-query.d.ts +1 -1
- package/dist/common/build-query.d.ts.map +1 -1
- package/dist/common/compress-name.d.ts +2 -0
- package/dist/common/compress-name.d.ts.map +1 -0
- package/dist/common/compress-name.js +34 -0
- package/dist/common/compress-name.js.map +1 -0
- package/dist/common/container.d.ts +98 -0
- package/dist/common/container.d.ts.map +1 -1
- package/dist/common/container.js +94 -0
- package/dist/common/container.js.map +1 -1
- package/dist/common/create-psql-index-helper.d.ts +1 -1
- package/dist/common/define-config.d.ts +4 -4
- package/dist/common/define-config.d.ts.map +1 -1
- package/dist/common/define-config.js +45 -26
- package/dist/common/define-config.js.map +1 -1
- package/dist/common/errors.d.ts +3 -0
- package/dist/common/errors.d.ts.map +1 -1
- package/dist/common/errors.js +1 -0
- package/dist/common/errors.js.map +1 -1
- package/dist/common/exec-mode.d.ts +2 -0
- package/dist/common/exec-mode.d.ts.map +1 -0
- package/dist/common/exec-mode.js +15 -0
- package/dist/common/exec-mode.js.map +1 -0
- package/dist/common/flatten-object-to-key-value-pairs.d.ts.map +1 -1
- package/dist/common/flatten-object-to-key-value-pairs.js +214 -72
- package/dist/common/flatten-object-to-key-value-pairs.js.map +1 -1
- package/dist/common/get-resolved-plugins.d.ts +4 -0
- package/dist/common/get-resolved-plugins.d.ts.map +1 -0
- package/dist/common/get-resolved-plugins.js +121 -0
- package/dist/common/get-resolved-plugins.js.map +1 -0
- package/dist/common/get-selects-and-relations-from-object-array.d.ts +2 -1
- package/dist/common/get-selects-and-relations-from-object-array.d.ts.map +1 -1
- package/dist/common/get-selects-and-relations-from-object-array.js +7 -5
- package/dist/common/get-selects-and-relations-from-object-array.js.map +1 -1
- package/dist/common/index.d.ts +19 -5
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +19 -5
- package/dist/common/index.js.map +1 -1
- package/dist/common/load-env.d.ts +3 -0
- package/dist/common/load-env.d.ts.map +1 -1
- package/dist/common/load-env.js +7 -4
- package/dist/common/load-env.js.map +1 -1
- package/dist/common/math.d.ts +2 -2
- package/dist/common/math.d.ts.map +1 -1
- package/dist/common/math.js +13 -6
- package/dist/common/math.js.map +1 -1
- package/dist/common/merge-metadata.d.ts +15 -0
- package/dist/common/merge-metadata.d.ts.map +1 -0
- package/dist/common/merge-metadata.js +34 -0
- package/dist/common/merge-metadata.js.map +1 -0
- package/dist/common/normalize-csv-value.d.ts +6 -0
- package/dist/common/normalize-csv-value.d.ts.map +1 -0
- package/dist/common/normalize-csv-value.js +14 -0
- package/dist/common/normalize-csv-value.js.map +1 -0
- package/dist/common/retry-execution.d.ts +18 -0
- package/dist/common/retry-execution.d.ts.map +1 -0
- package/dist/common/retry-execution.js +50 -0
- package/dist/common/retry-execution.js.map +1 -0
- package/dist/common/to-unix-slash.d.ts +2 -0
- package/dist/common/to-unix-slash.d.ts.map +1 -0
- package/dist/common/to-unix-slash.js +11 -0
- package/dist/common/to-unix-slash.js.map +1 -0
- package/dist/common/try-convert-to-boolean.d.ts +7 -0
- package/dist/common/try-convert-to-boolean.d.ts.map +1 -0
- package/dist/common/try-convert-to-boolean.js +15 -0
- package/dist/common/try-convert-to-boolean.js.map +1 -0
- package/dist/common/try-convert-to-number.d.ts +7 -0
- package/dist/common/try-convert-to-number.d.ts.map +1 -0
- package/dist/common/try-convert-to-number.js +10 -0
- package/dist/common/try-convert-to-number.js.map +1 -0
- package/dist/common/unflatten-object-keys.d.ts +29 -0
- package/dist/common/unflatten-object-keys.d.ts.map +1 -0
- package/dist/common/unflatten-object-keys.js +67 -0
- package/dist/common/unflatten-object-keys.js.map +1 -0
- package/dist/common/validate-module-name.d.ts +2 -0
- package/dist/common/validate-module-name.d.ts.map +1 -0
- package/dist/common/validate-module-name.js +27 -0
- package/dist/common/validate-module-name.js.map +1 -0
- package/dist/common/wrap-handler.d.ts +2 -0
- package/dist/common/wrap-handler.d.ts.map +1 -0
- package/dist/common/wrap-handler.js +40 -0
- package/dist/common/wrap-handler.js.map +1 -0
- package/dist/core-flows/events.d.ts +57 -0
- package/dist/core-flows/events.d.ts.map +1 -1
- package/dist/core-flows/events.js +58 -8
- package/dist/core-flows/events.js.map +1 -1
- package/dist/dal/index.d.ts +1 -0
- package/dist/dal/index.d.ts.map +1 -1
- package/dist/dal/index.js +1 -0
- package/dist/dal/index.js.map +1 -1
- package/dist/dal/mikro-orm/big-number-field.d.ts.map +1 -1
- package/dist/dal/mikro-orm/big-number-field.js +36 -21
- package/dist/dal/mikro-orm/big-number-field.js.map +1 -1
- package/dist/dal/mikro-orm/mikro-orm-create-connection.d.ts +10 -4
- package/dist/dal/mikro-orm/mikro-orm-create-connection.d.ts.map +1 -1
- package/dist/dal/mikro-orm/mikro-orm-create-connection.js +53 -11
- package/dist/dal/mikro-orm/mikro-orm-create-connection.js.map +1 -1
- package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.d.ts +3 -6
- package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.d.ts.map +1 -1
- package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.js +16 -21
- package/dist/dal/mikro-orm/mikro-orm-free-text-search-filter.js.map +1 -1
- package/dist/dal/mikro-orm/mikro-orm-repository.d.ts +4 -7
- package/dist/dal/mikro-orm/mikro-orm-repository.d.ts.map +1 -1
- package/dist/dal/mikro-orm/mikro-orm-repository.js +94 -79
- package/dist/dal/mikro-orm/mikro-orm-repository.js.map +1 -1
- package/dist/dal/mikro-orm/mikro-orm-serializer.d.ts +7 -3
- package/dist/dal/mikro-orm/mikro-orm-serializer.d.ts.map +1 -1
- package/dist/dal/mikro-orm/mikro-orm-serializer.js +18 -15
- package/dist/dal/mikro-orm/mikro-orm-serializer.js.map +1 -1
- package/dist/dal/mikro-orm/sql-migration-generator.d.ts +6 -4
- package/dist/dal/mikro-orm/sql-migration-generator.d.ts.map +1 -1
- package/dist/dal/mikro-orm/sql-migration-generator.js +120 -70
- package/dist/dal/mikro-orm/sql-migration-generator.js.map +1 -1
- package/dist/dal/mikro-orm/utils.d.ts +14 -1
- package/dist/dal/mikro-orm/utils.d.ts.map +1 -1
- package/dist/dal/mikro-orm/utils.js +82 -38
- package/dist/dal/mikro-orm/utils.js.map +1 -1
- package/dist/defaults/countries.d.ts.map +1 -1
- package/dist/defaults/countries.js +0 -6
- package/dist/defaults/countries.js.map +1 -1
- package/dist/defaults/currencies.d.ts.map +1 -1
- package/dist/defaults/currencies.js +9 -0
- package/dist/defaults/currencies.js.map +1 -1
- package/dist/dml/entity-builder.d.ts.map +1 -1
- package/dist/dml/entity-builder.js.map +1 -1
- package/dist/dml/entity.d.ts +4 -5
- package/dist/dml/entity.d.ts.map +1 -1
- package/dist/dml/entity.js +0 -2
- package/dist/dml/entity.js.map +1 -1
- package/dist/dml/helpers/create-graphql.d.ts.map +1 -1
- package/dist/dml/helpers/create-graphql.js +27 -2
- package/dist/dml/helpers/create-graphql.js.map +1 -1
- package/dist/dml/helpers/create-mikro-orm-entity.d.ts.map +1 -1
- package/dist/dml/helpers/create-mikro-orm-entity.js +9 -6
- package/dist/dml/helpers/create-mikro-orm-entity.js.map +1 -1
- package/dist/dml/helpers/entity-builder/define-property.d.ts.map +1 -1
- package/dist/dml/helpers/entity-builder/define-property.js +9 -7
- package/dist/dml/helpers/entity-builder/define-property.js.map +1 -1
- package/dist/dml/helpers/entity-builder/define-relationship.d.ts +1 -1
- package/dist/dml/helpers/entity-builder/define-relationship.d.ts.map +1 -1
- package/dist/dml/helpers/entity-builder/define-relationship.js +41 -25
- package/dist/dml/helpers/entity-builder/define-relationship.js.map +1 -1
- package/dist/dml/helpers/entity-builder/index.d.ts +1 -0
- package/dist/dml/helpers/entity-builder/index.d.ts.map +1 -1
- package/dist/dml/helpers/entity-builder/index.js +1 -0
- package/dist/dml/helpers/entity-builder/index.js.map +1 -1
- package/dist/dml/helpers/entity-builder/relationship-helpers.d.ts +6 -0
- package/dist/dml/helpers/entity-builder/relationship-helpers.d.ts.map +1 -0
- package/dist/dml/helpers/entity-builder/relationship-helpers.js +12 -0
- package/dist/dml/helpers/entity-builder/relationship-helpers.js.map +1 -0
- package/dist/dml/helpers/graphql-builder/get-attribute.js +2 -2
- package/dist/dml/helpers/graphql-builder/get-attribute.js.map +1 -1
- package/dist/dml/index.d.ts +1 -1
- package/dist/dml/index.d.ts.map +1 -1
- package/dist/dml/index.js +1 -1
- package/dist/dml/index.js.map +1 -1
- package/dist/dml/integration-tests/utils.js +1 -1
- package/dist/dml/integration-tests/utils.js.map +1 -1
- package/dist/dml/properties/autoincrement.d.ts +20 -1
- package/dist/dml/properties/autoincrement.d.ts.map +1 -1
- package/dist/dml/properties/autoincrement.js +19 -0
- package/dist/dml/properties/autoincrement.js.map +1 -1
- package/dist/dml/properties/number.d.ts +20 -1
- package/dist/dml/properties/number.d.ts.map +1 -1
- package/dist/dml/properties/number.js +19 -0
- package/dist/dml/properties/number.js.map +1 -1
- package/dist/event-bus/index.d.ts +1 -1
- package/dist/event-bus/index.d.ts.map +1 -1
- package/dist/event-bus/index.js +5 -6
- package/dist/event-bus/index.js.map +1 -1
- package/dist/event-bus/message-aggregator.js +1 -1
- package/dist/event-bus/message-aggregator.js.map +1 -1
- package/dist/feature-flags/eto-v2.d.ts +3 -0
- package/dist/feature-flags/eto-v2.d.ts.map +1 -0
- package/dist/feature-flags/eto-v2.js +10 -0
- package/dist/feature-flags/eto-v2.js.map +1 -0
- package/dist/feature-flags/many-to-many-inventory.d.ts +3 -0
- package/dist/feature-flags/many-to-many-inventory.d.ts.map +1 -0
- package/dist/feature-flags/many-to-many-inventory.js +10 -0
- package/dist/feature-flags/many-to-many-inventory.js.map +1 -0
- package/dist/feature-flags/order-editing.d.ts +3 -0
- package/dist/feature-flags/order-editing.d.ts.map +1 -0
- package/dist/feature-flags/order-editing.js +10 -0
- package/dist/feature-flags/order-editing.js.map +1 -0
- package/dist/feature-flags/product-categories.d.ts +3 -0
- package/dist/feature-flags/product-categories.d.ts.map +1 -0
- package/dist/feature-flags/product-categories.js +10 -0
- package/dist/feature-flags/product-categories.js.map +1 -0
- package/dist/feature-flags/sales-channels.d.ts +3 -0
- package/dist/feature-flags/sales-channels.d.ts.map +1 -0
- package/dist/feature-flags/sales-channels.js +10 -0
- package/dist/feature-flags/sales-channels.js.map +1 -0
- package/dist/feature-flags/tax-inclusive-pricing.d.ts +3 -0
- package/dist/feature-flags/tax-inclusive-pricing.d.ts.map +1 -0
- package/dist/feature-flags/tax-inclusive-pricing.js +10 -0
- package/dist/feature-flags/tax-inclusive-pricing.js.map +1 -0
- package/dist/file/abstract-file-provider.d.ts +70 -11
- package/dist/file/abstract-file-provider.d.ts.map +1 -1
- package/dist/file/abstract-file-provider.js +73 -11
- package/dist/file/abstract-file-provider.js.map +1 -1
- package/dist/graphql/graphql-to-ts-types.d.ts.map +1 -1
- package/dist/graphql/graphql-to-ts-types.js +23 -2
- package/dist/graphql/graphql-to-ts-types.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.d.ts +8 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +27 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/modules-sdk/build-query.d.ts.map +1 -1
- package/dist/modules-sdk/build-query.js +14 -13
- package/dist/modules-sdk/build-query.js.map +1 -1
- package/dist/modules-sdk/create-pg-connection.d.ts +2 -1
- package/dist/modules-sdk/create-pg-connection.d.ts.map +1 -1
- package/dist/modules-sdk/create-pg-connection.js +1 -1
- package/dist/modules-sdk/decorators/inject-manager.d.ts.map +1 -1
- package/dist/modules-sdk/decorators/inject-manager.js +6 -0
- package/dist/modules-sdk/decorators/inject-manager.js.map +1 -1
- package/dist/modules-sdk/decorators/inject-transaction-manager.js +5 -5
- package/dist/modules-sdk/decorators/inject-transaction-manager.js.map +1 -1
- package/dist/modules-sdk/define-link.d.ts +2 -0
- package/dist/modules-sdk/define-link.d.ts.map +1 -1
- package/dist/modules-sdk/define-link.js +16 -0
- package/dist/modules-sdk/define-link.js.map +1 -1
- package/dist/modules-sdk/definition.d.ts +9 -0
- package/dist/modules-sdk/definition.d.ts.map +1 -1
- package/dist/modules-sdk/definition.js +5 -2
- package/dist/modules-sdk/definition.js.map +1 -1
- package/dist/modules-sdk/eto-internal-service.d.ts.map +1 -1
- package/dist/modules-sdk/eto-internal-service.js +35 -37
- package/dist/modules-sdk/eto-internal-service.js.map +1 -1
- package/dist/modules-sdk/eto-service.d.ts.map +1 -1
- package/dist/modules-sdk/eto-service.js +25 -41
- package/dist/modules-sdk/eto-service.js.map +1 -1
- package/dist/modules-sdk/event-builder-factory.js +9 -9
- package/dist/modules-sdk/event-builder-factory.js.map +1 -1
- package/dist/modules-sdk/joiner-config-builder.js +1 -1
- package/dist/modules-sdk/joiner-config-builder.js.map +1 -1
- package/dist/modules-sdk/load-module-database-config.d.ts.map +1 -1
- package/dist/modules-sdk/load-module-database-config.js +3 -0
- package/dist/modules-sdk/load-module-database-config.js.map +1 -1
- package/dist/modules-sdk/loaders/mikro-orm-connection-loader.d.ts.map +1 -1
- package/dist/modules-sdk/loaders/mikro-orm-connection-loader.js +0 -7
- package/dist/modules-sdk/loaders/mikro-orm-connection-loader.js.map +1 -1
- package/dist/modules-sdk/migration-scripts/index.d.ts +1 -0
- package/dist/modules-sdk/migration-scripts/index.d.ts.map +1 -1
- package/dist/modules-sdk/migration-scripts/index.js +1 -0
- package/dist/modules-sdk/migration-scripts/index.js.map +1 -1
- package/dist/modules-sdk/migration-scripts/migration-down.js +2 -2
- package/dist/modules-sdk/migration-scripts/migration-down.js.map +1 -1
- package/dist/modules-sdk/migration-scripts/migration-generate.d.ts.map +1 -1
- package/dist/modules-sdk/migration-scripts/migration-generate.js +7 -3
- package/dist/modules-sdk/migration-scripts/migration-generate.js.map +1 -1
- package/dist/modules-sdk/migration-scripts/migration-up.js +2 -2
- package/dist/modules-sdk/migration-scripts/migration-up.js.map +1 -1
- package/dist/modules-sdk/migration-scripts/service-migration-generate.d.ts +7 -0
- package/dist/modules-sdk/migration-scripts/service-migration-generate.d.ts.map +1 -0
- package/dist/modules-sdk/migration-scripts/service-migration-generate.js +49 -0
- package/dist/modules-sdk/migration-scripts/service-migration-generate.js.map +1 -0
- package/dist/modules-sdk/mikro-orm-cli-config-builder.d.ts +0 -1
- package/dist/modules-sdk/mikro-orm-cli-config-builder.d.ts.map +1 -1
- package/dist/modules-sdk/mikro-orm-cli-config-builder.js +7 -6
- package/dist/modules-sdk/mikro-orm-cli-config-builder.js.map +1 -1
- package/dist/modules-sdk/module.d.ts.map +1 -1
- package/dist/modules-sdk/module.js +12 -14
- package/dist/modules-sdk/module.js.map +1 -1
- package/dist/modules-sdk/modules-to-container-types.d.ts.map +1 -1
- package/dist/modules-sdk/modules-to-container-types.js +30 -3
- package/dist/modules-sdk/modules-to-container-types.js.map +1 -1
- package/dist/modules-sdk/query-context.d.ts +2 -2
- package/dist/modules-sdk/query-context.d.ts.map +1 -1
- package/dist/modules-sdk/query-context.js.map +1 -1
- package/dist/modules-sdk/types/eto-service.d.ts +34 -10
- package/dist/modules-sdk/types/eto-service.d.ts.map +1 -1
- package/dist/notification/abstract-notification-provider.d.ts +10 -0
- package/dist/notification/abstract-notification-provider.d.ts.map +1 -1
- package/dist/notification/abstract-notification-provider.js.map +1 -1
- package/dist/payment/abstract-payment-provider.d.ts +253 -263
- package/dist/payment/abstract-payment-provider.d.ts.map +1 -1
- package/dist/payment/abstract-payment-provider.js +7 -15
- package/dist/payment/abstract-payment-provider.js.map +1 -1
- package/dist/payment/index.d.ts +0 -2
- package/dist/payment/index.d.ts.map +1 -1
- package/dist/payment/index.js +0 -2
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/payment-collection.d.ts +13 -1
- package/dist/payment/payment-collection.d.ts.map +1 -1
- package/dist/payment/payment-collection.js +12 -0
- package/dist/payment/payment-collection.js.map +1 -1
- package/dist/payment/webhook.d.ts +13 -1
- package/dist/payment/webhook.d.ts.map +1 -1
- package/dist/payment/webhook.js +13 -1
- package/dist/payment/webhook.js.map +1 -1
- package/dist/totals/big-number.d.ts +23 -0
- package/dist/totals/big-number.d.ts.map +1 -0
- package/dist/totals/big-number.js +115 -0
- package/dist/totals/big-number.js.map +1 -0
- package/dist/totals/create-raw-properties-from-bignumber.d.ts +5 -0
- package/dist/totals/create-raw-properties-from-bignumber.d.ts.map +1 -0
- package/dist/totals/create-raw-properties-from-bignumber.js +52 -0
- package/dist/totals/create-raw-properties-from-bignumber.js.map +1 -0
- package/dist/totals/index.d.ts +6 -0
- package/dist/totals/index.d.ts.map +1 -0
- package/dist/totals/index.js +22 -0
- package/dist/totals/index.js.map +1 -0
- package/dist/totals/math.d.ts +24 -0
- package/dist/totals/math.d.ts.map +1 -0
- package/dist/totals/math.js +106 -0
- package/dist/totals/math.js.map +1 -0
- package/dist/totals/transform-properties-to-bignumber.d.ts +6 -0
- package/dist/totals/transform-properties-to-bignumber.d.ts.map +1 -0
- package/dist/totals/transform-properties-to-bignumber.js +40 -0
- package/dist/totals/transform-properties-to-bignumber.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/dist/payment/get-smallest-unit.d.ts +0 -17
- package/dist/payment/get-smallest-unit.d.ts.map +0 -1
- package/dist/payment/get-smallest-unit.js +0 -68
- package/dist/payment/get-smallest-unit.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPaymentProvider, ProviderWebhookPayload, WebhookActionResult, CapturePaymentInput, CapturePaymentOutput, AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, InitiatePaymentInput, InitiatePaymentOutput, DeletePaymentInput, DeletePaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, UpdatePaymentInput, UpdatePaymentOutput } from "@etohq/types";
|
|
2
2
|
export declare abstract class AbstractPaymentProvider<TConfig = Record<string, unknown>> implements IPaymentProvider {
|
|
3
3
|
/**
|
|
4
4
|
* @ignore
|
|
@@ -10,11 +10,12 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
10
10
|
protected readonly container: Record<string, unknown>;
|
|
11
11
|
/**
|
|
12
12
|
* This method validates the options of the provider set in `eto-config.ts`.
|
|
13
|
-
* Implementing this method is optional
|
|
13
|
+
* Implementing this method is optional, but it's useful to ensure that the required
|
|
14
|
+
* options are passed to the provider, or if you have any custom validation logic.
|
|
14
15
|
*
|
|
15
16
|
* If the options aren't valid, throw an error.
|
|
16
17
|
*
|
|
17
|
-
* @param options - The provider's options.
|
|
18
|
+
* @param options - The provider's options passed in `eto-config.ts`.
|
|
18
19
|
*
|
|
19
20
|
* @example
|
|
20
21
|
* class MyPaymentProviderService extends AbstractPaymentProvider<Options> {
|
|
@@ -30,16 +31,18 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
30
31
|
*/
|
|
31
32
|
static validateOptions(options: Record<any, any>): void | never;
|
|
32
33
|
/**
|
|
33
|
-
* The constructor allows you to access resources from the [module's container](https://docs.etohq.com/learn/fundamentals/
|
|
34
|
+
* The constructor allows you to access resources from the [module's container](https://docs.etohq.com/learn/fundamentals/modules/container)
|
|
34
35
|
* using the first parameter, and the module's options using the second parameter.
|
|
35
36
|
*
|
|
37
|
+
* If you're creating a client or establishing a connection with a third-party service, do it in the constructor.
|
|
38
|
+
*
|
|
36
39
|
* :::note
|
|
37
40
|
*
|
|
38
41
|
* A module's options are passed when you register it in the Eto application.
|
|
39
42
|
*
|
|
40
43
|
* :::
|
|
41
44
|
*
|
|
42
|
-
* @param {Record<string, unknown>} cradle - The module's container
|
|
45
|
+
* @param {Record<string, unknown>} cradle - The module's container used to resolve resources.
|
|
43
46
|
* @param {Record<string, unknown>} config - The options passed to the Payment Module provider.
|
|
44
47
|
* @typeParam TConfig - The type of the provider's options passed as a second parameter.
|
|
45
48
|
*
|
|
@@ -111,75 +114,90 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
111
114
|
*/
|
|
112
115
|
getIdentifier(): string;
|
|
113
116
|
/**
|
|
114
|
-
* This method
|
|
117
|
+
* This method captures a payment using the third-party provider. In this method, use the third-party provider to capture the payment.
|
|
115
118
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* - A webhook event occurred that instructs the payment provider to capture the payment session. Learn more about handing webhook events in [this guide](https://docs.etohq.com/resources/commerce-modules/payment/webhook-events).
|
|
119
|
+
* When an order is placed, the payment is authorized using the {@link authorizePayment} method. Then, the admin
|
|
120
|
+
* user can capture the payment, which triggers this method.
|
|
119
121
|
*
|
|
120
|
-
*
|
|
122
|
+
* 
|
|
121
123
|
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
124
|
+
* This method can also be triggered by a webhook event if the {@link getWebhookActionAndData} method returns the action `captured`.
|
|
125
|
+
*
|
|
126
|
+
* #### Understanding `data` property
|
|
127
|
+
*
|
|
128
|
+
* The `data` property of the input parameter contains data that was previously stored in the Payment record's `data` property, which was
|
|
129
|
+
* returned by the {@link authorizePayment} method.
|
|
130
|
+
*
|
|
131
|
+
* The `data` property returned by this method is then stored in the `Payment` record. You can store data relevant to later refund or process the payment.
|
|
132
|
+
* For example, you can store the ID of the payment in the third-party provider to reference it later.
|
|
133
|
+
*
|
|
134
|
+
* 
|
|
135
|
+
*
|
|
136
|
+
* @param input - The input to capture the payment. The `data` field should contain the data from the payment provider. when the payment was created.
|
|
137
|
+
* @returns The new data to store in the payment's `data` property. Throws in case of an error.
|
|
125
138
|
*
|
|
126
139
|
* @example
|
|
127
140
|
* // other imports...
|
|
128
141
|
* import {
|
|
129
|
-
*
|
|
130
|
-
*
|
|
142
|
+
* CapturePaymentInput,
|
|
143
|
+
* CapturePaymentOutput,
|
|
131
144
|
* } from "@etohq/framework/types"
|
|
132
145
|
*
|
|
133
146
|
* class MyPaymentProviderService extends AbstractPaymentProvider<
|
|
134
147
|
* Options
|
|
135
148
|
* > {
|
|
136
149
|
* async capturePayment(
|
|
137
|
-
*
|
|
138
|
-
* ): Promise<
|
|
139
|
-
* const externalId =
|
|
150
|
+
* input: CapturePaymentInput
|
|
151
|
+
* ): Promise<CapturePaymentOutput> {
|
|
152
|
+
* const externalId = input.data?.id
|
|
140
153
|
*
|
|
141
|
-
* try {
|
|
142
154
|
* // assuming you have a client that captures the payment
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
155
|
+
* const newData = await this.client.capturePayment(externalId)
|
|
156
|
+
* return {
|
|
157
|
+
* data: {
|
|
146
158
|
* ...newData,
|
|
147
|
-
* id: externalId
|
|
148
|
-
* }
|
|
149
|
-
* } catch (e) {
|
|
150
|
-
* return {
|
|
151
|
-
* error: e,
|
|
152
|
-
* code: "unknown",
|
|
153
|
-
* detail: e
|
|
159
|
+
* id: externalId,
|
|
154
160
|
* }
|
|
155
161
|
* }
|
|
156
162
|
* }
|
|
157
|
-
*
|
|
158
163
|
* // ...
|
|
159
164
|
* }
|
|
160
165
|
*/
|
|
161
|
-
abstract capturePayment(
|
|
166
|
+
abstract capturePayment(input: CapturePaymentInput): Promise<CapturePaymentOutput>;
|
|
162
167
|
/**
|
|
163
|
-
* This method authorizes a payment session
|
|
164
|
-
* Module which can be later captured using the {@link capturePayment} method.
|
|
168
|
+
* This method authorizes a payment session using the third-party payment provider.
|
|
165
169
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
170
|
+
* During checkout, the customer may need to perform actions required by the payment provider,
|
|
171
|
+
* such as entering their card details or confirming the payment. Once that is done,
|
|
172
|
+
* the customer can place their order.
|
|
168
173
|
*
|
|
169
|
-
*
|
|
174
|
+
* During cart-completion before placing the order, this method is used to authorize the cart's payment session with the
|
|
175
|
+
* third-party payment provider. The payment can later be captured
|
|
176
|
+
* using the {@link capturePayment} method.
|
|
170
177
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
178
|
+
* 
|
|
179
|
+
*
|
|
180
|
+
* When authorized successfully, a `Payment` is created by the Payment
|
|
181
|
+
* Module, and it's associated with the order.
|
|
182
|
+
*
|
|
183
|
+
* #### Understanding `data` property
|
|
184
|
+
*
|
|
185
|
+
* The `data` property of the method's parameter contains the `PaymentSession` record's `data` property, which was
|
|
186
|
+
* returned by the {@link initiatePayment} method.
|
|
187
|
+
*
|
|
188
|
+
* The `data` property returned by this method is then stored in the created `Payment` record. You can store data relevant to later capture or process the payment.
|
|
189
|
+
* For example, you can store the ID of the payment in the third-party provider to reference it later.
|
|
190
|
+
*
|
|
191
|
+
* 
|
|
192
|
+
*
|
|
193
|
+
* @param input - The input to authorize the payment. The `data` field should contain the data from the payment provider. when the payment was created.
|
|
194
|
+
* @returns The status of the authorization, along with the `data` field about the payment. Throws in case of an error.
|
|
177
195
|
*
|
|
178
196
|
* @example
|
|
179
197
|
* // other imports...
|
|
180
198
|
* import {
|
|
181
|
-
*
|
|
182
|
-
*
|
|
199
|
+
* AuthorizePaymentInput,
|
|
200
|
+
* AuthorizePaymentOutput,
|
|
183
201
|
* PaymentSessionStatus
|
|
184
202
|
* } from "@etohq/framework/types"
|
|
185
203
|
*
|
|
@@ -188,55 +206,39 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
188
206
|
* Options
|
|
189
207
|
* > {
|
|
190
208
|
* async authorizePayment(
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* PaymentProviderError | {
|
|
195
|
-
* status: PaymentSessionStatus
|
|
196
|
-
* data: PaymentProviderSessionResponse["data"]
|
|
197
|
-
* }
|
|
198
|
-
* > {
|
|
199
|
-
* const externalId = paymentSessionData.id
|
|
209
|
+
* input: AuthorizePaymentInput
|
|
210
|
+
* ): Promise<AuthorizePaymentOutput> {
|
|
211
|
+
* const externalId = input.data?.id
|
|
200
212
|
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* const paymentData = await this.client.authorizePayment(externalId)
|
|
213
|
+
* // assuming you have a client that authorizes the payment
|
|
214
|
+
* const paymentData = await this.client.authorizePayment(externalId)
|
|
204
215
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* id: externalId
|
|
209
|
-
* },
|
|
210
|
-
* status: "authorized"
|
|
211
|
-
* }
|
|
212
|
-
* } catch (e) {
|
|
213
|
-
* return {
|
|
214
|
-
* error: e,
|
|
215
|
-
* code: "unknown",
|
|
216
|
-
* detail: e
|
|
217
|
-
* }
|
|
216
|
+
* return {
|
|
217
|
+
* data: paymentData,
|
|
218
|
+
* status: "authorized"
|
|
218
219
|
* }
|
|
219
220
|
* }
|
|
220
221
|
*
|
|
221
222
|
* // ...
|
|
222
223
|
* }
|
|
223
224
|
*/
|
|
224
|
-
abstract authorizePayment(
|
|
225
|
-
/**
|
|
226
|
-
* The new status of the payment.
|
|
227
|
-
*/
|
|
228
|
-
status: PaymentSessionStatus;
|
|
229
|
-
/**
|
|
230
|
-
* The data to store in the created payment's `data` property.
|
|
231
|
-
*/
|
|
232
|
-
data: PaymentProviderSessionResponse["data"];
|
|
233
|
-
}>;
|
|
225
|
+
abstract authorizePayment(input: AuthorizePaymentInput): Promise<AuthorizePaymentOutput>;
|
|
234
226
|
/**
|
|
235
|
-
* This method cancels a payment.
|
|
227
|
+
* This method cancels a payment in the third-party payment provider. It's used when
|
|
228
|
+
* the admin user cancels an order. The order can only be canceled if the payment
|
|
229
|
+
* is not captured yet.
|
|
230
|
+
*
|
|
231
|
+
* #### Understanding `data` property
|
|
232
|
+
*
|
|
233
|
+
* The `data` property of the method's parameter contains the `Payment` record's `data` property, which was
|
|
234
|
+
* returned by the {@link authorizePayment} method.
|
|
235
|
+
*
|
|
236
|
+
* The `data` property returned by this method is then stored in the `Payment` record. You can store data relevant for any further processing of the payment.
|
|
236
237
|
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* @
|
|
238
|
+
* 
|
|
239
|
+
*
|
|
240
|
+
* @param input - The input to cancel the payment. The `data` field should contain the data from the payment provider. when the payment was created.
|
|
241
|
+
* @returns The new data to store in the payment's `data` property, if any. Throws in case of an error.
|
|
240
242
|
*
|
|
241
243
|
* @example
|
|
242
244
|
* // other imports...
|
|
@@ -250,39 +252,51 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
250
252
|
* Options
|
|
251
253
|
* > {
|
|
252
254
|
* async cancelPayment(
|
|
253
|
-
*
|
|
254
|
-
* ): Promise<
|
|
255
|
-
* const externalId =
|
|
255
|
+
* input: CancelPaymentInput
|
|
256
|
+
* ): Promise<CancelPaymentOutput> {
|
|
257
|
+
* const externalId = input.data?.id
|
|
256
258
|
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
* } catch (e) {
|
|
261
|
-
* return {
|
|
262
|
-
* error: e,
|
|
263
|
-
* code: "unknown",
|
|
264
|
-
* detail: e
|
|
265
|
-
* }
|
|
266
|
-
* }
|
|
259
|
+
* // assuming you have a client that cancels the payment
|
|
260
|
+
* const paymentData = await this.client.cancelPayment(externalId)
|
|
261
|
+
* return { data: paymentData }
|
|
267
262
|
* }
|
|
268
263
|
*
|
|
269
264
|
* // ...
|
|
270
265
|
* }
|
|
271
266
|
*/
|
|
272
|
-
abstract cancelPayment(
|
|
267
|
+
abstract cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput>;
|
|
273
268
|
/**
|
|
274
|
-
* This method
|
|
275
|
-
*
|
|
269
|
+
* This method initializes a payment session with the third-party payment provider.
|
|
270
|
+
*
|
|
271
|
+
* When a customer chooses a payment method during checkout, this method is triggered to
|
|
272
|
+
* perform any initialization action with the third-party provider, such as creating a payment session.
|
|
273
|
+
*
|
|
274
|
+
* 
|
|
276
275
|
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
276
|
+
* #### Understanding `data` property
|
|
277
|
+
*
|
|
278
|
+
* The `data` property returned by this method will be stored in the created `PaymentSession` record. You can store data relevant to later authorize or process the payment.
|
|
279
|
+
* For example, you can store the ID of the payment session in the third-party provider to reference it later.
|
|
280
|
+
*
|
|
281
|
+
* The `data` property is also available to storefronts, allowing you to store data necessary for the storefront to integrate
|
|
282
|
+
* the payment provider in the checkout flow. For example, you can store the client token to use with the payment provider's SDK.
|
|
283
|
+
*
|
|
284
|
+
* :::note
|
|
285
|
+
*
|
|
286
|
+
* This also means you shouldn't store sensitive data and tokens in the `data` property, as it's publicly accessible.
|
|
287
|
+
*
|
|
288
|
+
* :::
|
|
289
|
+
*
|
|
290
|
+
* 
|
|
291
|
+
*
|
|
292
|
+
* @param input - The input to create the payment session.
|
|
293
|
+
* @returns The new data to store in the payment's `data` property. Throws in case of an error.
|
|
280
294
|
*
|
|
281
295
|
* @example
|
|
282
296
|
* // other imports...
|
|
283
297
|
* import {
|
|
284
|
-
*
|
|
285
|
-
*
|
|
298
|
+
* InitiatePaymentInput,
|
|
299
|
+
* InitiatePaymentOutput,
|
|
286
300
|
* } from "@etohq/framework/types"
|
|
287
301
|
*
|
|
288
302
|
*
|
|
@@ -290,53 +304,55 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
290
304
|
* Options
|
|
291
305
|
* > {
|
|
292
306
|
* async initiatePayment(
|
|
293
|
-
*
|
|
294
|
-
* ): Promise<
|
|
307
|
+
* input: InitiatePaymentInput
|
|
308
|
+
* ): Promise<InitiatePaymentOutput> {
|
|
295
309
|
* const {
|
|
296
310
|
* amount,
|
|
297
311
|
* currency_code,
|
|
298
312
|
* context: customerDetails
|
|
299
|
-
* } =
|
|
313
|
+
* } = input
|
|
300
314
|
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* )
|
|
315
|
+
* // assuming you have a client that initializes the payment
|
|
316
|
+
* const response = await this.client.init(
|
|
317
|
+
* amount, currency_code, customerDetails
|
|
318
|
+
* )
|
|
306
319
|
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
* id: response.id
|
|
311
|
-
* }
|
|
312
|
-
* }
|
|
313
|
-
* } catch (e) {
|
|
314
|
-
* return {
|
|
315
|
-
* error: e,
|
|
316
|
-
* code: "unknown",
|
|
317
|
-
* detail: e
|
|
318
|
-
* }
|
|
320
|
+
* return {
|
|
321
|
+
* id: response.id,
|
|
322
|
+
* data: response,
|
|
319
323
|
* }
|
|
320
324
|
* }
|
|
321
325
|
*
|
|
322
326
|
* // ...
|
|
323
327
|
* }
|
|
324
328
|
*/
|
|
325
|
-
abstract initiatePayment(
|
|
329
|
+
abstract initiatePayment(input: InitiatePaymentInput): Promise<InitiatePaymentOutput>;
|
|
326
330
|
/**
|
|
327
|
-
* This method
|
|
331
|
+
* This method deletes a payment session in the third-party payment provider.
|
|
332
|
+
*
|
|
333
|
+
* When a customer chooses a payment method during checkout, then chooses a different one,
|
|
334
|
+
* this method is triggered to delete the previous payment session.
|
|
335
|
+
*
|
|
336
|
+
* If your provider doesn't support deleting a payment session, you can just return an empty object or
|
|
337
|
+
* an object that contains the same received `data` property.
|
|
338
|
+
*
|
|
339
|
+
* 
|
|
328
340
|
*
|
|
329
|
-
*
|
|
341
|
+
* #### Understanding `data` property
|
|
330
342
|
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
343
|
+
* The `data` property of the method's parameter contains the `PaymentSession` record's `data` property, which was
|
|
344
|
+
* returned by the {@link initiatePayment} method.
|
|
345
|
+
*
|
|
346
|
+
* 
|
|
347
|
+
*
|
|
348
|
+
* @param input - The input to delete the payment session. The `data` field should contain the data from the payment provider. when the payment was created.
|
|
349
|
+
* @returns The new data to store in the payment's `data` property, if any. Throws in case of an error.
|
|
334
350
|
*
|
|
335
351
|
* @example
|
|
336
352
|
* // other imports...
|
|
337
353
|
* import {
|
|
338
|
-
*
|
|
339
|
-
*
|
|
354
|
+
* DeletePaymentInput,
|
|
355
|
+
* DeletePaymentOutput,
|
|
340
356
|
* } from "@etohq/framework/types"
|
|
341
357
|
*
|
|
342
358
|
*
|
|
@@ -344,38 +360,32 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
344
360
|
* Options
|
|
345
361
|
* > {
|
|
346
362
|
* async deletePayment(
|
|
347
|
-
*
|
|
348
|
-
* ): Promise<
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* await this.client.cancelPayment(externalId)
|
|
356
|
-
* } catch (e) {
|
|
357
|
-
* return {
|
|
358
|
-
* error: e,
|
|
359
|
-
* code: "unknown",
|
|
360
|
-
* detail: e
|
|
361
|
-
* }
|
|
363
|
+
* input: DeletePaymentInput
|
|
364
|
+
* ): Promise<DeletePaymentOutput> {
|
|
365
|
+
* const externalId = input.data?.id
|
|
366
|
+
*
|
|
367
|
+
* // assuming you have a client that cancels the payment
|
|
368
|
+
* await this.client.cancelPayment(externalId)
|
|
369
|
+
* return {
|
|
370
|
+
* data: input.data
|
|
362
371
|
* }
|
|
363
372
|
* }
|
|
364
373
|
*
|
|
365
374
|
* // ...
|
|
366
375
|
* }
|
|
367
376
|
*/
|
|
368
|
-
abstract deletePayment(
|
|
377
|
+
abstract deletePayment(input: DeletePaymentInput): Promise<DeletePaymentOutput>;
|
|
369
378
|
/**
|
|
370
379
|
* This method gets the status of a payment session based on the status in the third-party integration.
|
|
371
380
|
*
|
|
372
|
-
* @param
|
|
373
|
-
*
|
|
374
|
-
* @returns The payment session's status.
|
|
381
|
+
* @param input - The input to get the payment status. The `data` field should contain the data from the payment provider. when the payment was created.
|
|
382
|
+
* @returns The payment session's status. It can also return additional `data` from the payment provider.
|
|
375
383
|
*
|
|
376
384
|
* @example
|
|
377
385
|
* // other imports...
|
|
378
386
|
* import {
|
|
387
|
+
* GetPaymentStatusInput,
|
|
388
|
+
* GetPaymentStatusOutput,
|
|
379
389
|
* PaymentSessionStatus
|
|
380
390
|
* } from "@etohq/framework/types"
|
|
381
391
|
*
|
|
@@ -384,46 +394,58 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
384
394
|
* Options
|
|
385
395
|
* > {
|
|
386
396
|
* async getPaymentStatus(
|
|
387
|
-
*
|
|
388
|
-
* ): Promise<
|
|
389
|
-
* const externalId =
|
|
397
|
+
* input: GetPaymentStatusInput
|
|
398
|
+
* ): Promise<GetPaymentStatusOutput> {
|
|
399
|
+
* const externalId = input.data?.id
|
|
390
400
|
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* const status = await this.client.getStatus(externalId)
|
|
401
|
+
* // assuming you have a client that retrieves the payment status
|
|
402
|
+
* const status = await this.client.getStatus(externalId)
|
|
394
403
|
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
* return "authorized"
|
|
404
|
+
* switch (status) {
|
|
405
|
+
* case "requires_capture":
|
|
406
|
+
* return {status: "authorized"}
|
|
398
407
|
* case "success":
|
|
399
|
-
* return "captured"
|
|
408
|
+
* return {status: "captured"}
|
|
400
409
|
* case "canceled":
|
|
401
|
-
* return "canceled"
|
|
410
|
+
* return {status: "canceled"}
|
|
402
411
|
* default:
|
|
403
|
-
* return "pending"
|
|
404
|
-
*
|
|
405
|
-
* } catch (e) {
|
|
406
|
-
* return "error"
|
|
407
|
-
* }
|
|
412
|
+
* return {status: "pending"}
|
|
413
|
+
* }
|
|
408
414
|
* }
|
|
409
415
|
*
|
|
410
416
|
* // ...
|
|
411
417
|
* }
|
|
412
418
|
*/
|
|
413
|
-
abstract getPaymentStatus(
|
|
419
|
+
abstract getPaymentStatus(input: GetPaymentStatusInput): Promise<GetPaymentStatusOutput>;
|
|
414
420
|
/**
|
|
415
|
-
* This method refunds an amount
|
|
421
|
+
* This method refunds an amount using the third-party payment provider. This method
|
|
422
|
+
* is triggered when the admin user refunds a payment of an order.
|
|
423
|
+
*
|
|
424
|
+
* #### Understanding `data` property
|
|
425
|
+
*
|
|
426
|
+
* The `data` property of the method's parameter contains the `Payment` record's `data` property, which was
|
|
427
|
+
* returned by the {@link capturePayment} or {@link refundPayment} method.
|
|
428
|
+
*
|
|
429
|
+
* The `data` property returned by this method is then stored in the `Payment` record. You can store data relevant to later refund or process the payment.
|
|
430
|
+
* For example, you can store the ID of the payment in the third-party provider to reference it later.
|
|
416
431
|
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
432
|
+
* :::note
|
|
433
|
+
*
|
|
434
|
+
* A payment may be refunded multiple times with different amounts. In this case, the `data` property
|
|
435
|
+
* of the input parameter contains the data from the last refund.
|
|
436
|
+
*
|
|
437
|
+
* :::
|
|
438
|
+
*
|
|
439
|
+
* 
|
|
440
|
+
*
|
|
441
|
+
* @param input - The input to refund the payment. The `data` field should contain the data from the payment provider. when the payment was created.
|
|
420
442
|
* @returns The new data to store in the payment's `data` property, or an error object.
|
|
421
443
|
*
|
|
422
444
|
* @example
|
|
423
445
|
* // other imports...
|
|
424
446
|
* import {
|
|
425
|
-
*
|
|
426
|
-
*
|
|
447
|
+
* RefundPaymentInput,
|
|
448
|
+
* RefundPaymentOutput,
|
|
427
449
|
* } from "@etohq/framework/types"
|
|
428
450
|
*
|
|
429
451
|
*
|
|
@@ -431,49 +453,35 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
431
453
|
* Options
|
|
432
454
|
* > {
|
|
433
455
|
* async refundPayment(
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
* PaymentProviderError | PaymentProviderSessionResponse["data"]
|
|
438
|
-
* > {
|
|
439
|
-
* const externalId = paymentData.id
|
|
456
|
+
* input: RefundPaymentInput
|
|
457
|
+
* ): Promise<RefundPaymentOutput> {
|
|
458
|
+
* const externalId = input.data?.id
|
|
440
459
|
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
* const newData = await this.client.refund(
|
|
460
|
+
* // assuming you have a client that refunds the payment
|
|
461
|
+
* const newData = await this.client.refund(
|
|
444
462
|
* externalId,
|
|
445
|
-
*
|
|
463
|
+
* input.amount
|
|
446
464
|
* )
|
|
447
465
|
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
* id: externalId
|
|
451
|
-
* }
|
|
452
|
-
* } catch (e) {
|
|
453
|
-
* return {
|
|
454
|
-
* error: e,
|
|
455
|
-
* code: "unknown",
|
|
456
|
-
* detail: e
|
|
457
|
-
* }
|
|
466
|
+
* return {
|
|
467
|
+
* data: input.data,
|
|
458
468
|
* }
|
|
459
469
|
* }
|
|
460
|
-
*
|
|
461
470
|
* // ...
|
|
462
471
|
* }
|
|
463
472
|
*/
|
|
464
|
-
abstract refundPayment(
|
|
473
|
+
abstract refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput>;
|
|
465
474
|
/**
|
|
466
|
-
*
|
|
475
|
+
* This method retrieves the payment's data from the third-party payment provider.
|
|
467
476
|
*
|
|
468
|
-
* @param
|
|
469
|
-
*
|
|
470
|
-
* @returns An object to be stored in the payment's `data` property, or an error object.
|
|
477
|
+
* @param input - The input to retrieve the payment. The `data` field should contain the data from the payment provider when the payment was created.
|
|
478
|
+
* @returns The payment's data as found in the the payment provider.
|
|
471
479
|
*
|
|
472
480
|
* @example
|
|
473
481
|
* // other imports...
|
|
474
482
|
* import {
|
|
475
|
-
*
|
|
476
|
-
*
|
|
483
|
+
* RetrievePaymentInput,
|
|
484
|
+
* RetrievePaymentOutput,
|
|
477
485
|
* } from "@etohq/framework/types"
|
|
478
486
|
*
|
|
479
487
|
*
|
|
@@ -481,41 +489,28 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
481
489
|
* Options
|
|
482
490
|
* > {
|
|
483
491
|
* async retrievePayment(
|
|
484
|
-
*
|
|
485
|
-
* ): Promise<
|
|
486
|
-
*
|
|
487
|
-
* > {
|
|
488
|
-
* const externalId = paymentSessionData.id
|
|
492
|
+
* input: RetrievePaymentInput
|
|
493
|
+
* ): Promise<RetrievePaymentOutput> {
|
|
494
|
+
* const externalId = input.data?.id
|
|
489
495
|
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
* return await this.client.retrieve(externalId)
|
|
493
|
-
* } catch (e) {
|
|
494
|
-
* return {
|
|
495
|
-
* error: e,
|
|
496
|
-
* code: "unknown",
|
|
497
|
-
* detail: e
|
|
498
|
-
* }
|
|
499
|
-
* }
|
|
496
|
+
* // assuming you have a client that retrieves the payment
|
|
497
|
+
* return await this.client.retrieve(externalId)
|
|
500
498
|
* }
|
|
501
|
-
*
|
|
502
499
|
* // ...
|
|
503
500
|
* }
|
|
504
501
|
*/
|
|
505
|
-
abstract retrievePayment(
|
|
502
|
+
abstract retrievePayment(input: RetrievePaymentInput): Promise<RetrievePaymentOutput>;
|
|
506
503
|
/**
|
|
507
|
-
*
|
|
504
|
+
* This method updates a payment in the third-party service that was previously initiated with the {@link initiatePayment} method.
|
|
508
505
|
*
|
|
509
|
-
* @param
|
|
510
|
-
* @returns
|
|
511
|
-
* object. Make sure to set in `data` anything useful to later retrieve the session.
|
|
506
|
+
* @param input - The input to update the payment. The `data` field should contain the data from the payment provider. when the payment was created.
|
|
507
|
+
* @returns The new data to store in the payment's `data` property. Throws in case of an error.
|
|
512
508
|
*
|
|
513
509
|
* @example
|
|
514
510
|
* // other imports...
|
|
515
511
|
* import {
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
* PaymentProviderSessionResponse,
|
|
512
|
+
* UpdatePaymentInput,
|
|
513
|
+
* UpdatePaymentOutput,
|
|
519
514
|
* } from "@etohq/framework/types"
|
|
520
515
|
*
|
|
521
516
|
*
|
|
@@ -523,55 +518,44 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
523
518
|
* Options
|
|
524
519
|
* > {
|
|
525
520
|
* async updatePayment(
|
|
526
|
-
*
|
|
527
|
-
* ): Promise<
|
|
528
|
-
* const {
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
521
|
+
* input: UpdatePaymentInput
|
|
522
|
+
* ): Promise<UpdatePaymentOutput> {
|
|
523
|
+
* const { amount, currency_code, context } = input
|
|
524
|
+
* const externalId = input.data?.id
|
|
525
|
+
*
|
|
526
|
+
* // Validate context.customer
|
|
527
|
+
* if (!context || !context.customer) {
|
|
528
|
+
* throw new Error("Context must include a valid customer.");
|
|
529
|
+
* }
|
|
535
530
|
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
* externalId,
|
|
531
|
+
* // assuming you have a client that updates the payment
|
|
532
|
+
* const response = await this.client.update(
|
|
533
|
+
* externalId,
|
|
540
534
|
* {
|
|
541
535
|
* amount,
|
|
542
536
|
* currency_code,
|
|
543
|
-
*
|
|
537
|
+
* customer: context.customer
|
|
544
538
|
* }
|
|
545
539
|
* )
|
|
546
540
|
*
|
|
547
|
-
*
|
|
548
|
-
* ...response,
|
|
549
|
-
* data: {
|
|
550
|
-
* id: response.id
|
|
551
|
-
* }
|
|
552
|
-
* }
|
|
553
|
-
* } catch (e) {
|
|
554
|
-
* return {
|
|
555
|
-
* error: e,
|
|
556
|
-
* code: "unknown",
|
|
557
|
-
* detail: e
|
|
558
|
-
* }
|
|
559
|
-
* }
|
|
541
|
+
* return response
|
|
560
542
|
* }
|
|
561
543
|
*
|
|
562
544
|
* // ...
|
|
563
545
|
* }
|
|
564
546
|
*/
|
|
565
|
-
abstract updatePayment(
|
|
547
|
+
abstract updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput>;
|
|
566
548
|
/**
|
|
567
|
-
* This method is executed when a webhook event is received from the third-party payment provider.
|
|
568
|
-
* to
|
|
549
|
+
* This method is executed when a webhook event is received from the third-party payment provider. Eto uses
|
|
550
|
+
* the data returned by this method to perform actions in the Eto application, such as completing the associated cart
|
|
551
|
+
* if the payment was authorized successfully.
|
|
569
552
|
*
|
|
570
|
-
* Learn more in [
|
|
553
|
+
* Learn more in the [Webhook Events](https://docs.etohq.com/resources/commerce-modules/payment/webhook-events) documentation.
|
|
571
554
|
*
|
|
572
555
|
* @param data - The webhook event's data
|
|
573
556
|
* @returns The webhook result. If the `action`'s value is `captured`, the payment is captured within Eto as well.
|
|
574
|
-
* If the `action`'s value is `authorized`, the associated payment session is authorized within Eto
|
|
557
|
+
* If the `action`'s value is `authorized`, the associated payment session is authorized within Eto and the associated cart
|
|
558
|
+
* will be completed to create an order.
|
|
575
559
|
*
|
|
576
560
|
* @example
|
|
577
561
|
* // other imports...
|
|
@@ -602,6 +586,8 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
602
586
|
* return {
|
|
603
587
|
* action: "authorized",
|
|
604
588
|
* data: {
|
|
589
|
+
* // assuming the session_id is stored in the metadata of the payment
|
|
590
|
+
* // in the third-party provider
|
|
605
591
|
* session_id: (data.metadata as Record<string, any>).session_id,
|
|
606
592
|
* amount: new BigNumber(data.amount as number)
|
|
607
593
|
* }
|
|
@@ -610,19 +596,27 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
610
596
|
* return {
|
|
611
597
|
* action: "captured",
|
|
612
598
|
* data: {
|
|
599
|
+
* // assuming the session_id is stored in the metadata of the payment
|
|
600
|
+
* // in the third-party provider
|
|
613
601
|
* session_id: (data.metadata as Record<string, any>).session_id,
|
|
614
602
|
* amount: new BigNumber(data.amount as number)
|
|
615
603
|
* }
|
|
616
604
|
* }
|
|
617
605
|
* default:
|
|
618
606
|
* return {
|
|
619
|
-
* action: "not_supported"
|
|
607
|
+
* action: "not_supported",
|
|
608
|
+
* data: {
|
|
609
|
+
* session_id: "",
|
|
610
|
+
* amount: new BigNumber(0)
|
|
611
|
+
* }
|
|
620
612
|
* }
|
|
621
613
|
* }
|
|
622
614
|
* } catch (e) {
|
|
623
615
|
* return {
|
|
624
616
|
* action: "failed",
|
|
625
617
|
* data: {
|
|
618
|
+
* // assuming the session_id is stored in the metadata of the payment
|
|
619
|
+
* // in the third-party provider
|
|
626
620
|
* session_id: (data.metadata as Record<string, any>).session_id,
|
|
627
621
|
* amount: new BigNumber(data.amount as number)
|
|
628
622
|
* }
|
|
@@ -635,8 +629,4 @@ export declare abstract class AbstractPaymentProvider<TConfig = Record<string, u
|
|
|
635
629
|
*/
|
|
636
630
|
abstract getWebhookActionAndData(data: ProviderWebhookPayload["payload"]): Promise<WebhookActionResult>;
|
|
637
631
|
}
|
|
638
|
-
/**
|
|
639
|
-
* @ignore
|
|
640
|
-
*/
|
|
641
|
-
export declare function isPaymentProviderError(obj: any): obj is PaymentProviderError;
|
|
642
632
|
//# sourceMappingURL=abstract-payment-provider.d.ts.map
|