Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reddit-ucashpay

A Reddit bot that replies with U.CASH Pay checkout links. Non-custodial: the bot never holds funds. It parses payment commands from comments, submissions, and private messages, and replies with a pay.u.cash checkout link the user can click to pay in crypto.

How it works

Redditors mention the bot and issue a command:

u/your_bot !pay 5 USD Coffee
u/your_bot !pay 0.001 BTC Tip jar
u/your_bot !pay 20

Command syntax:

!pay <amount> [currency] [title]
  • amount (required): numeric, supports decimals (e.g. 5, 0.001, 19.99).
  • currency (optional): a currency code, defaults to USD (or UXCASH_DEFAULT_CURRENCY).
  • title (optional): free text that becomes the checkout title.

The bot replies with a pay.u.cash checkout link built from the store Cloud Token and the parsed parameters.

Where it listens

  • Mentions: comments and submissions anywhere on Reddit that mention the bot's username (u/your_bot).
  • Private messages (DMs): unread messages sent directly to the bot.

Each handled item is replied to once; handled Reddit item ids are kept in an in-process set to avoid duplicate replies within a run.

Pay link modes

The bot supports two modes for producing the checkout link:

  1. Client-side hosted link (default): builds a GET https://pay.u.cash/embed.php URL with query params cloud, amount, currency, title, external_reference, and redirect. The store Cloud Token is publishable and safe to embed in a link the user opens in their browser. No server secret is required.

  2. Server-side tracked checkout (opt-in): when UXCASH_TRACK_SERVER=1, the bot also calls POST https://pay.u.cash/payment/ajax.php with function=create-transaction, amount, currency_code, cryptocurrency_code (empty), external_reference, title, redirect, cloud, and idempotent=1. This creates a tracked, idempotent checkout and the bot replies with the returned payment URL. Enable this when you want each checkout recorded server-side under a stable external_reference.

Requirements

Setup

  1. Create a virtual environment and install dependencies:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
  2. Create a Reddit "script" app at https://www.reddit.com/prefs/apps:

    • Name it whatever you like.
    • Set the redirect URI to http://localhost:8080.
    • Note the client id (under the app name) and client secret.
  3. Copy .env.example to .env and fill in your credentials:

    cp .env.example .env

    Set UXCASH_CLOUD_TOKEN to your store Cloud Token from pay.u.cash.

  4. Run the bot:

    python bot.py

Configuration

All configuration is via environment variables (see .env.example):

Variable Required Description
REDDIT_CLIENT_ID yes Reddit app client id
REDDIT_CLIENT_SECRET yes Reddit app client secret
REDDIT_USERNAME yes Bot Reddit username
REDDIT_PASSWORD yes Bot Reddit password
REDDIT_USER_AGENT no Descriptive user agent string
UXCASH_CLOUD_TOKEN yes Store Cloud Token from pay.u.cash (publishable)
UXCASH_REDIRECT no Redirect URL after payment
UXCASH_TRACK_SERVER no 1 to also create a server-side tracked checkout. Default 0
UXCASH_DEFAULT_CURRENCY no Default currency when the command omits one. Default USD
UXCASH_POLL_SECONDS no Seconds between polls. Default 60

Usage

Once the bot is running and logged in, any user (including yourself for testing) can summon it. Example commands:

u/your_bot !pay 10 USD Server hosting
u/your_bot !pay 0.5
u/your_bot !pay 2.50 EUR Espresso

The bot replies with a markdown link to the pay.u.cash checkout.

Set up your pay.u.cash account

  1. Sign up at pay.u.cash, then click the verification link in the email.
  2. Set receive addresses under Settings -> Addresses (raw address, ENS, Unstoppable Domains, or FIO).
  3. Create a store under Account -> Stores and copy its Store Cloud Token (use the store-level token, not the account-wide one).
  4. For fiat cards, connect your own Stripe under Settings -> Payment processors.

Limitations

  • Custody: This bot is non-custodial. It only constructs and posts pay.u.cash checkout links; funds go directly to the store's configured receive addresses.
  • Recurring billing: pay.u.cash does not support automatic crypto recurring billing, so the bot only creates one-time checkout links per command.
  • Reddit rate limits: Replies are subject to Reddit's rate limits and the bot's account karma. The poll interval (UXCASH_POLL_SECONDS) should be kept reasonable to avoid throttling.
  • Dedup scope: Handled item ids are tracked in memory for the lifetime of a single process. Restarting the process re-reads from skip_existing=True streams, so already-handled items won't be reprocessed after a restart.

Security notes

  • The store Cloud Token is publishable and intended for client-side use (it is safe in the browser and in a posted link). It is not a server secret.
  • Reddit credentials are secrets. Keep .env out of version control (it is gitignored). Never hard-code them.
  • UXCASH_TRACK_SERVER=1 makes outbound server requests to pay.u.cash with your Cloud Token; this is expected and safe.

License

MIT. See LICENSE.

About

Reddit bot that replies with U.CASH Pay checkout links. Non-custodial.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages