@google-pay/button-react
Version:
React component for Google Pay button
64 lines (59 loc) • 2.25 kB
TypeScript
/// <reference types="googlepay" />
import React, { CSSProperties } from 'react';
/**
* 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.
*/
interface ReadyToPayChangeResponse {
isButtonVisible: boolean;
isReadyToPay: boolean;
paymentMethodPresent?: boolean;
}
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;
}
/**
* Properties for the Google Pay button React component
*/
interface Props extends Config {
className?: string;
style?: CSSProperties;
}
/**
* React component for the Google Pay button
*/
declare class GooglePayButton extends React.Component<Props> {
private manager;
private elementRef;
componentDidMount(): Promise<void>;
componentWillUnmount(): void;
componentDidUpdate(): void;
render(): JSX.Element;
}
export { ReadyToPayChangeResponse, GooglePayButton as default };