charge
Create payment requests, invoices, or QR codes for transactions by specifying amount, currency, and customer details.
Instructions
Create a payment request, invoice, or QR code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount in cents | |
| currency | No | ISO 4217 currency code | BRL |
| description | No | What the charge is for | |
| customer_email | No | Customer email | |
| customer_name | No | Customer name | |
| expires_in | No | Seconds until expiry | |
| provider | No | Force a specific provider |
Implementation Reference
- src/providers/woovi.ts:152-187 (handler)The `charge` method in `WooviProvider` acts as the handler for the charge tool. It prepares the request body, sends a POST request to the Woovi API, and parses the response.
async charge(req: ChargeRequest): Promise<ChargeResult> { const correlationID = req.correlation_id ?? `junto-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; const body: Record<string, unknown> = { value: req.amount, correlationID, comment: req.description ?? "Charge via Junto", }; if (req.expires_in) { body.expiresIn = req.expires_in; } if (req.customer_name || req.customer_email) { body.customer = { name: req.customer_name, email: req.customer_email, }; } const raw = await this.request("POST", "/charge", body); const data = WooviChargeResponse.parse(raw); return { id: correlationID, status: data.charge.status ?? "ACTIVE", provider: this.name, amount: req.amount, currency: "BRL", payment_link: data.charge.paymentLinkUrl, qr_code: data.charge.qrCodeImage, br_code: data.brCode ?? data.charge.brCode, timestamp: new Date().toISOString(), }; }