PHPackages                             caydeesoft/card-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. caydeesoft/card-sdk

ActiveLibrary[Payment Processing](/categories/payments)

caydeesoft/card-sdk
===================

A Laravel SDK for integrating Visa, MasterCard, Amex, and Discover APIs

v1.0.3(4w ago)05MITPHPPHP &gt;=8.2CI passing

Since May 12Pushed 4w agoCompare

[ Source](https://github.com/Caydeesoft/CardSDK)[ Packagist](https://packagist.org/packages/caydeesoft/card-sdk)[ RSS](/packages/caydeesoft-card-sdk/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (5)Used By (0)

Caydeesoft Card SDK
===================

[](#caydeesoft-card-sdk)

A Laravel package for working with card payment providers and validating card details. The package ships with clients for Visa, Mastercard, American Express, and Discover, plus a lightweight card validator for card type detection, Luhn checks, expiry dates, and CVV length validation.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 9, 10, 11, 12, or 13
- Guzzle 7

Installation
------------

[](#installation)

Install the package with Composer:

```
composer require caydeesoft/card-sdk
```

Laravel discovers the service provider automatically. If package discovery is disabled, add the provider manually:

```
'providers' => [
    Caydeesoft\CardSdk\CardServiceProvider::class,
],
```

Publish the configuration file:

```
php artisan vendor:publish --tag=card-config
```

This creates `config/card.php`.

Configuration
-------------

[](#configuration)

Set the active payment provider and credentials in your `.env` file:

```
CARD_PROVIDER=visa

VISA_API_KEY=
VISA_BASE_URL=https://sandbox.api.visa.com

MASTERCARD_CONSUMER_KEY=
MASTERCARD_PRIVATE_KEY_PATH=
MASTERCARD_BASE_URL=https://sandbox.api.mastercard.com

AMEX_API_KEY=
AMEX_BASE_URL=https://api.americanexpress.com

DISCOVER_API_KEY=
DISCOVER_BASE_URL=https://api.discover.com

CARD_ENCRYPTION_ITERATIONS=210000
CARD_ENCRYPTION_PEPPER=
```

Supported `CARD_PROVIDER` values are:

- `visa`
- `mastercard`
- `amex`
- `discover`

Payment Usage
-------------

[](#payment-usage)

Resolve the configured payment client from Laravel's container by type-hinting `CardInterface`:

```
use Caydeesoft\CardSdk\Contracts\CardInterface;

class PaymentController
{
    public function store(CardInterface $cards)
    {
        $response = $cards->authorizePayment([
            'amount' => 1000,
            'currency' => 'USD',
            'card_number' => '4111111111111111',
            'expiry' => '12/26',
            'cvv' => '123',
        ]);

        return response()->json($response);
    }
}
```

The concrete client is selected from `config('card.payment_provider')`.

### Available Payment Methods

[](#available-payment-methods)

All provider clients implement `Caydeesoft\CardSdk\Contracts\CardInterface`:

```
authorizePayment(array $paymentData): array;
capturePayment(string $transactionId): array;
refundPayment(string $transactionId): array;
```

Example capture:

```
$response = $cards->capturePayment($transactionId);
```

Example refund:

```
$response = $cards->refundPayment($transactionId);
```

Card Validation
---------------

[](#card-validation)

Use `CardValidator` when you need local card checks before sending data to a payment provider:

```
use Caydeesoft\CardSdk\CardValidator;

$cardType = CardValidator::getCardType('4111111111111111');

if (! CardValidator::isValidCardNumber('4111111111111111')) {
    return response()->json(['error' => 'Invalid card number'], 422);
}

if (! CardValidator::isValidExpiry('12', '2026')) {
    return response()->json(['error' => 'Expired card'], 422);
}

if (! CardValidator::isValidCVV('123', $cardType)) {
    return response()->json(['error' => 'Invalid CVV'], 422);
}
```

### Validator Methods

[](#validator-methods)

- `CardValidator::getCardType(string $number): string`
- `CardValidator::isValidCardNumber(string $number): bool`
- `CardValidator::isValidExpiry(string|int $month, string|int $year): bool`
- `CardValidator::isValidCVV(string|int $cvv, string $cardType): bool`

Detected card types include `Visa`, `MasterCard`, `Amex`, `Discover`, `Diners Club`, `JCB`, and `Unknown`.

Encrypted Stored Data
---------------------

[](#encrypted-stored-data)

Use `StoredCardEncryptor` to encrypt stored payment metadata with a password or PIN supplied by the user. The encryptor derives a key with PBKDF2-SHA256, a random per-record salt, and the optional `CARD_ENCRYPTION_PEPPER`, then encrypts the data with AES-256-GCM.

Store only the encrypted payload. Do not store CVV/CVC values, even encrypted.

```
use Caydeesoft\CardSdk\StoredCardEncryptor;

class StoredPaymentMethodController
{
    public function store(StoredCardEncryptor $encryptor)
    {
        $encrypted = $encryptor->encrypt([
            'provider' => 'visa',
            'card_token' => 'tok_provider_generated_value',
            'last_four' => '1111',
            'card_type' => 'Visa',
            'expiry_month' => '12',
            'expiry_year' => '2028',
        ], request('password_or_pin'));

        auth()->user()->paymentMethods()->create([
            'encrypted_payload' => $encrypted,
        ]);
    }
}
```

### Repeat Transactions

[](#repeat-transactions)

For a repeat transaction, ask the user for the same password or PIN, decrypt the stored payload, and use the decrypted provider token or stored card reference in the payment request:

```
use Caydeesoft\CardSdk\Contracts\CardInterface;
use Caydeesoft\CardSdk\StoredCardEncryptor;

class RepeatPaymentController
{
    public function store(CardInterface $cards, StoredCardEncryptor $encryptor)
    {
        $paymentMethod = auth()->user()->paymentMethods()->findOrFail(request('payment_method_id'));

        $stored = $encryptor->decrypt(
            $paymentMethod->encrypted_payload,
            request('password_or_pin')
        );

        $response = $cards->authorizePayment([
            'amount' => 1000,
            'currency' => 'USD',
            'card_token' => $stored['card_token'],
        ]);

        return response()->json($response);
    }
}
```

Password and PIN guidance:

- A password is safer than a short PIN because encrypted payloads can be attacked offline if the database leaks.
- If you allow a PIN, set a strong random `CARD_ENCRYPTION_PEPPER` in the server environment and rate-limit unlock attempts.
- If the user forgets the password or PIN, the package cannot decrypt the stored payload. Create a new stored payment method instead.
- Prefer storing provider tokens or card references. Storing raw card numbers can bring your application into PCI DSS scope.

Notes
-----

[](#notes)

- Card number validation uses the Luhn algorithm.
- Amex CVVs must be four digits. Other supported card types use three digits.
- The included provider clients send JSON requests with authorization headers based on the configured credentials.
- Store live API credentials only in environment variables or a secrets manager.

Troubleshooting
---------------

[](#troubleshooting)

### Service Provider Is Not Discovered

[](#service-provider-is-not-discovered)

Refresh Composer's autoloader and Laravel's package discovery cache:

```
composer dump-autoload
php artisan package:discover
```

If auto-discovery is disabled, register `Caydeesoft\CardSdk\CardServiceProvider::class` manually in your Laravel configuration.

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance94

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

28d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b45f83595087e9d2a3e2af6b69cdb1867d10bba2edc06182e8a09e47fb73f2ea?d=identicon)[dennis.kiptoo](/maintainers/dennis.kiptoo)

---

Top Contributors

[![dkiptugen](https://avatars.githubusercontent.com/u/11540219?v=4)](https://github.com/dkiptugen "dkiptugen (3 commits)")

### Embed Badge

![Health badge](/badges/caydeesoft-card-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/caydeesoft-card-sdk/health.svg)](https://phpackages.com/packages/caydeesoft-card-sdk)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[spatie/laravel-export

Create a static site bundle from a Laravel app

670139.5k6](/packages/spatie-laravel-export)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4849.3k](/packages/sebdesign-laravel-viva-payments)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

232.5k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
