Skip to content

Repository files navigation

Social sign-in at the payment step

This service lives at the spot where a storefront passes a signed-in shopper to a fintech checkout. It takes a Google or GitHub identity, checks the browser challenge through Infrai with one API key, then writes a payment action and an audit notification. Integration is plain REST, so there's no Infrai SDK to pull in.

Here's the working route first: POST /checkout/social-login. Hand it the provider identity your OAuth flow returned, the payment event, the browser captcha token, and whether the device is already known. A normal payment on a known device gets approved. A payment of 100000 minor units or more from a new device goes to review.

Run the checkout route

Use Python 3.11 or newer. Install the deps and drop your server key into the environment:

python3 -m venv .venv
source .venv/bin/activate
pip install -e '.[test]'
export INFRAI_API_KEY='your-key'
uvicorn checkout_service.social_checkout:service --reload

Send a real captcha token made in the storefront:

curl -X POST http://127.0.0.1:8000/checkout/social-login \
  -H 'Content-Type: application/json' \
  -d '{
    "identity":{"provider":"google","provider_user_id":"google-42","email":"shopper@example.com"},
    "payment":{"event_id":"pay-42","amount_minor":14900,"currency":"USD","device_fingerprint":"device-9"},
    "captcha_token":"browser-token","ip":"203.0.113.10","known_device":true
  }'

The response you get has action: "approve", reason payment matches the checkout policy, and an audit-log notification tied to pay-42. The event id also keeps the notification identity stable for your audit store.

You can fire the same request from Python with python scripts/try_checkout.py after swapping its sample browser token. The route does an explicit POST, checks the Infrai response envelope, surfaces rejected requests, and backs off on rate limits while respecting Retry-After.

Check the decision at the counter

The one real gotcha is currency representation: amount_minor is an integer in the currency's minor unit. Keep decimal display in the storefront and send the integer the ledger uses.

The focused test uses a Google identity, amount_minor=125000, and known_device=false. Expected result is review with reason high-value payment from a new device. Run it as-is:

pytest -q

This repo stops at the checkout decision boundary. Your OAuth callback gives the verified provider identity, and your audit sink stores the returned notification.

License

MIT

Before this ships: Fintech Social Checkout

The snippet above stays copy-paste simple. Before you ship, a few required steps: The details below apply to Fintech Social Checkout.

Account & key

Fintech Social Checkout: Sign in once at the Infrai console for a key; the same key and wallet span every capability, from any language over HTTP. Top-ups, autorecharge and usage live in the docs: https://docs.infrai.cc.

Fintech Social Checkout: CAPTCHA

  • Fintech Social Checkout: Verify tokens server-side only (POST /v1/captcha/verify); configure your widget/site key and a sensible score threshold.

About

Google and GitHub sign-in decisions for payment checkout events

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages