Search by

althosalud / cobros

gonzaloalonsod

Typed PHP SDK for the AlthoCobros checkout API

v1.0.0 2026-09-12 23:44 UTC

This package is auto-updated.

Last update: 2026-09-12 23:48:44 UTC


README

Cliente PHP tipado para la AlthoCobros Checkout API.

Sin dependencias de framework: PHP 8.2+, ext-curl, ext-hash.

Instalación

composer require althosalud/cobros

Uso

use AlthoSalud\Cobros\CobrosClient;
use AlthoSalud\Cobros\EntitlementSignature;

$client = new CobrosClient(
    baseUrl: 'https://cobros.althosalud.com',
    apiKey: 'cb_...',
);

$me = $client->me();

$checkout = $client->createCheckout([
    'customer_external_id' => 'org-42',
    'lines' => [[
        'amount_cents' => 15000,
        'currency' => 'ARS',
        'description' => 'Plan mensual',
        'sku' => 'althasalud.pro',
        'period_start' => '2026-08-01',
        'period_end' => '2026-08-31',
        'entitlement_ref' => 'org-42:2026-08',
    ]],
], idempotencyKey: 'org-42-2026-08');

// Redirect the payer:
$checkout->initPoint;

$paid = $client->getCheckout($checkout->id);

Webhook entitlement.paid

$event = EntitlementSignature::parse(
    rawBody: $request->getContent(),
    signatureHeader: (string) $request->headers->get('X-Cobros-Signature'),
    secret: $applicationWebhookSecret,
    idempotencyKey: $request->headers->get('X-Cobros-Idempotency-Key'),
);
// $event->sku, amountCents, periodStart, customerExternalId

withApiKey() is immutable (one key per tenant).