/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///
export interface ReadyToPayChangeResponse {
isButtonVisible: boolean;
isReadyToPay: boolean;
paymentMethodPresent?: boolean;
}
export interface Config {
environment: google.payments.api.Environment;
existingPaymentMethodRequired?: boolean;
paymentRequest: google.payments.api.PaymentDataRequest;
onPaymentDataChanged?: google.payments.api.PaymentDataChangedHandler;
onPaymentAuthorized?: google.payments.api.PaymentAuthorizedHandler;
onLoadPaymentData?: (paymentData: google.payments.api.PaymentData) => void;
onCancel?: (reason: google.payments.api.PaymentsError) => void;
onError?: (error: Error | google.payments.api.PaymentsError) => void;
onReadyToPayChange?: (result: ReadyToPayChangeResponse) => void;
onClick?: (event: Event) => void;
buttonType?: google.payments.api.ButtonType;
buttonColor?: google.payments.api.ButtonColor;
buttonRadius?: number;
buttonSizeMode?: google.payments.api.ButtonSizeMode;
buttonLocale?: string;
buttonBorderType?: google.payments.api.ButtonBorderType;
}
interface ButtonManagerOptions {
cssSelector: string;
softwareInfoId: string;
softwareInfoVersion: string;
}
/**
* Manages the lifecycle of the Google Pay button.
*
* Includes lifecycle management of the `PaymentsClient` instance,
* `isReadyToPay`, `onClick`, `loadPaymentData`, and other callback methods.
*/
export declare class ButtonManager {
private client?;
private config?;
private element?;
private options;
private oldInvalidationValues?;
isReadyToPay?: boolean;
paymentMethodPresent?: boolean;
constructor(options: ButtonManagerOptions);
getElement(): Element | undefined;
private isGooglePayLoaded;
mount(element: Element): Promise;
unmount(): void;
configure(newConfig: Config): Promise;
/**
* Creates client configuration options based on button configuration
* options.
*
* This method would normally be private but has been made public for
* testing purposes.
*
* @private
*/
createClientOptions(config: Config): google.payments.api.PaymentOptions;
private createIsReadyToPayRequest;
/**
* Constructs `loadPaymentData` request object based on button configuration.
*
* It infers request properties like `shippingAddressRequired`,
* `shippingOptionRequired`, and `billingAddressRequired` if not already set
* based on the presence of their associated options and parameters. It also
* infers `callbackIntents` based on the callback methods defined in button
* configuration.
*
* This method would normally be private but has been made public for
* testing purposes.
*
* @private
*/
createLoadPaymentDataRequest(config: Config): google.payments.api.PaymentDataRequest;
private createMerchantInfo;
private isMounted;
private removeButton;
private updateElement;
/**
* Handles the click event of the Google Pay button.
*
* This method would normally be private but has been made public for
* testing purposes.
*
* @private
*/
handleClick: (event: Event) => Promise;
private setClassName;
private appendStyles;
private isClientInvalidated;
private getInvalidationValues;
}
export {};