WordPress — a payment plugin built by AI
A prompt for ChatGPT / Claude. It generates a plug-and-play WordPress plugin
that adds a [tegro_pay amount="500" desc="..."] shortcode —
so you can drop a payment button into any page or post.
Prompt
Paste it into ChatGPT / Claude. The reply will be the full plugin code.
Create a WordPress plugin "Tegro.Money Pay" — a single PHP plugin file (a .zip archive is fine).
Functionality:
1) Registers a settings page in the WordPress admin (Settings → Tegro.Money) with fields:
- Shop ID (text)
- API Key (password)
- Test mode (checkbox — while enabled, send orders flagged as "test")
2) Adds a shortcode [tegro_pay amount="500" desc="Product description" currency="RUB"]
— renders a "Pay" button on the page.
On click it makes an AJAX request to admin-ajax.php?action=tegro_create_order,
and the server-side function:
- Reads shop_id and api_key from settings
- Builds the body: {shop_id, nonce: wp_generate_uuid4(), currency, amount, order_id: wp_generate_uuid4(), description}
- body_string = wp_json_encode(body)
- sign = hash_hmac('sha256', body_string, $api_key)
- HTTP POSTs to https://tegro.money/api/createOrder/ via wp_remote_post, with header Authorization: Bearer <sign>
- the request body is EXACTLY body_string (do NOT json_encode it again)
- Parses the response. If type=success — returns data.url. Otherwise — an error.
3) Page-side JS — after the response, does window.location.href = data.url.
4) Registers a POST /wp-json/tegro/v1/notify endpoint to receive the webhook from Tegro.Money:
- Parses the form-urlencoded body
- Verifies the signature per the docs at https://tegro.money/docs/en/payments/notify/
- Stores the order in a custom post type "tegro_order" with its status
5) In the admin — Tegro.Money → Orders, a table of all received payments.
Requirements:
- Compatible with WordPress 6.x and PHP 8.1+
- No third-party Composer dependencies (WordPress functions + PHP core only)
- i18n-ready (text domain 'tegro-money')
- README.txt in wordpress.org format
- Security: nonce check in the admin, sanitize all POST input, escape all output
- No eval / curl_exec — wp_remote_post only
File structure:
tegro-money-pay/
├── tegro-money-pay.php (main plugin file)
├── README.txt
├── includes/
│ ├── class-admin.php
│ ├── class-shortcode.php
│ ├── class-api.php (Tegro API calls + HMAC sign)
│ └── class-webhook.php
└── assets/
└── pay.js
At the end, give instructions on how to package it into a zip and install it.
After it's generated
- Save the files into
wp-content/plugins/tegro-money-pay/on your WordPress install. - In the admin: Plugins → Activate "Tegro.Money Pay".
- Settings → Tegro.Money — paste your Shop ID and API Key from your merchant cabinet.
- Enable test mode until your first live payment.
- Drop
[tegro_pay amount="500" desc="Subscription"]into any page or post. - In the shop settings, set
notify_url = https://<your-site>/wp-json/tegro/v1/notify.
Not a vibe-coder? Once the AI generates the code, ask it to bundle everything into a single .zip archive — then install it through the standard WordPress installer.