Skip to content

Commit

Permalink
Add AE getValue type (#410)
Browse files Browse the repository at this point in the history
* Add AE getValue type

* prettier and update comment

* Add .then to test
  • Loading branch information
cyuen-stripe authored Jan 17, 2023
1 parent c8af87f commit 3faf2a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,12 @@ addressElement.update({
},
});

addressElement.getValue().then((res) => {
if (res.complete && res.isNewAddress) {
const value = res.value;
}
});

const retrievedAddressElement: StripeAddressElement | null = elements.getElement(
'address'
);
Expand Down
7 changes: 7 additions & 0 deletions types/stripe-js/elements/address.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ export type StripeAddressElement = StripeElementBase & {
* Updates are merged into the existing configuration.
*/
update(options: Partial<StripeAddressElementOptions>): StripeAddressElement;

/**
* Validates and retrieves form values from the `AddressElement`.
*/
getValue(): Promise<
Pick<StripeAddressElementChangeEvent, 'complete' | 'isNewAddress' | 'value'>
>;
};

export interface ContactOption {
Expand Down

0 comments on commit 3faf2a2

Please sign in to comment.