Search by

credpal / connect-php

credpalwiseminds

CredPal Connect for PHP: checkout sessions, payment links, orders, refunds, payouts and webhook verification

Package info

github.com/crednet/connect-php

pkg:composer/credpal/connect-php

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-11-19 16:33 UTC

This package is auto-updated.

Last update: 2026-12-02 12:01:14 UTC


README

CredPal Connect for PHP 8.1+ (ext-curl, ext-json). It covers checkout sessions, payment links, orders, refunds and payouts, plus webhook verification.

composer require credpal/connect-php
use CredPal\Connect\Client;
use CredPal\Connect\CredPalException;
use CredPal\Connect\Webhook;

$credpal = new Client(getenv('CREDPAL_SECRET_KEY')); // sk_sbx_… → sandbox, sk_live_… → live

// 1. Create a checkout for an order (amounts in kobo).
$session = $credpal->checkoutSessions->create([
    'amount' => 5000000,
    'reference' => 'order-1001',
    'items' => [['name' => 'Wireless headphones', 'quantity' => 1, 'unit_amount' => 5000000]],
    'redirect_url' => 'https://yourstore.com/orders/1001/thanks',
], ['idempotency_key' => 'order-1001']);
header('Location: ' . $session['url']);

// 2. Fulfil on the webhook (raw body).
$event = Webhook::constructEvent(file_get_contents('php://input'), $_SERVER['HTTP_X_CREDPAL_SIGNATURE'] ?? null, getenv('CREDPAL_WEBHOOK_SECRET'));
if ($event['type'] === 'order.created' && $event['data']['status'] === 'confirmed') {
    ship($event['data']['reference']);
}
checkoutSessions create, retrieve, expire
orders list, retrieve
refunds create, list, retrieve
paymentLinks create, list, retrieve, update (a new cart version), deactivate
payouts balance, list, retrieve
Webhook verifySignature, constructEvent
  • Responses are decoded arrays.
  • Retries: network errors, 429 (respecting Retry-After) and 5xx are retried twice by default. Creates carry an Idempotency-Key (yours, or one generated and reused across retries).
  • Errors: API errors throw CredPalException. getErrorCode() is stable, so branch on it. getParam(), getStatusCode() and getRequestId() are also available.
  • Options: base_url, timeout, max_retries, transport (implement Http\Transport to use your own HTTP client), and app_info.

Tests: vendor/bin/phpunit. Docs: https://docs.credpal.com/connect