🤖 Merge PR #49658 [@types/braintree-web] Add some missing methods and properties from update to 3.69 by @murphybob

* [@types/braintree-web] Add teardown method to Client instance

* [@types/braintree-web] Update selector -> container in hosted fields field

* [@types/braintree-web] Expand three d secure card verification origins

* [@types/braintree-web] Add 'inputSubmitRequest' hosted fields event type

Co-authored-by: Rob Murphy <rob.murphy@wegift.io>
This commit is contained in:
Rob Murphy
2020-12-15 16:37:22 +00:00
committed by GitHub
parent 70cd3a77f8
commit 1add3c2d7f
6 changed files with 125 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
// Type definitions for Braintree-web 3.62
// Type definitions for Braintree-web 3.69
// Project: https://github.com/braintree/braintree-web
// Definitions by: Guy Shahine <https://github.com/chlela>
// Jason Buckner <https://github.com/jbuckner>

View File

@@ -96,4 +96,17 @@ export interface Client {
* });
*/
request(options: { method: string; endpoint: string; data: any; timeout?: number }, callback: callback): void;
/**
* Cleanly tear down anything set up by {@link Client#getConfiguration|create}.
* @param [callback] Called once teardown is complete. No data is returned if teardown completes successfully.
* @example
* clientInstance.teardown();
* @example <caption>With callback</caption>
* clientInstance.teardown(function () {
* // teardown is complete
* });
* @returns Returns a promise if no callback is provided.
*/
teardown(callback: callback<void>): Promise<void>;
}

View File

@@ -17,7 +17,11 @@ export interface HostedFieldsFieldMaskInput {
* Fields used in {@link module:braintree-web/hosted-fields~fieldOptions fields options}
*/
export interface HostedFieldsField {
selector: string;
/**
* @deprecated Now an alias for `container`.
*/
selector?: string;
container?: string | HTMLElement;
placeholder?: string;
type?: string;
formatInput?: boolean;
@@ -124,7 +128,8 @@ export interface HostedFieldsStateObject {
fields: HostedFieldsFieldDataFields;
}
export type HostedFieldEventType = 'blur' | 'focus' | 'empty' | 'notEmpty' | 'cardTypeChange' | 'validityChange';
export type HostedFieldEventType = 'blur' | 'focus' | 'empty' | 'notEmpty'
| 'cardTypeChange' | 'validityChange' | 'inputSubmitRequest';
export interface HostedFieldsAccountDetails {
bin: string;

View File

@@ -14,6 +14,98 @@ export interface ThreeDSecureVerifyPayload {
liabilityShifted: boolean;
}
export interface ThreeDSecureBillingAddress {
givenName?: string;
surname?: string;
phoneNumber?: string;
streetAddress?: string;
extendedAddress?: string;
line3?: string;
locality?: string;
region?: string;
postalCode?: string;
countryCodeAlpha2?: string;
}
export interface ThreeDSecureShippingAddress {
streetAddress: string;
extendedAddress: string;
line3: string;
locality: string;
region: string;
postalCode: string;
countryCodeAlpha2: string;
}
export interface ThreeDSecureAdditionalInformation {
workPhoneNumber?: string;
shippingGivenName?: string;
shippingSurname?: string;
shippingAddress?: ThreeDSecureShippingAddress;
streetAddress?: string;
extendedAddress?: string;
line3?: string;
locality?: string;
region?: string;
postalCode?: string;
countryCodeAlpha2?: string;
shippingPhone?: string;
shippingMethod?: string;
shippingMethodIndicator?: string;
productCode?: string;
deliveryTimeframe?: string;
deliveryEmail?: string;
reorderindicator?: string;
preorderIndicator?: string;
preorderDate?: string;
giftCardAmount?: string;
giftCardCurrencyCode?: string;
giftCardCount?: string;
accountAgeIndicator?: string;
accountCreateDate?: string;
accountChangeIndicator?: string;
accountChangeDate?: string;
accountPwdChangeIndicator?: string;
accountPwdChangeDate?: string;
shippingAddressUsageIndicator?: string;
shippingAddressUsageDate?: string;
transactionCountDay?: string;
transactionCountYear?: string;
addCardAttempts?: string;
accountPurchases?: string;
fraudActivity?: string;
shippingNameIndicator?: string;
paymentAccountIndicator?: string;
paymentAccountAge?: string;
acsWindowSize?: string;
sdkMaxTimeout?: string;
addressMatch?: string;
accountId?: string;
ipAddress?: string;
orderDescription?: string;
taxAmount?: string;
userAgent?: string;
authenticationIndicator?: string;
installment?: string;
purchaseDate?: string;
recurringEnd?: string;
recurringFrequency?: string;
}
export interface ThreeDSecureVerifyOptions {
nonce: string;
amount: number;
bin: string;
challengeRequested?: boolean;
exemptionRequested?: boolean;
email?: string;
mobilePhoneNumber?: string;
billingAddress?: ThreeDSecureBillingAddress;
additionalInformation?: ThreeDSecureAdditionalInformation;
addFrame: (err?: BraintreeError, iframe?: HTMLIFrameElement) => void;
removeFrame?: () => void;
}
export interface ThreeDSecure {
/**
* braintree.threeDSecure.create({
@@ -83,21 +175,8 @@ export interface ThreeDSecure {
* }
* });
*/
verifyCard(options: {
nonce: string;
amount: number;
addFrame: (err?: BraintreeError, iframe?: HTMLIFrameElement) => void;
removeFrame?: () => void;
}): Promise<ThreeDSecureVerifyPayload>;
verifyCard(
options: {
nonce: string;
amount: number;
addFrame: (err?: BraintreeError, iframe?: HTMLIFrameElement) => void;
removeFrame: () => void;
},
callback: callback,
): void;
verifyCard(options: ThreeDSecureVerifyOptions): Promise<ThreeDSecureVerifyPayload>;
verifyCard(options: ThreeDSecureVerifyOptions, callback: callback): void;
/**
* Cancel the 3DS flow and return the verification payload if available. * @example

View File

@@ -547,6 +547,7 @@ braintree.threeDSecure.verifyCard(
{
nonce: existingNonce,
amount: 123.45, // $ExpectType number
bin: "1234",
addFrame: (err, iframe) => {
// Set up your UI and add the iframe.
const my3DSContainer = document.createElement('div');

View File

@@ -128,14 +128,14 @@ braintree.client.create(
},
fields: {
number: {
selector: '#card-number',
container: document.createElement('div'),
},
cvv: {
selector: '#cvv',
container: '#cvv',
type: 'password',
},
expirationMonth: {
selector: '#expiration-month',
container: '#expiration-month',
select: {
options: [
'01 - Jan',
@@ -154,7 +154,7 @@ braintree.client.create(
},
},
expirationYear: {
selector: '#expiration-year',
container: '#expiration-year',
select: true,
},
},
@@ -681,6 +681,10 @@ braintree.client.create(
});
});
});
clientInstance.teardown((err) => {
// implementation
});
},
);
@@ -726,6 +730,7 @@ braintree.threeDSecure.verifyCard(
{
nonce: existingNonce,
amount: 123.45, // $ExpectType number
bin: "1234",
addFrame: (err, iframe) => {
// Set up your UI and add the iframe.
const my3DSContainer = document.createElement('div');