From 68d8d46a6270165700b01548ad8474c668cbf7e0 Mon Sep 17 00:00:00 2001 From: Douglas Eggleton Date: Wed, 17 Jan 2024 15:38:30 +0000 Subject: [PATCH] feat(option-labels): add custom option labels (#188) * feat(option-labels): add custom option labels * chore: update trivy package --- packages/embed-react/README.md | 3 ++- packages/embed/README.md | 3 ++- packages/embed/src/index.ts | 1 + packages/embed/src/types.ts | 1 + packages/embed/src/validation.ts | 7 +++++++ yarn.lock | 13 ++++--------- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/embed-react/README.md b/packages/embed-react/README.md index d740c736..d6f465d5 100644 --- a/packages/embed-react/README.md +++ b/packages/embed-react/README.md @@ -88,7 +88,8 @@ The options for this integration are as follows. | `onBeforeTransaction` | `null` | An optional callback hook is called right before a transaction is created. It allows you to change the `metadata`, `externalIdentifier` and `shippingDetailsId` right before a transaction request. This callback should return a promise. | | `showDeleteButton` | `false` | An optional boolean which controls the display of the delete button on stored payment methods, so that buyers can delete them. | | `merchantAccountId` | `default` | An optional merchant account ID. | -| `excludedMethods` | `null` | An optional list of methods to be excluded. | +| `excludedMethods` | `null` | An optional list of methods to be excluded. | +| `optionLabels` | `Object` | An optional object map of payment option labels | ### Events diff --git a/packages/embed/README.md b/packages/embed/README.md index 8722ad5f..86c93712 100644 --- a/packages/embed/README.md +++ b/packages/embed/README.md @@ -99,7 +99,8 @@ The options for this integration are as follows. | `antiFraudFingerprint` | `string` | An optional string to use as the device fingerprint. Leave unset to opt-in to Gr4vy's automatic anti-fraud functionality. | | `enableAnimations` | `false` | An optional boolean to turn on animations. | | `separatePaymentOptions` | `false` | An optional boolean to separate payment options. | -| `excludedMethods` | `null` | An optional list of methods to be excluded. | +| `excludedMethods` | `null` | An optional list of methods to be excluded. | +| `optionLabels` | `Object` | An optional object map of payment option labels | ### Theming diff --git a/packages/embed/src/index.ts b/packages/embed/src/index.ts index 58e947dd..7088ac93 100644 --- a/packages/embed/src/index.ts +++ b/packages/embed/src/index.ts @@ -59,6 +59,7 @@ export const optionKeys = [ 'enableAnimations', 'separatePaymentOptions', 'excludedMethods', + 'optionLabels', ] // Map of cleanup callbacks diff --git a/packages/embed/src/types.ts b/packages/embed/src/types.ts index 730b02ad..3e93b6ea 100644 --- a/packages/embed/src/types.ts +++ b/packages/embed/src/types.ts @@ -53,6 +53,7 @@ export type Config = { enableAnimations?: boolean separatePaymentOptions?: boolean excludedMethods?: Array + optionLabels?: Record } export type BillingAddressFields = { diff --git a/packages/embed/src/validation.ts b/packages/embed/src/validation.ts index ae9094dc..b392cb71 100644 --- a/packages/embed/src/validation.ts +++ b/packages/embed/src/validation.ts @@ -476,4 +476,11 @@ export const validate = (options: SetupConfig) => message: 'must be a array', required: false, type: 'object', + }) && + validateType({ + argument: 'optionLabels', + value: options.optionLabels, + type: 'object', + message: 'must be an object', + required: false, }) diff --git a/yarn.lock b/yarn.lock index c2c94cdc..84130535 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8249,15 +8249,10 @@ flow-parser@0.*: resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.221.0.tgz#e11d7b7d19fb4ce08c3e54461476af4111a62fd0" integrity sha512-i+GzdLcKYy5bxhx1N+FIcR1bTqssuVWTJcuytMhwqLAxifz46g4BSNicWXGrtzT0HibJUBIzZOYA3FveJucTPg== -follow-redirects@^1.0.0: - version "1.14.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== - -follow-redirects@^1.15.0: - version "1.15.3" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" - integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== +follow-redirects@^1.0.0, follow-redirects@^1.15.0: + version "1.15.5" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020" + integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw== for-each@^0.3.3: version "0.3.3"