feat: add Stripe payment handler for Google Pay token processing#57
Open
paiking1 wants to merge 2 commits intoUniversal-Commerce-Protocol:mainfrom
Open
feat: add Stripe payment handler for Google Pay token processing#57paiking1 wants to merge 2 commits intoUniversal-Commerce-Protocol:mainfrom
paiking1 wants to merge 2 commits intoUniversal-Commerce-Protocol:mainfrom
Conversation
Adds a real PSP integration showing how to process Google Pay payment tokens through Stripe. Currently all payment handlers in the sample accept tokens without contacting a PSP — this shows the actual "last mile" every merchant needs. Changes: - New payment_handlers/stripe_handler.py with full Stripe error handling - Updated _process_payment to route google_pay to Stripe when configured - Updated discovery_profile.json with Stripe tokenization parameters - Added stripe as optional dependency - Added "Using Stripe as PSP" section to README Zero breaking changes: without STRIPE_SECRET_KEY, behavior is unchanged.
15 tests covering: - Configuration gating (is_configured, missing env var) - Successful PaymentIntent creation with mocked Stripe - Error handling for all Stripe exception types: CardError (402), InvalidRequestError (400), RateLimitError (429), APIConnectionError (503), generic StripeError (500) - Non-success statuses: requires_action (3DS), unexpected status - Currency normalization (USD -> usd) - Lazy import with clear error when stripe package missing - Live integration tests (skipped without STRIPE_SECRET_KEY): tok_visa succeeds, tok_chargeDeclined fails Run unit tests (no Stripe key needed): uv run pytest payment_handlers/test_stripe_handler.py -v Run all tests including live Stripe API: STRIPE_SECRET_KEY=sk_test_... uv run pytest payment_handlers/test_stripe_handler.py -v
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
504779a to
2bf9988
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey Google!
My name is Gal, I'm an ex-Googler myself, currently working at Sellersnap and we're very excited for the UCP launch, and we're currently in the waitlist.
Sellersnap is a company that provides repricing services for E-Commerce, so we're looking forward to allow our seller's items appear in Gemini. Let me know if it's possible for us to join the Beta asap, because we already have the core necessary logic implemented!
Below I'm sharing a PR to add Stripe support, because we've already implemented it in our codebase for UCP integration. Let me know what you think.
Thanks!
Summary
payment_handlers/stripe_handler.py) that processes Google Pay credential tokens through StripePaymentIntent.creategoogle_payhandler in_process_paymentto Stripe whenSTRIPE_SECRET_KEYis set, falls back to existing mock behavior otherwisediscovery_profile.jsonwith Stripe tokenization gateway parametersstripe>=7.0.0as optional dependencyThis is the "last mile" that every merchant implementing UCP with a real PSP needs — the sample currently accepts Google Pay tokens without contacting a PSP. This PR shows the complete
credential.token → stripe.PaymentIntent.create()flow.Zero breaking changes: without
STRIPE_SECRET_KEY, the server behaves exactly as before.How to use
Tests
Test plan
sk_test_*keypi_3T92T6KCyqI7L8TF0fm9FvWn)/.well-known/ucpshows Stripe tokenization configsimple_happy_path_client.pystill works (steps 0–6, backward compatible)STRIPE_SECRET_KEY, google_pay tokens accepted as before (mock fallback)🤖 Generated with Claude Code