$npx -y skills add binance/binance-skills-hub --skill paymentBinance Pay Assistant - Send and Receive crypto payments. Send: QR code payment from Funding Wallet (C2C + PIX). Use when user wants to buy/purchase/pay/transfer/send, confirm/cancel payment, or query order status. Requires QR code data. PIX QR codes (pix, br.gov.bcb.pix) are aut
| 1 | ## ⚠️ CRITICAL: How to Handle QR Images |
| 2 | |
| 3 | **When user sends a QR code image or asks to pay:** |
| 4 | |
| 5 | ### Step 0: Check if user provided a PAYMENT LINK (text, not an image) |
| 6 | If the user provided **text** (not an image), and the text is a URL containing |
| 7 | `app.binance.com/uni-qr/` or `app.binance.com/qr/`: |
| 8 | |
| 9 | → This is a payment link. Skip all decode steps. Go directly to purchase: |
| 10 | ```bash |
| 11 | python3 payment_skill.py --action purchase --raw_qr "<the URL text>" |
| 12 | ``` |
| 13 | |
| 14 | Otherwise (user sent an image, or text doesn't match above) → continue to Step 1. |
| 15 | |
| 16 | ### Step 1: Try to READ the QR data directly (Vision) |
| 17 | Look at the QR code image and try to extract the actual data string (URL or EMV code). |
| 18 | - If you can read it → `--action purchase --raw_qr "<DATA>"` |
| 19 | - If you cannot read the data (only see logo/colors) → Go to Step 2 |
| 20 | |
| 21 | ### Step 2: Check for image file path |
| 22 | Does your platform provide the image attachment path in message metadata? |
| 23 | - If YES → `--action decode_qr --image "<PATH>"` |
| 24 | - If NO → Go to Step 3 |
| 25 | |
| 26 | ### Step 3: Ask user for help (DO NOT auto-use clipboard!) |
| 27 | ``` |
| 28 | "I cannot read the QR directly. Please copy to clipboard, then reply 'use clipboard'" |
| 29 | ``` |
| 30 | (Translate to user's language as needed) |
| 31 | |
| 32 | ### Step 4: Only after user confirms → use clipboard |
| 33 | ```bash |
| 34 | python3 payment_skill.py --action decode_qr --clipboard |
| 35 | ``` |
| 36 | |
| 37 | --- |
| 38 | |
| 39 | **⛔ FORBIDDEN:** |
| 40 | - ❌ `--clipboard` without user explicitly saying "use clipboard" |
| 41 | - ❌ Guessing or searching for image files |
| 42 | - ❌ Skipping the "ask user" step |
| 43 | |
| 44 | **✅ REQUIRED after decode_qr succeeds:** |
| 45 | - Tell user the image source (e.g., "Decoded from clipboard" or "Decoded from file: xxx.jpg") |
| 46 | - Include `source_type` from response in your message to user |
| 47 | |
| 48 | --- |
| 49 | |
| 50 | ## 🚀 Quick Start - Agent MUST Execute |
| 51 | |
| 52 | **When user sends a QR code image or asks to pay:** |
| 53 | |
| 54 | ### Step 1 - Get QR Data (Choose ONE method) |
| 55 | |
| 56 | **Method A: AI Vision (BEST - if your platform supports it)** |
| 57 | ``` |
| 58 | 1. Use your vision capability to read the QR code content directly from the image |
| 59 | 2. Skip decode_qr entirely, go straight to purchase with the QR data |
| 60 | ``` |
| 61 | ```bash |
| 62 | python3 payment_skill.py --action purchase --raw_qr "https://app.binance.com/uni-qr/xxx" |
| 63 | ``` |
| 64 | |
| 65 | **Method B: decode_qr with explicit image path (RECOMMENDED)** |
| 66 | ```bash |
| 67 | # Use the attachment path your platform provides |
| 68 | python3 payment_skill.py --action decode_qr --image "/path/to/attachment.jpg" |
| 69 | ``` |
| 70 | |
| 71 | **Method C: decode_qr from clipboard (Only when user explicitly says "use clipboard")** |
| 72 | ```bash |
| 73 | python3 payment_skill.py --action decode_qr --clipboard |
| 74 | ``` |
| 75 | |
| 76 | **Method D: decode_qr with base64 (For platforms that provide base64 image data)** |
| 77 | ```bash |
| 78 | python3 payment_skill.py --action decode_qr --base64 "iVBORw0KGgo..." |
| 79 | ``` |
| 80 | |
| 81 | ### Step 2 - Purchase (IMMEDIATELY after getting QR data) |
| 82 | ```bash |
| 83 | python3 payment_skill.py --action purchase --raw_qr "DECODED_QR_DATA" |
| 84 | ``` |
| 85 | |
| 86 | ### Step 3 - Set amount (if needed) |
| 87 | ```bash |
| 88 | python3 payment_skill.py --action set_amount --amount NUMBER |
| 89 | ``` |
| 90 | |
| 91 | ### Step 4 - Confirm payment (after user confirms) |
| 92 | ```bash |
| 93 | python3 payment_skill.py --action confirm |
| 94 | ``` |
| 95 | |
| 96 | ⚠️ **IMPORTANT**: After decode succeeds, IMMEDIATELY proceed to purchase. Do NOT stop and ask "Would you like to proceed?" - the user already said they want to pay. (Note: This applies to the `decode → purchase` transition only. You MUST still ask for explicit user confirmation before calling `pay_confirm`.) |
| 97 | |
| 98 | --- |
| 99 | |
| 100 | ## 📦 Prerequisites |
| 101 | |
| 102 | Requires Python 3.8+ with these packages: |
| 103 | - `opencv-python` - QR code decoding |
| 104 | - `pyzbar` - Barcode/QR detection (requires zbar system library) |
| 105 | - `Pillow` - Image processing |
| 106 | - `requests` - API calls |
| 107 | |
| 108 | **Install Python packages:** |
| 109 | ```bash |
| 110 | pip install -r requirements.txt |
| 111 | ``` |
| 112 | |
| 113 | **System dependency for pyzbar:** |
| 114 | - macOS: `brew install zbar` |
| 115 | - Linux (Debian/Ubuntu): `apt install libzbar0` |
| 116 | - Windows: Usually works without extra setup |
| 117 | |
| 118 | If you see "No QR decoder available", ensure both Python packages and system dependencies are installed. |
| 119 | |
| 120 | ## ⛔ STOP - READ THIS FIRST (Agent MUST Follow) |
| 121 | |
| 122 | **Before executing ANY command, you MUST follow these rules:** |
| 123 | |
| 124 | ### ❌ NEVER DO |
| 125 | |
| 126 | 1. **NEVER** use placeholder data like `'QR_CODE_DATA'` or `'test'` - you must decode actual data from the QR image first |
| 127 | 2. **NEVER** skip phases - follow the 3-step flow in order |
| 128 | 3. **NEVER** add extra command-line flags unless documented |
| 129 | 4. **NEVER** write inline Python/bash scripts to decode QR codes yourself. ALWAYS use `python3 payment_skill. |