{"id":28576340,"url":"https://github.com/google-pay/compose-pay-button","last_synced_at":"2025-06-10T23:40:15.460Z","repository":{"id":164368467,"uuid":"638035588","full_name":"google-pay/compose-pay-button","owner":"google-pay","description":"An Android library that provides a Jetpack Compose wrapper on top of the Google Pay Button API.","archived":false,"fork":false,"pushed_at":"2025-05-26T11:48:52.000Z","size":787,"stargazers_count":38,"open_issues_count":6,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-26T12:54:53.595Z","etag":null,"topics":["google-pay","jetpack-compose"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google-pay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-05-09T00:26:44.000Z","updated_at":"2025-05-26T11:44:47.000Z","dependencies_parsed_at":"2023-12-12T17:59:40.121Z","dependency_job_id":"7c9c60f7-9d6c-4626-99d2-4ab83dd46999","html_url":"https://github.com/google-pay/compose-pay-button","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-pay%2Fcompose-pay-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-pay%2Fcompose-pay-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-pay%2Fcompose-pay-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-pay%2Fcompose-pay-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google-pay","download_url":"https://codeload.github.com/google-pay/compose-pay-button/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-pay%2Fcompose-pay-button/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259172148,"owners_count":22816514,"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":["google-pay","jetpack-compose"],"created_at":"2025-06-10T23:40:14.551Z","updated_at":"2025-06-10T23:40:15.439Z","avatar_url":"https://github.com/google-pay.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Pay button for Jetpack Compose\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.google.pay.button/compose-pay-button)](https://search.maven.org/search?q=g:com.google.pay.button)\n\nAn Android library that provides a [Jetpack Compose](https://developer.android.com/jetpack/compose) wrapper on top of the\n[Google Pay Button API](https://developers.google.com/pay/api/android/guides/tutorial).\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"pay-buttons.png\" width=\"250\" alt=\"Pay button variations\"\u003e\n\u003c/p\u003e\n\n## Installation\n\nThe library is hosted on Maven central and can be used by ensuring the following lines exist in each gradle file:\n\n**build.gradle:**\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n```\n\n**app/build.gradle:**\n\n```\ndependencies {\n    implementation \"com.google.pay.button:compose-pay-button:\u003cversion\u003e\"\n}\n```\n\n## Usage\n\n```kotlin\n// other imports omitted for brevity\n// see full example in the \"app\" directory\n\nimport com.google.pay.button.ButtonTheme\nimport com.google.pay.button.ButtonType\nimport com.google.pay.button.PayButton\n\nclass MainActivity : ComponentActivity() {\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        val onClick = { println(\"Button clicked\") }\n\n        // as per https://developers.google.com/pay/api/android/reference/request-objects#PaymentMethod\n        val allowedPaymentMethods = \"\"\"\n            [\n              {\n                \"type\": \"CARD\",\n                \"parameters\": {\n                  \"allowedAuthMethods\": [\"PAN_ONLY\", \"CRYPTOGRAM_3DS\"],\n                  \"allowedCardNetworks\": [\"AMEX\", \"DISCOVER\", \"JCB\", \"MASTERCARD\", \"VISA\"]\n                },\n                \"tokenizationSpecification\": {\n                  \"type\": \"PAYMENT_GATEWAY\",\n                  \"parameters\": {\n                    \"gateway\": \"example\",\n                    \"gatewayMerchantId\": \"exampleGatewayMerchantId\"\n                  }\n                }\n              }\n            ]\n        \"\"\".trimIndent()\n\n        setContent {\n            // Default\n            PayButton(onClick = onClick, allowedPaymentMethods = allowedPaymentMethods)\n\n            // Customized look\n            PayButton(\n                onClick = onClick,\n                allowedPaymentMethods = allowedPaymentMethods,\n                radius = 1.dp,\n                modifier = Modifier.width(200.dp),\n                theme = ButtonTheme.Light\n            )\n\n            // Customized labels\n            PayButton(onClick = onClick, allowedPaymentMethods = allowedPaymentMethods, type = ButtonType.Book)\n            PayButton(onClick = onClick, allowedPaymentMethods = allowedPaymentMethods, type = ButtonType.Subscribe)\n            PayButton(onClick = onClick, allowedPaymentMethods = allowedPaymentMethods, type = ButtonType.Donate)\n        }\n    }\n}\n```\n\n## Error handling and Fallback UI\n\nThe `PayButton` composable wraps the underlying `PayButton` Android View, which may encounter errors during initialization. To handle these situations, the `PayButton` composable provides:\n\n*   **`onError` Callback:** Invoked when an error occurs during the button's initialization. This callback receives the `Throwable` that caused the error, allowing you to log it or take other actions.\n*   **`fallbackUi` Composable:** An optional composable function that is displayed in place of the button if an error occurs. If not provided, nothing will be displayed in case of error.\n\nThis mechanism ensures that your app can gracefully handle potential issues with the `PayButton` and provide a fallback experience to the user.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle-pay%2Fcompose-pay-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle-pay%2Fcompose-pay-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle-pay%2Fcompose-pay-button/lists"}