### Install laravel-tolt via Composer Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Installs the laravel-tolt package via Composer. ```bash composer require jeffersongoncalves/laravel-tolt ``` -------------------------------- ### Add a new endpoint to Tolt.php Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/resources/boost/skills/laravel-tolt-development/SKILL.md Add a public method to src/Tolt.php that calls the private get() helper. Wrap the payload in withProgram() if the endpoint requires a program. ```php public function newEndpoint(string $id): array { return $this->get("/new-endpoint/{$id}"); } ``` -------------------------------- ### Partner CRUD operations Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Performs CRUD operations on partners: list by group, get, create, update, and delete. ```php Tolt::listPartners(['group_id' => 'grp_1']); Tolt::getPartner('part_1'); Tolt::createPartner([ 'first_name' => 'Jane', 'last_name' => 'Doe', 'email' => 'jane@example.com', 'payout_method' => 'paypal', 'notify_partner' => true, ]); Tolt::updatePartner('part_1', ['status' => 'suspended']); Tolt::deletePartner('part_1'); ``` -------------------------------- ### Customer CRUD operations Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Performs CRUD operations on customers: list by status, get, create, update, and delete. ```php Tolt::listCustomers(['status' => 'active']); Tolt::getCustomer('cus_1'); Tolt::createCustomer([ 'email' => 'john@example.com', 'partner_id' => 'part_1', 'subscription_id' => 'sub_123', 'status' => 'trialing', ]); Tolt::updateCustomer('cus_1', ['status' => 'active']); Tolt::deleteCustomer('cus_1'); ``` -------------------------------- ### Link CRUD operations Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Performs CRUD operations on links: list by partner, get, create, update, and delete. ```php Tolt::listLinks(['partner_id' => 'part_1']); Tolt::getLink('lnk_1'); Tolt::createLink([ 'param' => 'via', 'value' => 'jane', 'partner_id' => 'part_1', ]); Tolt::updateLink('lnk_1', ['value' => 'jane-new']); Tolt::deleteLink('lnk_1'); ``` -------------------------------- ### Publish tolt-config Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Optionally publishes the package configuration file. ```bash php artisan vendor:publish --tag="tolt-config" ``` -------------------------------- ### List customers with pagination options Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/resources/boost/skills/laravel-tolt-development/SKILL.md Every list*() method accepts a query array with limit (default 10, max 100), starting_after, ending_before, order, expand, created_gte, and created_lte. ```php Tolt::listCustomers(['limit' => 50, 'starting_after' => 'cus_100']); ``` -------------------------------- ### tolt.php configuration Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Configuration file for the package, reading environment variables for API key, program ID, and base URL with a default of https://api.tolt.com/v1. ```php // config/tolt.php return [ 'api_key' => env('TOLT_API_KEY'), 'program_id' => env('TOLT_PROGRAM_ID'), 'base_url' => env('TOLT_BASE_URL', 'https://api.tolt.com/v1'), ]; ``` -------------------------------- ### List programs Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Lists all programs using the configured program ID. ```php Tolt::listPrograms(); ``` -------------------------------- ### Import Tolt facade and exception Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Import the Tolt facade and exception class before using any Tolt API methods. ```php use JeffersonGoncalves\Tolt\Exceptions\ToltException; use JeffersonGoncalves\Tolt\Facades\Tolt; ``` -------------------------------- ### List customers with program_id from config or explicit Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/resources/boost/skills/laravel-tolt-development/SKILL.md List endpoints require a program_id. The private withProgram() helper uses config('tolt.program_id') unless the query array already has one. Explicit program_id wins. ```php Tolt::listCustomers(); // uses config('tolt.program_id') Tolt::listCustomers(['program_id' => 'prg_2']); // explicit wins ``` -------------------------------- ### Run static analysis with composer analyse Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Runs static analysis on the codebase. ```bash composer analyse ``` -------------------------------- ### Record a referred sale with Tolt Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/resources/boost/skills/laravel-tolt-development/SKILL.md Record a referred sale end to end by creating a customer and then a transaction. The transaction uses the customer's id from the createCustomer response. ```php $customer = Tolt::createCustomer([ 'email' => 'john@example.com', 'partner_id' => 'part_1', ]); Tolt::createTransaction([ 'amount' => 4990, 'customer_id' => $customer['data']['id'], 'billing_type' => 'subscription', 'interval' => 'month', ]); ``` -------------------------------- ### List partners with pagination options Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Lists partners with pagination options. The `limit` parameter has a maximum value of 100. ```php Tolt::listPartners(['limit' => 50, 'order' => 'asc']); ``` -------------------------------- ### Format code with composer format Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Formats the code according to the project's style. ```bash composer format ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Executes the test suite for the package. ```bash composer test ``` -------------------------------- ### Configure TOLT_API_KEY and TOLT_PROGRAM_ID Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Environment variables for the Tolt API key and default program ID. The API key is found in the Tolt dashboard under Settings > Integrations; program IDs come from Tolt::listPrograms(). ```env TOLT_API_KEY=your-api-key TOLT_PROGRAM_ID=prg_your-program-id ``` -------------------------------- ### Create click event Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Creates a click event. Identify the click either by `partner_id` or by the `param`/`value` pair of the tracking link. ```php Tolt::createClick([ 'partner_id' => 'part_1', 'country' => 'BR', 'device' => 'mobile', 'page' => 'https://example.com/pricing', ]); ``` -------------------------------- ### Call Tolt::getPartner with facade Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/resources/boost/skills/laravel-tolt-development/SKILL.md Use the Tolt facade to call a Tolt v1 endpoint. The method returns the decoded JSON body as an array. ```php use JeffersonGoncalves\Tolt\Facades\Tolt; Tolt::getPartner('part_1'); ``` -------------------------------- ### Handle ToltException on createTransaction Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/resources/boost/skills/laravel-tolt-development/SKILL.md Non-2xx responses throw ToltException with getMessage() and public readonly statusCode. The API allows 25 requests per second per key and returns 429 with rate_limit_error beyond that. ```php try { Tolt::createTransaction(['amount' => 4990, 'customer_id' => 'cus_1']); } catch (\JeffersonGoncalves\Tolt\Exceptions\ToltException $e) { report($e); } ``` -------------------------------- ### Override program_id for list partners Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Overrides the default `program_id` from `config('tolt.program_id')` by passing a custom value. ```php Tolt::listPartners(['program_id' => 'prg_other']); ``` -------------------------------- ### Handle Tolt API errors Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Handles API errors. The API allows 25 requests per second per key and answers `429` beyond that. The exception provides `getMessage()` for the error message or raw response body, and `statusCode` for the HTTP status code. ```php try { $partner = Tolt::getPartner('part_1'); } catch (ToltException $e) { // $e->getMessage() — the API's error message, or the raw response body // $e->statusCode — the HTTP status code returned by Tolt } ``` -------------------------------- ### Transaction CRUD and refund operations Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Performs CRUD and refund operations on transactions. Amounts are in cents. ```php Tolt::listTransactions(['customer_id' => 'cus_1']); Tolt::getTransaction('txn_1'); Tolt::createTransaction([ 'amount' => 4990, 'customer_id' => 'cus_1', 'billing_type' => 'subscription', 'interval' => 'month', ]); Tolt::updateTransaction('txn_1', ['amount' => 5990]); Tolt::refundTransaction('txn_1'); Tolt::deleteTransaction('txn_1'); ``` -------------------------------- ### Commission CRUD operations Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Performs CRUD operations on commissions. Amounts are in cents. `program_id` and `partner_id` are required when `customer_id` is omitted or null. ```php Tolt::listCommissions(['partner_id' => 'part_1']); Tolt::getCommission('comm_1'); Tolt::createCommission([ 'amount' => 2999, 'customer_id' => 'cus_1', 'revenue' => 14999, 'status' => 'pending', ]); Tolt::updateCommission('comm_1', ['status' => 'approved']); Tolt::deleteCommission('comm_1'); ``` -------------------------------- ### Promotion code CRUD operations Source: https://github.com/jeffersongoncalves/laravel-tolt/blob/main/README.md Performs CRUD operations on promotion codes. `value` is an amount in cents for the `fixed` type, or a number between 0 and 100 for the `percentage` type. ```php Tolt::listPromotionCodes(['search' => 'SUMMER']); Tolt::getPromotionCode('prc_1'); Tolt::createPromotionCode([ 'code' => 'SUMMER2026', 'type' => 'percentage', 'value' => 20, 'partner_id' => 'part_1', ]); Tolt::updatePromotionCode('prc_1', ['type' => 'fixed', 'value' => 2500]); Tolt::deletePromotionCode('prc_1'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.