{"id":18683097,"url":"https://github.com/foxy/foxy-node-google-pay-decrypt","last_synced_at":"2026-02-13T00:02:16.390Z","repository":{"id":206273378,"uuid":"707620475","full_name":"Foxy/foxy-node-google-pay-decrypt","owner":"Foxy","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-06T21:45:01.000Z","size":207,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T21:00:55.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Foxy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-20T09:42:26.000Z","updated_at":"2025-02-06T21:45:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"3d89cb03-4c5e-4133-aec3-e55c21668f4c","html_url":"https://github.com/Foxy/foxy-node-google-pay-decrypt","commit_stats":{"total_commits":19,"total_committers":4,"mean_commits":4.75,"dds":0.631578947368421,"last_synced_commit":"552d3a01ea136137808f066eb1b89864428efb49"},"previous_names":["foxy/foxy-node-google-pay-decrypt"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxy%2Ffoxy-node-google-pay-decrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxy%2Ffoxy-node-google-pay-decrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxy%2Ffoxy-node-google-pay-decrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxy%2Ffoxy-node-google-pay-decrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Foxy","download_url":"https://codeload.github.com/Foxy/foxy-node-google-pay-decrypt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248111871,"owners_count":21049577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T10:13:44.609Z","updated_at":"2026-02-13T00:02:16.333Z","avatar_url":"https://github.com/Foxy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Pay Decrypt\n\nThis package allows you to decrypt a token received from Google Pay.\n\nThis works in `node` and not on a browser, as it requires the built-in `crypto` package and secret keys (`.pem` files), which should never exist on the client anyway.\n\nThe decryption methodology of this package is largely taken from the [Python Google Pay Token Decryption](https://github.com/yoyowallet/google-pay-token-decryption).\n\n## Getting Started\n\n```sh\nnpm i @foxy.io/google-pay-decrypt\n```\n\nIn order to decrypt the token, you will need the `.pem` file, the gateway id, and Google signing keys.\nIn order to get the Google signing keys you will have to fetch them from one of the two URLs. You have the sandbox URL https://payments.developers.google.com/paymentmethodtoken/test/keys.json or the production URL https://payments.developers.google.com/paymentmethodtoken/keys.json.\n\n\nAnd a key (`privatePem.pem`) that looks something like this:\n\n```\n-----BEGIN EC PRIVATE KEY-----\n7G3PLjvRkmLcZd1H4CX6XbE7nrMrUU4tJc1sO5Cs0n4gnncYbJoTJXLIYN3o4FXL\n9T33p5TtiTh4pkBzsj8zRHWeFrJoRaitZmnVBAL5u2v9f98d8mwN4uhP5bsS7lwa\nGQPYeVaMGHaWQctQbQx26D1C5oGcPir3LP==\n-----END EC PRIVATE KEY-----\n\n```\n\n## Usage\n\nThe token that you get from Google Pay will look something like this:\n```js\n{\n    \"signature\": \"MEYCIQD...\u003ca lot more data\u003e...9GwgIhALJ/5PrBogdma+aft/ZEU0UYklTEteJYrkbphfeg4FpW\",\n    \"intermediateSigningKey\": {\n        \"signedKey\": \"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0D...\u003ca lot more data\u003e...Qn1GLn9rh33FVdUadzkZc2b4oTCKA\\\\u003d\\\\u003d\\\",\\\"keyExpiration\\\":\\\"1698424300849\\\"}\",\n        \"signatures\": [\n            \"MEQCIAmx8FHGQs9jRTlacoUSD7T969Vz77+...\u003ca lot more data\u003e...mWh5f8qds+K6e+kL4wxdi/FswUQ==\"\n        ]\n    },\n    \"protocolVersion\": \"ECv2\",\n    \"signedMessage\": \"{\\\"encryptedMessage\\\":\\\"zA3SNtOdi...\u003ca lot more data\u003e...FhfKXNjcxz1LkEvTFKir8NFyoLf+Gbxcf7u3eNllgGwiTbjm1FlJAZHHy6WiNg\\\\u003d\\\",\\\"ephemeralPublicKey\\\":\\\"BDDaWyJv0u9DdWWosdYI...\u003ca lot more data\u003e...D8qntQO/3jhrMemajE4pI\\\\u003d\\\",\\\"tag\\\":\\\"lfEFA5...\u003ca lot more data\u003e...2bRGyS+yESzrqQ0\\\\u003d\\\"}\"\n}\n```\n\nTo decrypt the token, import the `.pem` file, fetch the Google singing keys and create a new `GooglePaymentToken` with the token from Google Pay. Then decrypt using the keys.\n\n```js\nconst use_sandbox = false;\nconst rootSigningKeysUrl = use_sandbox ? 'https://payments.developers.google.com/paymentmethodtoken/test/keys.json' : 'https://payments.developers.google.com/paymentmethodtoken/keys.json';\nfetch(rootSigningKeysUrl).then(async (result) =\u003e {\n    const key = file.readFileSync('/path/to/key.pem');\n    const rootSigningKeys = await result.json();\n    const token = new GooglePaymentToken(rootSigningKeys.keys, 'gatewayId', key);\n    const decryptedToken = token.decrypt(data);\n    console.log(decryptedToken);\n}).catch((err) =\u003e {\n    console.log(err);\n});\n```\n\nThe `decrypted` value at this point should look something like this:\n\n```js\n{\n  messageExpiration: '169832356723',\n  messageId: 'GQPYeVaMGHaWQctQbQx26D1C5oGcPir3LPGQPYeVaMGHaWQctQbQx26D1C5oGcPir3LPGQPYeVaMGHaWQctQbQx26D1C5oGcPir3LPGQPYeVaMGHaWQctQbQx26D1C5oGcPir3LPGQPYeVaMGHaWQctQbQx26D1C5oGcPir3LP',\n  paymentMethod: 'CARD',\n  paymentMethodDetails: {\n    expirationYear: 2028,\n    expirationMonth: 8,\n    pan: '4111111111111111',\n    authMethod: 'PAN_ONLY'\n  }\n}\n```\n\nYou can then use those decrypted values with your payment processor of choice (Stripe, Braintree, et al) to process payments from Google Pay. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxy%2Ffoxy-node-google-pay-decrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxy%2Ffoxy-node-google-pay-decrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxy%2Ffoxy-node-google-pay-decrypt/lists"}