### Install via Composer Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Installs the package via Composer. ```bash composer require jeffersongoncalves/laravel-partnerstack ``` -------------------------------- ### Deal CRUD and archive operations Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Deal resource methods: list, get, create, update, and archive. The create method requires a partner_key and amount. ```php PartnerStack::listDeals(); PartnerStack::getDeal('deal-key'); PartnerStack::createDeal([ 'partner_key' => 'partner-key', 'name' => 'Acme Corp', 'amount' => 250000, 'stage' => 'proposal', ]); PartnerStack::updateDeal('deal-key', ['stage' => 'won', 'status' => 'closed']); PartnerStack::archiveDeal('deal-key'); ``` -------------------------------- ### Lead CRUD operations Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Lead resource methods: list, get, create, and update. The create method requires a partner_key and email. ```php PartnerStack::listLeads(); PartnerStack::getLead('lead-key'); PartnerStack::createLead([ 'partner_key' => 'partner-key', 'email' => 'lead@example.com', 'company' => 'Acme Corp', ]); PartnerStack::updateLead('lead-key', ['status' => 'qualified']); ``` -------------------------------- ### Partnership CRUD operations Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Partnership resource methods: list, get, create, and update. The create method requires an email and group_key. ```php PartnerStack::listPartnerships(); PartnerStack::getPartnership('partnership-key'); PartnerStack::createPartnership([ 'email' => 'jane@example.com', 'group_key' => 'group-key', 'first_name' => 'Jane', 'last_name' => 'Doe', ]); PartnerStack::updatePartnership('partnership-key', ['name' => 'Jane Doe']); ``` -------------------------------- ### Customer CRUD operations Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Customer resource methods: list, get, create, update, and delete. The create method requires an email and partner_key. ```php PartnerStack::listCustomers(); PartnerStack::getCustomer('customer-key'); PartnerStack::createCustomer([ 'email' => 'john@example.com', 'partner_key' => 'partner-key', 'customer_key' => 'your-internal-id', ]); PartnerStack::updateCustomer('customer-key', ['name' => 'John Doe']); PartnerStack::deleteCustomer('customer-key'); ``` -------------------------------- ### Transaction CRUD operations Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Transaction resource methods: list, get, create, and delete. Amounts are in cents. ```php PartnerStack::listTransactions(); PartnerStack::getTransaction('transaction-key'); PartnerStack::createTransaction([ 'customer_key' => 'customer-key', 'amount' => 4990, 'currency' => 'usd', 'category' => 'subscription', ]); PartnerStack::deleteTransaction('transaction-key'); ``` -------------------------------- ### Add a new endpoint method to PartnerStack.php Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/resources/boost/skills/laravel-partnerstack-development/SKILL.md Add a public method to src/PartnerStack.php that calls the private get() helper. The method returns an array and uses the provided key in the URL path. ```php public function newEndpoint(string $key): array { return $this->get("/new-endpoint/{$key}"); } ``` -------------------------------- ### Webhook CRUD operations Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Webhook resource methods: list, get, create, and delete. The create method requires a target URL and events array. ```php PartnerStack::listWebhooks(); PartnerStack::getWebhook('webhook-key'); PartnerStack::createWebhook([ 'target' => 'https://example.com/hooks/partnerstack', 'events' => ['customer.created', 'transaction.created'], ]); PartnerStack::deleteWebhook('webhook-key'); ``` -------------------------------- ### Record a referred sale end to end Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/resources/boost/skills/laravel-partnerstack-development/SKILL.md Create a customer with an email and partner key, then create a transaction using the returned customer key. The amount is in cents and currency is 'usd'. ```php $customer = PartnerStack::createCustomer([ 'email' => 'john@example.com', 'partner_key' => 'prt-1', ]); PartnerStack::createTransaction([ 'customer_key' => $customer['data']['key'], 'amount' => 4990, 'currency' => 'usd', ]); ``` -------------------------------- ### Publish Config File Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Optionally publishes the configuration file. ```bash php artisan vendor:publish --tag="partnerstack-config" ``` -------------------------------- ### Import PartnerStack facade and exception Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Import the PartnerStack facade and the PartnerStackException class before using the package methods. ```php use JeffersonGoncalves\PartnerStack\Exceptions\PartnerStackException; use JeffersonGoncalves\PartnerStack\Facades\PartnerStack; ``` -------------------------------- ### Action list and create operations Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Action resource methods: list and create. The create method requires a customer_key and key. ```php PartnerStack::listActions(); PartnerStack::createAction([ 'customer_key' => 'customer-key', 'key' => 'signup', 'value' => 1, ]); ``` -------------------------------- ### List partnerships with pagination options Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Every list*() method accepts cursor pagination options: limit, starting_after, ending_before, and order_by. ```php PartnerStack::listPartnerships(['limit' => 50, 'order_by' => 'created_at']); ``` -------------------------------- ### Config Options Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Configuration options for the package. The base_url defaults to the PartnerStack API v2 endpoint. ```php // config/partnerstack.php return [ 'public_key' => env('PARTNERSTACK_PUBLIC_KEY'), 'secret_key' => env('PARTNERSTACK_SECRET_KEY'), 'base_url' => env('PARTNERSTACK_BASE_URL', 'https://api.partnerstack.com/api/v2'), ]; ``` -------------------------------- ### Format code with composer format Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Formats the code according to the project's style guidelines. Use this command to ensure consistent code formatting. ```bash composer format ``` -------------------------------- ### Paginate customers with listCustomers Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/resources/boost/skills/laravel-partnerstack-development/SKILL.md Use cursor pagination with list*() methods. The optional query array supports limit, starting_after, ending_before, and order_by. ```php PartnerStack::listCustomers(['limit' => 50, 'starting_after' => 'cus-100']); ``` -------------------------------- ### Reward list and create operations Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Reward resource methods: list and create. Amounts are in cents. ```php PartnerStack::listRewards(); PartnerStack::createReward([ 'partner_key' => 'partner-key', 'amount' => 10000, 'description' => 'Q1 bonus', 'currency' => 'usd', ]); ``` -------------------------------- ### Run static analysis with composer analyse Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Runs static analysis on the codebase. Use this command to check for potential issues without executing the code. ```bash composer analyse ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Add these environment variables to your .env file. Both keys are found in the PartnerStack dashboard under Settings > Integrations > API keys. ```env PARTNERSTACK_PUBLIC_KEY=your-public-key PARTNERSTACK_SECRET_KEY=your-secret-key ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Runs the test suite for the package. Use this command to execute all tests defined in the project. ```bash composer test ``` -------------------------------- ### List groups Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Group resource method: list. ```php PartnerStack::listGroups(); ``` -------------------------------- ### Call PartnerStack endpoint with facade Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/resources/boost/skills/laravel-partnerstack-development/SKILL.md Use the PartnerStack facade to call a PartnerStack v2 endpoint. The method getPartnership maps 1:1 to the API and returns the decoded JSON body as an array. ```php use JeffersonGoncalves\PartnerStack\Facades\PartnerStack; PartnerStack::getPartnership('partnership-key'); ``` -------------------------------- ### Handle PartnerStackException with try-catch Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/resources/boost/skills/laravel-partnerstack-development/SKILL.md Handle PartnerStack API errors. Non-2xx responses throw PartnerStackException with getMessage() and a public statusCode property. The amount field is in cents, so pass 4990 for $49.90. ```php try { PartnerStack::createTransaction(['customer_key' => 'cus-1', 'amount' => 4990]); } catch (\JeffersonGoncalves\PartnerStack\Exceptions\PartnerStackException $e) { report($e); } ``` -------------------------------- ### Handle PartnerStackException Source: https://github.com/jeffersongoncalves/laravel-partnerstack/blob/main/README.md Wrap PartnerStack calls in try/catch to handle PartnerStackException. The exception provides getMessage() for the API error message or raw response body, and statusCode for the HTTP status code. ```php try { $partnership = PartnerStack::getPartnership('partnership-key'); } catch (PartnerStackException $e) { // $e->getMessage() — the API's error message, or the raw response body // $e->statusCode — the HTTP status code returned by PartnerStack } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.