Installations
npm install @google-pay/button-element
Developer Guide
Typescript
Yes
Module System
CommonJS, UMD
Min. Node Version
>=8.0.0
Node Version
16.20.2
NPM Version
8.19.4
Score
81
Supply Chain
99.6
Quality
77
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (88.45%)
JavaScript (5.96%)
Shell (5.59%)
Developer
google-pay
Download Statistics
Total Downloads
220,199
Last Day
61
Last Week
2,991
Last Month
11,002
Last Year
90,792
GitHub Statistics
260 Stars
433 Commits
69 Forks
16 Watching
5 Branches
10 Contributors
Package Meta Information
Latest Version
3.1.0
Package Id
@google-pay/button-element@3.1.0
Unpacked Size
133.86 kB
Size
29.02 kB
File Count
9
NPM Version
8.19.4
Node Version
16.20.2
Publised On
28 Mar 2024
Total Downloads
Cumulative downloads
Total Downloads
220,199
Last day
-7.6%
61
Compared to previous day
Last week
13.1%
2,991
Compared to previous week
Last month
-8.5%
11,002
Compared to previous month
Last year
31.6%
90,792
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Google Pay web component button
This is the web component for the Google Pay button. This component can be used in standard HTML websites as well as websites built with many popular JavaScript frameworks.
Note that React and Angular developers should use the @google-pay/button-react and @google-pay/button-angular versions of this component.
Installation
1npm install @google-pay/button-element
Example usage: HTML website
1<div id="buttons"> 2 <google-pay-button environment="TEST" button-type="short" button-color="black"></google-pay-button> 3</div> 4<script type="module"> 5 import './node_modules/@google-pay/button-element/dist/index.js'; 6 7 const button = document.querySelector('google-pay-button'); 8 button.paymentRequest = { 9 apiVersion: 2, 10 apiVersionMinor: 0, 11 allowedPaymentMethods: [ 12 { 13 type: 'CARD', 14 parameters: { 15 allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'], 16 allowedCardNetworks: ['MASTERCARD', 'VISA'], 17 billingAddressRequired: true, 18 }, 19 tokenizationSpecification: { 20 type: 'PAYMENT_GATEWAY', 21 parameters: { 22 gateway: 'example', 23 gatewayMerchantId: 'exampleGatewayMerchantId', 24 }, 25 }, 26 }, 27 ], 28 merchantInfo: { 29 merchantId: '12345678901234567890', 30 merchantName: 'Demo Merchant', 31 }, 32 transactionInfo: { 33 totalPriceStatus: 'FINAL', 34 totalPriceLabel: 'Total', 35 totalPrice: '100.00', 36 currencyCode: 'USD', 37 countryCode: 'US', 38 }, 39 }; 40 41 button.addEventListener('loadpaymentdata', event => { 42 console.log('load payment data', event.detail); 43 }); 44</script>
More HTML examples can be found in the examples folder of this repository.
Try it out on StackBlitz.
Example usage: Vue website
1<google-pay-button 2 environment="TEST" 3 button-type="buy" 4 button-color="black" 5 v-bind:paymentRequest.prop="{ 6 apiVersion: 2, 7 apiVersionMinor: 0, 8 allowedPaymentMethods: [ 9 { 10 type: 'CARD', 11 parameters: { 12 allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'], 13 allowedCardNetworks: ['AMEX', 'VISA', 'MASTERCARD'] 14 }, 15 tokenizationSpecification: { 16 type: 'PAYMENT_GATEWAY', 17 parameters: { 18 gateway: 'example', 19 gatewayMerchantId: 'exampleGatewayMerchantId' 20 } 21 } 22 } 23 ], 24 transactionInfo: { 25 totalPriceStatus: 'FINAL', 26 totalPriceLabel: 'Total', 27 totalPrice: '100.00', 28 currencyCode: 'USD', 29 countryCode: 'US' 30 } 31 }" 32 v-on:loadpaymentdata="onLoadPaymentData" 33 v-on:error="onError" 34></google-pay-button>
More Vue examples can be found in the examples folder of this repository.
Try it out on StackBlitz.
Example usage: Svelte website
1<google-pay-button 2 environment="TEST" 3 button-type="buy" 4 button-color="black" 5 paymentRequest={{ 6 apiVersion: 2, 7 apiVersionMinor: 0, 8 allowedPaymentMethods: [ 9 { 10 type: 'CARD', 11 parameters: { 12 allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'], 13 allowedCardNetworks: ['AMEX', 'VISA', 'MASTERCARD'], 14 }, 15 tokenizationSpecification: { 16 type: 'PAYMENT_GATEWAY', 17 parameters: { 18 gateway: 'example', 19 gatewayMerchantId: 'exampleGatewayMerchantId', 20 }, 21 }, 22 }, 23 ], 24 transactionInfo: { 25 totalPriceStatus: 'FINAL', 26 totalPriceLabel: 'Total', 27 totalPrice: '100.00', 28 currencyCode: 'USD', 29 countryCode: 'US', 30 }, 31 }} 32 on:loadpaymentdata={event => { 33 console.log('load payment data', event.detail); 34 }} 35></google-pay-button>
More Svelte examples can be found in the examples folder of this repository.
Try it out on StackBlitz (note: limited browser support).
Documentation
Visit the Google Pay developer site for more information about integrating Google Pay into your website.
Properties
Property | Type | Remarks |
---|---|---|
buttonColor |
|
Optional.
Default value |
buttonLocale |
|
Optional. This ISO 639-1 code represents the desired button language. Supported locales include Default value is determined by the browser/operating system locale. |
buttonSizeMode |
|
Optional.
Default value |
buttonType |
|
Optional. Displays their respective prompts (localized based on the user's browser settings) with the Google Pay logo. The
Default value |
buttonRadius |
|
Optional. Specifies the button corner radius in pixels. The minimum is 0 and the maximum depends on the height of the button. If the height is 40px (default height) then the maximum value for the |
environment |
|
Required. The Google Pay environment to target. Note: in the |
existingPaymentMethodRequired |
|
Optional. When set to Default value |
paymentRequest |
Required. Request parameters that define the type of payment information requested from Google Pay. See |
Callbacks/events
Callback | Arguments | Remarks |
---|---|---|
onCancel | reason |
Invoked when a user cancels or closes the Google Pay payment sheet. Also raised as event |
onClick | event |
Invoked when the Google Pay button is clicked, before the payment sheet is displayed. Display of the payment sheet can be prevented by calling |
onError | reason |
Invoked when an error is encountered in the process of presenting and collecting payment options from the Google Pay payment sheet. Also raised as event |
onLoadPaymentData | paymentData |
Invoked when a user has successfully nominated payment details. This callback receives the Also raised as event |
onPaymentAuthorized | paymentData |
Invoked when a user chooses a payment method. This callback should be used to validate whether or not the payment method can be used to complete a payment. This would be typically used to perform pre-authorization to ensure that the card is valid and has sufficient funds. Note that in order to use this callback See payment authorization reference for more information. |
onPaymentDataChanged | intermediatePaymentData |
Invoked when payment the user changes payment data options including payment method, shipping details, and contact details. This callback can be used to dynamically update Note that in order to use this callback See payment data changed reference for more information. |
onReadyToPayChange | result |
Invoked when the user's Note that when
Also raised as event |
About this package
Note that this folder does not contain a package.json
file. The package.json
file is generated during the build
process using the package-template.json
where the version number is read from the package.json
file defined in the root of this repository.
No vulnerabilities found.
Reason
15 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0
Reason
SAST tool is run on all commits
Details
- Info: all commits (24) are checked with a SAST tool
Reason
Found 2/12 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/push.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/google-pay/google-pay-button/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/google-pay/google-pay-button/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/google-pay/google-pay-button/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/push.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/google-pay/google-pay-button/push.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/push.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/google-pay/google-pay-button/push.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: scripts/update.sh:22
- Warn: npmCommand not pinned by hash: scripts/update.sh:25
- Warn: npmCommand not pinned by hash: scripts/update.sh:28
- Warn: npmCommand not pinned by hash: scripts/update.sh:31
- Warn: npmCommand not pinned by hash: scripts/update.sh:34
- Warn: npmCommand not pinned by hash: scripts/update.sh:37
- Warn: npmCommand not pinned by hash: scripts/update.sh:40
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:22
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:25
- Warn: npmCommand not pinned by hash: .github/workflows/push.yml:29
- Warn: npmCommand not pinned by hash: .github/workflows/push.yml:32
- Info: 0 out of 5 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 11 npmCommand dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
13 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-8266-84wp-wv5c
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
Score
4.6
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More