├── .env ├── .eslintrc.js ├── .flowconfig ├── .github ├── issue_label_bot.yaml └── workflows │ ├── main.yml │ └── publish.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .npmrc ├── .nvmrc ├── .prettierignore ├── .prettierrc.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── __sdk__.js ├── babel.config.js ├── commitlint.config.js ├── globals.js ├── package.json ├── renovate.json └── src ├── __tests__ └── googlepay.test.js ├── babel.config.js ├── component.js ├── constants.js ├── googlepay.js ├── index.js ├── logging.js ├── mock.js ├── types.js └── util.js /.env: -------------------------------------------------------------------------------- 1 | NODE_TLS_REJECT_UNAUTHORIZED=0 -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | module.exports = { 4 | extends: "@krakenjs/eslint-config-grumbler/eslintrc-browser", 5 | 6 | globals: { 7 | __sdk__: true, 8 | document: true, 9 | performance: true, 10 | assert: true, 11 | beforeAll: true, 12 | afterAll: true, 13 | test: true, 14 | jest: true, 15 | page: true, 16 | browserlist: true, 17 | }, 18 | overrides: [ 19 | { 20 | files: ["**/*.test.js"], 21 | env: { 22 | jest: true, 23 | }, 24 | globals: { 25 | JestMockFn: false, 26 | }, 27 | }, 28 | ], 29 | rules: { 30 | "compat/compat": "off", 31 | "max-lines": "off", 32 | "no-restricted-globals": "off", 33 | "promise/no-native": "off", 34 | "key-spacing": "off", 35 | "import/no-commonjs": "off", 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/node_modules/babel-plugin-flow-runtime 3 | .*/node_modules/npm 4 | .*/node_modules/jsonlint 5 | .*/dist/module 6 | .*/node_modules/resolve 7 | [include] 8 | [libs] 9 | flow-typed 10 | src/declarations.js 11 | node_modules/@paypal/sdk-client/src/declarations.js 12 | [options] 13 | module.name_mapper='^src\(.*\)$' -> '/src/\1' 14 | -------------------------------------------------------------------------------- /.github/issue_label_bot.yaml: -------------------------------------------------------------------------------- 1 | label-alias: 2 | bug: "🐞 bug" 3 | feature_request: "🧞‍♂️ feature" 4 | question: "⁉️ question" 5 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: {} 7 | jobs: 8 | main: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: ⬇️ Checkout repo 12 | uses: actions/checkout@v2 13 | 14 | - name: ⎔ Setup node 15 | uses: actions/setup-node@v2 16 | with: 17 | node-version: "16" 18 | 19 | - name: 📥 Download deps 20 | uses: bahmutov/npm-install@v1 21 | with: 22 | useLockFile: false 23 | 24 | - name: ▶️ Run flow-typed script 25 | run: npm run flow-typed 26 | 27 | - name: ▶️ Run test script 28 | run: npm run test 29 | 30 | - name: ⬆️ Upload jest coverage report 31 | uses: codecov/codecov-action@v2 32 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: publish to npm 2 | on: workflow_dispatch 3 | jobs: 4 | main: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: ⬇️ Checkout repo 8 | uses: actions/checkout@v2 9 | with: 10 | ref: ${{ github.head_ref }} 11 | 12 | - name: ⎔ Setup node 13 | # sets up the .npmrc file to publish to npm 14 | uses: actions/setup-node@v2 15 | with: 16 | node-version: "16" 17 | registry-url: "https://registry.npmjs.org" 18 | 19 | - name: 📥 Download deps 20 | uses: bahmutov/npm-install@v1 21 | with: 22 | useLockFile: false 23 | 24 | - name: Configure git user 25 | run: | 26 | git config --global user.email ${{ github.actor }}@users.noreply.github.com 27 | git config --global user.name ${{ github.actor }} 28 | 29 | - name: Publish to npm 30 | run: npm run release 31 | env: 32 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 33 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | flow-typed 4 | package-lock.json -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx --no -- commitlint --edit "$1" 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | npx lint-staged 6 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | save=false 3 | package-lock=false 4 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | coverage/ 3 | flow-typed/ 4 | CHANGELOG.md 5 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### 1.2.3 (2023-10-23) 6 | 7 | ### 1.2.2 (2023-06-27) 8 | 9 | 10 | * add back authJWT ([#17](https://github.com/paypal/paypal-googlepay-component/issues/17)) ([19c8b0a](https://github.com/paypal/paypal-googlepay-component/commit/19c8b0a59847a62b00d3f235896a711f87bf3800)) 11 | 12 | ### 1.2.1 (2023-06-27) 13 | 14 | 15 | * fix tests ([#16](https://github.com/paypal/paypal-googlepay-component/issues/16)) ([2f6d54a](https://github.com/paypal/paypal-googlepay-component/commit/2f6d54a8a2a669172cd21b6ffdff25ec2591dec6)) 16 | 17 | ## 1.2.0 (2023-06-26) 18 | 19 | 20 | ### Features 21 | 22 | * add countrycode and api version ([#15](https://github.com/paypal/paypal-googlepay-component/issues/15)) ([7f40ada](https://github.com/paypal/paypal-googlepay-component/commit/7f40adae3ed17d362af9456dc49f8b7b90536296)) 23 | 24 | ### 1.1.4 (2023-05-19) 25 | 26 | 27 | * correct initiate spelling ([#12](https://github.com/paypal/paypal-googlepay-component/issues/12)) ([5949a6a](https://github.com/paypal/paypal-googlepay-component/commit/5949a6af1b18285b126414915c108b0053986b8c)) 28 | 29 | ### 1.1.3 (2023-05-03) 30 | 31 | 32 | * change name to keep it consistent with applepay ([#11](https://github.com/paypal/paypal-googlepay-component/issues/11)) ([1f8eecd](https://github.com/paypal/paypal-googlepay-component/commit/1f8eecdf02a8ca6b0014628732e7d5f9f85aa40d)) 33 | 34 | ### 1.1.2 (2023-04-21) 35 | 36 | 37 | * globals and 3ds fix ([#10](https://github.com/paypal/paypal-googlepay-component/issues/10)) ([e2dbfe7](https://github.com/paypal/paypal-googlepay-component/commit/e2dbfe7171a8f78933c63190fc70f8a8a3605ba2)) 38 | 39 | ### 1.1.1 (2023-04-20) 40 | 41 | 42 | ### Bug Fixes 43 | 44 | * schemaChanges for merchantID and testfix ([#9](https://github.com/paypal/paypal-googlepay-component/issues/9)) ([0a44202](https://github.com/paypal/paypal-googlepay-component/commit/0a4420213d09dd4f20614f7254b3fa65f7c6816e)) 45 | 46 | ## 1.1.0 (2023-04-20) 47 | 48 | 49 | ### Features 50 | 51 | * **3ds:** ThreeDS Handling, Remove CreateOrder, Add MerchantID ([#8](https://github.com/paypal/paypal-googlepay-component/issues/8)) ([4def05e](https://github.com/paypal/paypal-googlepay-component/commit/4def05e9569628286bd137891c78071125a547d5)) 52 | 53 | ### 1.0.1 (2023-03-21) 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | https://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019 PayPal 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | https://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/paypal-googlepay-component/a4c2f9759655f2a17e5696e8fc9729729d1c5eab/README.md -------------------------------------------------------------------------------- /__sdk__.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | /* eslint import/no-commonjs: 0 */ 3 | 4 | const globals = require("./globals"); 5 | 6 | module.exports = { 7 | googlepay: { 8 | entry: "./src/index", 9 | ...globals, 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | module.exports = { 4 | extends: "@krakenjs/babel-config-grumbler/babelrc-node", 5 | }; 6 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | /* eslint import/no-commonjs: off */ 3 | 4 | module.exports = { 5 | extends: ["@commitlint/config-conventional"], 6 | }; 7 | -------------------------------------------------------------------------------- /globals.js: -------------------------------------------------------------------------------- 1 | /* eslint import/no-commonjs: off, flowtype/require-valid-file-annotation: off, flowtype/require-return-type: off */ 2 | 3 | const postRobotGlobals = require("@krakenjs/post-robot/globals"); 4 | const zoidGlobals = require("@krakenjs/zoid/globals"); 5 | 6 | module.exports = { 7 | __ZOID__: { 8 | ...zoidGlobals.__ZOID__, 9 | __DEFAULT_CONTAINER__: true, 10 | __DEFAULT_PRERENDER__: true, 11 | __FRAMEWORK_SUPPORT__: true, 12 | }, 13 | 14 | __POST_ROBOT__: { 15 | ...postRobotGlobals.__POST_ROBOT__, 16 | __IE_POPUP_SUPPORT__: false, 17 | }, 18 | 19 | __PAYPAL_CHECKOUT__: { 20 | __REMEMBERED_FUNDING__: [], 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@paypal/googlepay-components", 3 | "version": "1.2.3", 4 | "description": "A Web Component for GooglePay Integration", 5 | "main": "index.js", 6 | "publishConfig": { 7 | "access": "public" 8 | }, 9 | "scripts": { 10 | "flow-typed": "flow-typed install", 11 | "flow": "flow", 12 | "flow:build": "flow gen-flow-files ./src/index.js --out-dir ./dist/module", 13 | "format": "prettier --write .", 14 | "format:check": "prettier --check .", 15 | "test:unit": "NODE_TLS_REJECT_UNAUTHORIZED=0 jest src/ --collectCoverage --collectCoverageFrom='src/' --testPathIgnorePatterns=/fixtures/ --no-cache --runInBand", 16 | "lint": "eslint --fix src/*.js", 17 | "test": "npm run format:check && npm run lint && npm run flow && npm run test:unit", 18 | "build": "npm run test", 19 | "prepare": "husky install", 20 | "prerelease": "npm run clean && npm run build && git add dist && git commit -m 'ci: check in dist folder' || echo 'Nothing to distribute'", 21 | "release": "standard-version", 22 | "postrelease": "git push && git push --follow-tags && npm publish" 23 | }, 24 | "jest": { 25 | "coverageDirectory": "./coverage/", 26 | "restoreMocks": true, 27 | "testEnvironment": "jsdom", 28 | "transformIgnorePatterns": [ 29 | "node_modules/(?!(@paypal|@krakenjs|get-browser-fingerprint))" 30 | ], 31 | "globals": { 32 | "__DEBUG__": true, 33 | "__TEST__": true, 34 | "__POST_ROBOT__": {} 35 | } 36 | }, 37 | "standard-version": { 38 | "types": [ 39 | { 40 | "type": "feat", 41 | "section": "Features" 42 | }, 43 | { 44 | "type": "fix", 45 | "section": "Bug Fixes" 46 | }, 47 | { 48 | "type": "chore", 49 | "hidden": false 50 | }, 51 | { 52 | "type": "docs", 53 | "hidden": false 54 | }, 55 | { 56 | "type": "style", 57 | "hidden": false 58 | }, 59 | { 60 | "type": "refactor", 61 | "hidden": false 62 | }, 63 | { 64 | "type": "perf", 65 | "hidden": false 66 | }, 67 | { 68 | "type": "test", 69 | "hidden": false 70 | }, 71 | { 72 | "type": "ci", 73 | "hidden": true 74 | } 75 | ] 76 | }, 77 | "files": [ 78 | "src", 79 | "__sdk__.js", 80 | "globals.js" 81 | ], 82 | "repository": { 83 | "type": "git", 84 | "url": "git+https://github.com/paypal/paypal-googlepay-component.git" 85 | }, 86 | "author": "RatnadeepSimhadri", 87 | "license": "Apache-2.0", 88 | "bugs": { 89 | "url": "https://github.com/paypal/paypal-googlepay-component/issues" 90 | }, 91 | "homepage": "https://github.com/paypal/paypal-googlepay-component#readme", 92 | "devDependencies": { 93 | "@babel/core": "^7.19.1", 94 | "@babel/preset-env": "^7.19.1", 95 | "@commitlint/cli": "^16.2.3", 96 | "@commitlint/config-conventional": "^16.2.1", 97 | "@krakenjs/grumbler-scripts": "^8.1.1", 98 | "atob": "^2.1.2", 99 | "babel-jest": "^29.0.3", 100 | "btoa": "^1.2.1", 101 | "cross-env": "^7.0.3", 102 | "flow-bin": "0.155.0", 103 | "flow-typed": "^3.8.0", 104 | "husky": "^7.0.4", 105 | "isomorphic-fetch": "^3.0.0", 106 | "jest": "^29.3.1", 107 | "jest-environment-jsdom": "^29.2.0", 108 | "jest-fetch-mock": "^3.0.3", 109 | "mocha": "^4", 110 | "prettier": "^2.8.8", 111 | "standard-version": "^9.3.2" 112 | }, 113 | "dependencies": { 114 | "@krakenjs/zalgo-promise": "^2.0.0", 115 | "@paypal/common-components": "^1.0.35", 116 | "@paypal/sdk-client": "^4.0.166", 117 | "@paypal/sdk-constants": "^1.0.129", 118 | "@krakenjs/post-robot": "^11.0.0", 119 | "@krakenjs/zoid": "^10.0.0" 120 | }, 121 | "lint-staged": { 122 | "**/*": "prettier --write --ignore-unknown" 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["config:base"] 3 | } 4 | -------------------------------------------------------------------------------- /src/__tests__/googlepay.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable eslint-comments/disable-enable-pair */ 2 | /* @flow */ 3 | 4 | import fetch from "isomorphic-fetch"; 5 | 6 | import { Googlepay } from "../component"; 7 | 8 | jest.mock("@paypal/sdk-client/src", () => ({ 9 | getPartnerAttributionID: () => "bn_code", 10 | getClientID: () => 11 | "ARRXqmcYWf0Ekx1vXM_1nhs1eGSi9X_cVl6qjFb0PfTPsbhmErPrAFy4Y59kAKtG_HMzh7fcyvUVKUhO", 12 | getMerchantID: () => ["WSHE4HLKU3W5N"], 13 | getPayPalAPIDomain: () => "https://cors.api.sandbox.paypal.com", 14 | getPayPalDomain: () => "https://www.sandbox.paypal.com", 15 | getBuyerCountry: () => "US", 16 | getLogger: () => ({ 17 | info: () => ({ 18 | track: () => ({ 19 | flush: () => ({}), 20 | }), 21 | }), 22 | error: () => ({ 23 | track: () => ({ 24 | flush: () => ({}), 25 | }), 26 | }), 27 | }), 28 | getSDKQueryParam: (param) => { 29 | if (param === "currency") { 30 | return "USD"; 31 | } 32 | 33 | return ""; 34 | }, 35 | getEnv: () => "stage", 36 | })); 37 | 38 | jest.mock("../util", () => { 39 | const actualUtil = jest.requireActual("../util"); 40 | return { 41 | ...actualUtil, 42 | getMerchantDomain: () => "https://www.checkout.com", 43 | getPayPalDomain: () => "https://www.sandbox.paypal.com", 44 | }; 45 | }); 46 | 47 | jest.mock("@paypal/sdk-constants/src", () => { 48 | const originalModule = jest.requireActual("@paypal/sdk-constants/src"); 49 | 50 | return { 51 | __esModule: true, 52 | ...originalModule, 53 | }; 54 | }); 55 | 56 | global.fetch = fetch; 57 | 58 | describe("googlepay", () => { 59 | describe("Config", () => { 60 | it("GetGooglePayConfig", async () => { 61 | const googlepay = Googlepay(); 62 | const config = await googlepay.config(); 63 | expect(config).toEqual({ 64 | isEligible: true, 65 | apiVersion: 2, 66 | apiVersionMinor: 0, 67 | countryCode: "US", 68 | allowedPaymentMethods: [ 69 | { 70 | type: "CARD", 71 | parameters: { 72 | allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"], 73 | allowedCardNetworks: ["MASTERCARD", "DISCOVER", "VISA", "AMEX"], 74 | billingAddressRequired: true, 75 | assuranceDetailsRequired: true, 76 | billingAddressParameters: { 77 | format: "FULL", 78 | }, 79 | }, 80 | tokenizationSpecification: { 81 | type: "PAYMENT_GATEWAY", 82 | parameters: { 83 | gateway: "paypalsb", 84 | gatewayMerchantId: "NDFBEMLJX9XMN", 85 | }, 86 | }, 87 | }, 88 | ], 89 | merchantInfo: { 90 | merchantOrigin: "https://www.checkout.com", 91 | merchantId: "BCR2DN4TXSDMVTKM", 92 | }, 93 | }); 94 | }); 95 | }); 96 | }); 97 | -------------------------------------------------------------------------------- /src/babel.config.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | module.exports = { 4 | extends: "@krakenjs/babel-config-grumbler/babelrc-node", 5 | }; 6 | -------------------------------------------------------------------------------- /src/component.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | import { 4 | confirmOrder, 5 | googlePayConfig, 6 | initiatePayerAction, 7 | } from "./googlepay"; 8 | import type { GooglePayType } from "./types"; 9 | 10 | export function Googlepay(): GooglePayType { 11 | return { 12 | config: googlePayConfig, 13 | confirmOrder, 14 | initiatePayerAction, 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /src/constants.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | export const DEFAULT_API_HEADERS = { 4 | "Content-Type": "application/json", 5 | Accept: "application/json", 6 | }; 7 | 8 | type Headers = {| 9 | "x-app-name": string, 10 | "Content-Type": string, 11 | Accept: string, 12 | origin: string, 13 | prefer: string, 14 | |}; 15 | 16 | export const DEFAULT_GQL_HEADERS: Headers = { 17 | "x-app-name": "sdk-googlepay", 18 | "Content-Type": "application/json", 19 | Accept: "application/json", 20 | origin: window.location, 21 | prefer: "return=representation", 22 | }; 23 | 24 | export const FPTI_TRANSITION = { 25 | GOOGLEPAY_EVENT: ("googlepay_event": "googlepay_event"), 26 | GOOGLEPAY_FLOW_ERROR: ("googlepay_flow_error": "googlepay_flow_error"), 27 | GOOGLEPAY_CREATE_ORDER_ERROR: 28 | ("googlepay_create_order_error": "googlepay_create_order_error"), 29 | GOOGLEPAY_GET_ORDER_ERROR: 30 | ("googlepay_get_order_error": "googlepay_get_order_error"), 31 | GOOGLEPAY_ON_CLICK_INVALID: 32 | ("googlepay_onclick_invalid": "googlepay_onclick_invalid"), 33 | GOOGLEPAY_PAYMENT_ERROR: 34 | ("googlepay_payment_error": "googlepay_payment_error"), 35 | GOOGLEPAY_CONFIG_ERROR: ("googlepay_config_error": "googlepay_config_error"), 36 | GOOGLEPAY_TDS_SUCCESS: ("googlepay_tds_success": "googlepay_tds_success"), 37 | GOOGLEPAY_TDS_CANCEL: ("googlepay_tds_cancel": "googlepay_tds_cancel"), 38 | GOOGLEPAY_TDS_ERROR: ("googlepay_tds_error": "googlepay_tds_error"), 39 | }; 40 | 41 | export const FPTI_CUSTOM_KEY = { 42 | ERR_DESC: ("int_error_desc": "int_error_desc"), 43 | INFO_MSG: ("info_msg": "info_msg"), 44 | }; 45 | 46 | export const ORDER_INTENT = { 47 | CAPTURE: "CAPTURE", 48 | AUTHORIZE: "AUTHORIZE", 49 | }; 50 | 51 | export const LOCAL_HOST = "https://localhost.paypal.com:9000"; 52 | 53 | export const API_HOST = `https://sandbox.paypal.com`; 54 | -------------------------------------------------------------------------------- /src/googlepay.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | import { 4 | getClientID, 5 | getLogger, 6 | getMerchantID, 7 | getBuyerCountry, 8 | } from "@paypal/sdk-client/src"; 9 | import { FPTI_KEY } from "@paypal/sdk-constants/src"; 10 | import { ZalgoPromise } from "@krakenjs/zalgo-promise/src"; 11 | import { getThreeDomainSecureComponent } from "@paypal/common-components/src/three-domain-secure"; 12 | 13 | import { 14 | PayPalGooglePayError, 15 | getMerchantDomain, 16 | getPayPalDomain, 17 | getConfigQuery, 18 | } from "./util"; 19 | import { 20 | FPTI_TRANSITION, 21 | FPTI_CUSTOM_KEY, 22 | DEFAULT_GQL_HEADERS, 23 | } from "./constants"; 24 | import { logGooglePayEvent } from "./logging"; 25 | import type { 26 | ConfigResponse, 27 | PayPalGooglePayErrorType, 28 | ConfirmOrderParams, 29 | ApprovePaymentResponse, 30 | InitiatePayerActionParams, 31 | } from "./types"; 32 | 33 | export function googlePayConfig(): Promise< 34 | ConfigResponse | PayPalGooglePayErrorType 35 | > { 36 | logGooglePayEvent("GetGooglePayConfig"); 37 | return fetch(`${getPayPalDomain()}/graphql?GetGooglePayConfig`, { 38 | method: "POST", 39 | headers: { 40 | ...DEFAULT_GQL_HEADERS, 41 | }, 42 | body: JSON.stringify({ 43 | query: getConfigQuery(), 44 | variables: { 45 | clientId: getClientID(), 46 | merchantId: getMerchantID(), 47 | merchantOrigin: getMerchantDomain(), 48 | buyerCountry: getBuyerCountry(), 49 | }, 50 | }), 51 | }) 52 | .then((res) => { 53 | if (!res.ok) { 54 | const { headers } = res; 55 | throw new PayPalGooglePayError( 56 | "INTERNAL_SERVER_ERROR", 57 | "An internal server error has occurred", 58 | headers.get("Paypal-Debug-Id") 59 | ); 60 | } 61 | return res.json(); 62 | }) 63 | .then(({ data, errors, extensions }) => { 64 | if (Array.isArray(errors) && errors.length) { 65 | const message = errors[0]?.message ?? JSON.stringify(errors[0]); 66 | throw new PayPalGooglePayError( 67 | "GOOGLEPAY_CONFIG_ERROR", 68 | message, 69 | extensions?.correlationId 70 | ); 71 | } 72 | if (!data.googlePayConfig.isEligible) { 73 | throw new PayPalGooglePayError( 74 | "GOOGLEPAY_CONFIG_ERROR", 75 | "Not Eligible for GooglePay Payments", 76 | extensions?.correlationId 77 | ); 78 | } 79 | return data.googlePayConfig; 80 | }) 81 | .catch((err) => { 82 | getLogger() 83 | .error(FPTI_TRANSITION.GOOGLEPAY_CONFIG_ERROR) 84 | .track({ 85 | [FPTI_KEY.TRANSITION]: FPTI_TRANSITION.GOOGLEPAY_CONFIG_ERROR, 86 | [FPTI_CUSTOM_KEY.ERR_DESC]: `Error: ${err.message}) }`, 87 | }) 88 | .flush(); 89 | 90 | throw err; 91 | }); 92 | } 93 | 94 | export function confirmOrder({ 95 | orderId, 96 | paymentMethodData, 97 | shippingAddress, 98 | billingAddress, 99 | email, 100 | }: ConfirmOrderParams): Promise< 101 | ApprovePaymentResponse | PayPalGooglePayErrorType 102 | > { 103 | /** If the Merchant Choses to */ 104 | if (billingAddress && paymentMethodData?.info) { 105 | paymentMethodData.info.billingAddress = billingAddress; 106 | } 107 | return fetch(`${getPayPalDomain()}/graphql?ApproveGooglePayPayment`, { 108 | method: "POST", 109 | headers: { 110 | ...DEFAULT_GQL_HEADERS, 111 | }, 112 | body: JSON.stringify({ 113 | query: ` 114 | mutation ApproveGooglePayPayment( 115 | $paymentMethodData: GooglePayPaymentMethodData! 116 | $orderID: String! 117 | $clientID : String! 118 | $shippingAddress: GooglePayPaymentContact 119 | $email: String 120 | $productFlow: String 121 | ) { 122 | approveGooglePayPayment( 123 | paymentMethodData: $paymentMethodData 124 | orderID: $orderID 125 | clientID: $clientID 126 | shippingAddress: $shippingAddress 127 | email: $email 128 | productFlow: $productFlow 129 | ) 130 | }`, 131 | variables: { 132 | paymentMethodData, 133 | clientID: getClientID(), 134 | orderID: orderId, 135 | shippingAddress, 136 | email, 137 | productFlow: "CUSTOM_DIGITAL_WALLET", 138 | }, 139 | }), 140 | }) 141 | .then((res) => { 142 | if (!res.ok) { 143 | const { headers } = res; 144 | const error = { 145 | name: "INTERNAL_SERVER_ERROR", 146 | fullDescription: "An internal server error has occurred", 147 | paypalDebugId: headers.get("Paypal-Debug-Id"), 148 | }; 149 | 150 | throw new PayPalGooglePayError( 151 | error.name, 152 | error.fullDescription, 153 | error.paypalDebugId 154 | ); 155 | } 156 | return res.json(); 157 | }) 158 | .then(({ data, errors, extensions }) => { 159 | if (Array.isArray(errors) && errors.length) { 160 | const error = { 161 | name: errors[0]?.name || "GOOGLEPAY_PAYMENT_ERROR", 162 | fullDescription: errors[0]?.message ?? JSON.stringify(errors[0]), 163 | paypalDebugId: extensions?.correlationId, 164 | }; 165 | 166 | throw new PayPalGooglePayError( 167 | error.name, 168 | error.fullDescription, 169 | error.paypalDebugId 170 | ); 171 | } 172 | return data.approveGooglePayPayment; 173 | }) 174 | .catch((err) => { 175 | getLogger() 176 | .error(FPTI_TRANSITION.GOOGLEPAY_PAYMENT_ERROR) 177 | .track({ 178 | [FPTI_KEY.TRANSITION]: FPTI_TRANSITION.GOOGLEPAY_PAYMENT_ERROR, 179 | [FPTI_CUSTOM_KEY.ERR_DESC]: `Error: ${err.message}) }`, 180 | }) 181 | .flush(); 182 | 183 | throw err; 184 | }); 185 | } 186 | 187 | /** 188 | * Intiate 3DS Flow for User 189 | */ 190 | export function initiatePayerAction({ 191 | orderId, 192 | }: InitiatePayerActionParams): ZalgoPromise { 193 | const promise = new ZalgoPromise(); 194 | const threeds = getThreeDomainSecureComponent(); 195 | 196 | // $FlowIssue - need to fix this type 197 | const instance = threeds({ 198 | createOrder: () => orderId, 199 | onSuccess: (contingencyResult) => { 200 | logGooglePayEvent(FPTI_TRANSITION.GOOGLEPAY_TDS_SUCCESS); 201 | return promise.resolve({ 202 | liabilityShift: contingencyResult.liability_shift, 203 | }); 204 | }, 205 | onCancel: () => { 206 | logGooglePayEvent(FPTI_TRANSITION.GOOGLEPAY_TDS_CANCEL); 207 | return promise.resolve({ liabilityShift: "UNKNOWN" }); 208 | }, 209 | onError: (err) => { 210 | logGooglePayEvent(FPTI_TRANSITION.GOOGLEPAY_TDS_ERROR); 211 | logGooglePayEvent(err && err.message); 212 | return promise.resolve({ liabilityShift: "UNKNOWN" }); 213 | }, 214 | }); 215 | // $FlowIssue - need to fix this type 216 | return instance.renderTo(window, "body").then(() => promise); 217 | } 218 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | export * from "./component"; 4 | -------------------------------------------------------------------------------- /src/logging.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | import { getLogger } from "@paypal/sdk-client/src"; 4 | import { FPTI_KEY } from "@paypal/sdk-constants/src"; 5 | 6 | import { FPTI_TRANSITION, FPTI_CUSTOM_KEY } from "./constants"; 7 | 8 | export function logGooglePayEvent(event: string, payload: Object) { 9 | const data = payload || {}; 10 | 11 | getLogger() 12 | .info(`${FPTI_TRANSITION.GOOGLEPAY_EVENT}_${event}`, data) 13 | .track({ 14 | [FPTI_KEY.TRANSITION]: `${FPTI_TRANSITION.GOOGLEPAY_EVENT}_${event}`, 15 | [FPTI_CUSTOM_KEY.INFO_MSG]: JSON.stringify(data), 16 | }) 17 | .flush(); 18 | } 19 | -------------------------------------------------------------------------------- /src/mock.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable eslint-comments/disable-enable-pair */ 2 | /* eslint-disable flowtype/no-weak-types */ 3 | 4 | /* @flow */ 5 | export function googlePayConfig(): any { 6 | return { 7 | allowedPaymentMethods: [ 8 | { 9 | type: "CARD", 10 | parameters: { 11 | allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"], 12 | allowedCardNetworks: [ 13 | "AMEX", 14 | "DISCOVER", 15 | "JCB", 16 | "MASTERCARD", 17 | "VISA", 18 | ], 19 | }, 20 | tokenizationSpecification: { 21 | type: "PAYMENT_GATEWAY", 22 | parameters: { 23 | gateway: "paypalqa", 24 | gatewayMerchantId: "12345678901234567890", 25 | }, 26 | }, 27 | }, 28 | ], 29 | merchantInfo: { 30 | merchantId: "12345678901234567890", 31 | merchantOrigin: "stage-googlepay-paypal-js-sdk.herokuapp.com", 32 | merchantName: "paypal", 33 | }, 34 | }; 35 | } 36 | 37 | export function approveGooglePayPaymentWith3DS(): any { 38 | return { 39 | status: "PAYER_ACTION_REQUIRED", 40 | payment_source: null, 41 | links: [ 42 | { 43 | href: "https://sandbox.paypal.com/webapps/helios?action=verify&flow=3ds&cart_id=87669629F7083071T", 44 | rel: "payer-action", 45 | method: "GET", 46 | }, 47 | { 48 | href: "https://developer.paypal.com/docs/api/orders/v2/#error-PAYER_ACTION_REQUIRED", 49 | rel: "information_link", 50 | method: "GET", 51 | }, 52 | ], 53 | }; 54 | } 55 | -------------------------------------------------------------------------------- /src/types.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | import type { ZalgoPromise } from "@krakenjs/zalgo-promise/src"; 3 | 4 | export type OrderPayload = {| 5 | intent: string, 6 | purchase_units: $ReadOnlyArray<{| 7 | amount: {| currency_code: string, value: string |}, 8 | payee: {| merchant_id: string |}, 9 | |}>, 10 | |}; 11 | 12 | export type PayPalGooglePayErrorType = {| 13 | name: string, 14 | message: string, 15 | paypalDebugId: null | string, 16 | |}; 17 | 18 | export type ConfigResponse = {| 19 | allowedPaymentMethods: $ReadOnlyArray<{| 20 | parameters: {| 21 | allowedAuthMethods: $ReadOnlyArray, 22 | allowedCardNetworks: $ReadOnlyArray, 23 | |}, 24 | tokenizationSpecification: {| 25 | parameters: {| 26 | gateway: string, 27 | gatewayMerchantId: string, 28 | |}, 29 | type: string, 30 | |}, 31 | type: string, 32 | |}>, 33 | merchantInfo: {| 34 | authJwt: string, 35 | merchantId: string, 36 | merchantName: string, 37 | merchantOrigin: string, 38 | |}, 39 | |}; 40 | 41 | export type ApprovePaymentResponse = {| 42 | id: string, 43 | status: string, 44 | payment_source: {| 45 | google_pay: {| 46 | name: string, 47 | card: {| 48 | last_digits: string, 49 | type: string, 50 | brand: string, 51 | |}, 52 | |}, 53 | |}, 54 | links: $ReadOnlyArray<{| 55 | href: string, 56 | rel: string, 57 | method: string, 58 | |}>, 59 | |}; 60 | 61 | export type GooglePayPaymentContact = {| 62 | name: string, 63 | postalCode: string, 64 | countryCode: string, 65 | phoneNumber: string, 66 | address1: string, 67 | address2: string, 68 | address3: string, 69 | locality: string, 70 | administrativeArea: string, 71 | sortingCode: string, 72 | |}; 73 | 74 | export type AssuranceDetailsSpec = {| 75 | accountVerified: boolean, 76 | cardHolderAuthenticated: boolean, 77 | |}; 78 | 79 | export type CardInfo = {| 80 | cardDetails: string, 81 | cardNetwork: string, 82 | assuranceDetails: AssuranceDetailsSpec, 83 | billingAddress?: GooglePayPaymentContact, 84 | |}; 85 | 86 | export type GooglePayTokenizationData = {| 87 | type: string, 88 | token: string, 89 | |}; 90 | export type GooglePayPaymentMethodData = {| 91 | description: string | null, 92 | tokenizationData: GooglePayTokenizationData, 93 | type: string, 94 | info: CardInfo, 95 | |}; 96 | 97 | export type ConfirmOrderParams = {| 98 | paymentMethodData: GooglePayPaymentMethodData, 99 | orderId: string, 100 | shippingAddress?: GooglePayPaymentContact, 101 | billingAddress?: GooglePayPaymentContact, 102 | email?: string, 103 | |}; 104 | 105 | export type CreateOrderResponse = {| 106 | id: string, 107 | status: string, 108 | |}; 109 | 110 | export type InitiatePayerActionParams = {| 111 | orderId: string, 112 | |}; 113 | 114 | export type GooglePayType = {| 115 | config: () => Promise, 116 | confirmOrder: (ConfirmOrderParams) => Promise< 117 | ApprovePaymentResponse | PayPalGooglePayErrorType 118 | >, 119 | initiatePayerAction: ( 120 | initiatePayerActionParams: InitiatePayerActionParams 121 | ) => ZalgoPromise, 122 | |}; 123 | -------------------------------------------------------------------------------- /src/util.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | import { 4 | getPayPalDomain as getDefaultPayPalDomain, 5 | getPayPalAPIDomain as getDefaultPayPalAPIDomain, 6 | getEnv, 7 | } from "@paypal/sdk-client/src"; 8 | import { ENV } from "@paypal/sdk-constants/src"; 9 | 10 | import { LOCAL_HOST, API_HOST } from "./constants"; 11 | 12 | export class PayPalGooglePayError extends Error { 13 | paypalDebugId: null | string; 14 | errorName: string; 15 | constructor(name: string, message: string, paypalDebugId: null | string) { 16 | super(message); 17 | this.name = "PayPalGooglePayError"; 18 | this.errorName = name; 19 | this.paypalDebugId = paypalDebugId; 20 | } 21 | } 22 | 23 | export function getMerchantDomain(): string { 24 | const url = window.location.origin; 25 | return url.split("//")[1]; 26 | } 27 | 28 | export function getPayPalDomain(): string { 29 | return getEnv() === ENV.LOCAL ? LOCAL_HOST : getDefaultPayPalDomain(); 30 | } 31 | 32 | export function getPayPalAPIDomain(): string { 33 | return getEnv() === ENV.LOCAL ? API_HOST : getDefaultPayPalAPIDomain(); 34 | } 35 | 36 | export function getConfigQuery(): string { 37 | if (getEnv() === ENV.PRODUCTION) { 38 | return ` 39 | query getGooglePayConfig( 40 | $clientId: String! 41 | $merchantId: [String]! 42 | $merchantOrigin: String! 43 | ) { 44 | googlePayConfig( 45 | clientId: $clientId 46 | merchantId: $merchantId 47 | merchantOrigin: $merchantOrigin 48 | ){ 49 | isEligible 50 | apiVersion 51 | apiVersionMinor 52 | countryCode 53 | allowedPaymentMethods{ 54 | type 55 | parameters{ 56 | allowedAuthMethods 57 | allowedCardNetworks 58 | billingAddressRequired 59 | assuranceDetailsRequired 60 | billingAddressParameters { 61 | format 62 | } 63 | } 64 | tokenizationSpecification{ 65 | type 66 | parameters { 67 | gateway 68 | gatewayMerchantId 69 | } 70 | } 71 | } 72 | merchantInfo { 73 | merchantOrigin 74 | merchantId 75 | authJwt 76 | } 77 | } 78 | }`; 79 | } else { 80 | return ` 81 | query getGooglePayConfig( 82 | $clientId: String! 83 | $merchantId: [String]! 84 | $merchantOrigin: String! 85 | $buyerCountry: CountryCodes 86 | ) { 87 | googlePayConfig( 88 | clientId: $clientId 89 | merchantId: $merchantId 90 | merchantOrigin: $merchantOrigin 91 | buyerCountry: $buyerCountry 92 | ){ 93 | isEligible 94 | apiVersion 95 | apiVersionMinor 96 | countryCode 97 | allowedPaymentMethods{ 98 | type 99 | parameters{ 100 | allowedAuthMethods 101 | allowedCardNetworks 102 | billingAddressRequired 103 | assuranceDetailsRequired 104 | billingAddressParameters { 105 | format 106 | } 107 | } 108 | tokenizationSpecification{ 109 | type 110 | parameters { 111 | gateway 112 | gatewayMerchantId 113 | } 114 | } 115 | } 116 | merchantInfo { 117 | merchantOrigin 118 | merchantId 119 | } 120 | } 121 | }`; 122 | } 123 | } 124 | --------------------------------------------------------------------------------