From 2729c1ac018f2a6cae2e577de7027faec7675c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Fri, 3 Apr 2020 22:12:28 +0200 Subject: [PATCH] fix(braintree-web): add missing propertes to factory methods (#43433) * fix(braintree-web): add missing propertes to factory methods - `authorization` - `version` https://braintree.github.io/braintree-web/current/module-braintree-web_hosted-fields.html#.create https://braintree.github.io/braintree-web/current/module-braintree-web_three-d-secure.html#.create /cc @jbojcic1 Thanks! Fixes: #43346 * Add missing `authorization` option as per PR comment --- types/braintree-web/index.d.ts | 10 +++++---- types/braintree-web/test/node.ts | 36 ++++++++++++++++++++++++++++++++ types/braintree-web/test/web.ts | 36 ++++++++++++++++++++++++++++++++ types/braintree-web/tslint.json | 3 ++- 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/types/braintree-web/index.d.ts b/types/braintree-web/index.d.ts index f99e11883b..bd6544f735 100644 --- a/types/braintree-web/index.d.ts +++ b/types/braintree-web/index.d.ts @@ -653,6 +653,7 @@ declare namespace braintree { * @function create * @param {object} options Creation options: * @param {Client} options.client A {@link Client} instance. + * @param {string} options.authorization A tokenizationKey or clientToken. Can be used in place of `options.client`. * @param {fieldOptions} options.fields A {@link module:braintree-web/hosted-fields~fieldOptions set of options for each field}. * @param {styleOptions} options.styles {@link module:braintree-web/hosted-fields~styleOptions Styles} applied to each field. * @param {callback} callback The second argument, `data`, is the {@link HostedFields} instance. @@ -685,8 +686,8 @@ declare namespace braintree { * } * }, callback); */ - create(options: { client: Client, fields: HostedFieldFieldOptions, styles?: any }): Promise; - create(options: { client: Client, fields: HostedFieldFieldOptions, styles?: any }, callback: callback): void; + create(options: { client?: Client, authorization?: string, fields: HostedFieldFieldOptions, styles?: any }): Promise; + create(options: { client?: Client, authorization?: string, fields: HostedFieldFieldOptions, styles?: any }, callback: callback): void; /** @@ -1154,6 +1155,7 @@ declare namespace braintree { * @static * @function create * @param {object} options Creation options: + * @param {string} [options.authorization] A tokenizationKey or clientToken. Can be used in place of `options.client`. * @param {Version} options.version=1 The version of 3DS to use. Pass in 2 to use 3DS 2.0. * @param {Client} options.client A {@link Client} instance. * @param {callback} callback The second argument, `data`, is the {@link ThreeDSecure} instance. @@ -1165,8 +1167,8 @@ declare namespace braintree { */ create(options: { client: Client }): Promise; create(options: { client: Client }, callback: callback): void; - create(options: { version: number, client: Client }): Promise; - create(options: { version: number, client: Client }, callback: callback): void; + create(options: { authorization?: string, version?: 1 | '1' | 2 | '2' | '2-bootstrap3-modal' | '2-inline-iframe', client?: Client }): Promise; + create(options: { authorization?: string, version?: 1 | '1' | 2 | '2' | '2-bootstrap3-modal' | '2-inline-iframe', client?: Client }, callback: callback): void; /** * @description The current version of the SDK, i.e. `3.0.2`. diff --git a/types/braintree-web/test/node.ts b/types/braintree-web/test/node.ts index 2f4b2a9f93..8bf2fbfef1 100644 --- a/types/braintree-web/test/node.ts +++ b/types/braintree-web/test/node.ts @@ -47,6 +47,7 @@ braintree.client.create({ braintree.hostedFields.create({ client: clientInstance, + authorization: clientToken, styles: { 'input': { 'font-size': '16pt', @@ -409,6 +410,41 @@ braintree.client.create({ let existingNonce = "fake-valid-nonce"; let submitNonceToServer: (nonce: string) => void; +braintree.client.create( + { + authorization: clientToken, + }, + (error: braintree.BraintreeError, clientInstance: braintree.Client) => { + braintree.threeDSecure.create( + { + client: clientInstance, + version: '2', + }, + (createError, threeDSecure) => { + // implementation + }, + ); + braintree.threeDSecure.create( + { + client: clientInstance, + version: 1, + }, + (createError, threeDSecure) => { + // implementation + }, + ); + braintree.threeDSecure.create( + { + client: clientInstance, + version: '2-bootstrap3-modal', + }, + (createError, threeDSecure) => { + // implementation + }, + ); + }, +); + braintree.threeDSecure.verifyCard({ nonce: existingNonce, amount: 123.45, // $ExpectType number diff --git a/types/braintree-web/test/web.ts b/types/braintree-web/test/web.ts index ee1aa9ef45..2e181adf8d 100644 --- a/types/braintree-web/test/web.ts +++ b/types/braintree-web/test/web.ts @@ -48,6 +48,7 @@ braintree.client.create({ braintree.hostedFields.create({ client: clientInstance, + authorization: clientToken, styles: { 'input': { 'font-size': '16pt', @@ -410,6 +411,41 @@ braintree.client.create({ let existingNonce = "fake-valid-nonce"; let submitNonceToServer: (nonce: string) => void; +braintree.client.create( + { + authorization: clientToken, + }, + (error: braintree.BraintreeError, clientInstance: braintree.Client) => { + braintree.threeDSecure.create( + { + client: clientInstance, + version: '2', + }, + (createError, threeDSecure) => { + // implementation + }, + ); + braintree.threeDSecure.create( + { + client: clientInstance, + version: 1, + }, + (createError, threeDSecure) => { + // implementation + }, + ); + braintree.threeDSecure.create( + { + client: clientInstance, + version: '2-bootstrap3-modal', + }, + (createError, threeDSecure) => { + // implementation + }, + ); + }, +); + braintree.threeDSecure.verifyCard({ nonce: existingNonce, amount: 123.45, // $ExpectType number diff --git a/types/braintree-web/tslint.json b/types/braintree-web/tslint.json index 181c9a1e64..b85d2acc3d 100644 --- a/types/braintree-web/tslint.json +++ b/types/braintree-web/tslint.json @@ -13,6 +13,7 @@ "no-mergeable-namespace": false, "no-padding": false, "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, "no-unnecessary-qualifier": false, "no-unnecessary-type-assertion": false, "no-var-keyword": false, @@ -27,4 +28,4 @@ "trim-file": false, "unified-signatures": false } -} \ No newline at end of file +}