1. Go to this page and download the library: Download selectwin/sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
selectwin / sdk example snippets
use Selectwin\SelectwinClient;
use Selectwin\Exception\CardException;
$sw = new SelectwinClient(getenv('SELECTWIN_API_KEY')); // sk_test_… / sk_live_…
// Create a PIX transaction (amounts in cents). Pass an array or a generated model:
$tx = $sw->transactions->create([
'amount' => 9990,
'payment' => ['method' => 'pix', 'currency' => 'BRL'],
]);
// id / id+body aliases
$one = $sw->transactions->retrieve('tra_…');
$sw->subscriptions->pause('subs_…');
// Typed exceptions — branch on the class / getSelectwinCode(), never the message
try {
$sw->transactions->create([/* … */]);
} catch (CardException $e) {
echo $e->getDisplayMessage(), $e->isReversible(); // buyer-facing + retryable
}
foreach ($sw->transactions->list(['limit' => 100]) as $tx) {
// every transaction across all pages
}
$firstPage = $sw->transactions->list(['limit' => 20])->first(); // page object (getData(), getHasMore())
$some = $sw->customers->list()->toArray(500); // collect, optionally capped
// $rawBody MUST be the exact bytes received (do not re-serialize)
$event = $sw->constructEvent(
$rawBody,
$_SERVER['HTTP_X_SELECTWIN_SIGNATURE'] ?? null,
getenv('SELECTWIN_WEBHOOK_SECRET'), // whsec_…
);
if ($event->type === 'transaction.approved') {
$object = $event->object;
}
lib/ # openapi-generator core (Selectwin\Api, \Model, Configuration…) — synced; DO NOT edit
src/
SelectwinClient.php # the client — wires Configuration + Guzzle into every resource
Resource/ # GENERATED resource wrappers (gen_resources.php) — DO NOT edit
Exception/Exceptions.php # typed exception hierarchy + ErrorFactory
Http/ClientFactory.php # Guzzle handler stack (retries) + idempotency middleware
Pagination/Paginator.php
Webhook/ # WebhookSignature (constructEvent) + Event
WebhookEvents.php # GENERATED Event Catalog