# Shiftech Africa Pesapal Laravel SDK
A production-grade Laravel SDK for Pesapal API 3.0 hosted payments, designed for Kenyan and East African applications that need Visa and Mastercard acceptance without handling raw card data.
## What this SDK does
- Authenticates and safely caches Pesapal's short-lived bearer token.
- Registers and lists IPN endpoints.
- Creates hosted checkout orders and returns the Pesapal redirect URL.
- Verifies callback/IPN payments through `GetTransactionStatus`.
- Supports recurring card enrollment fields, refunds, and eligible order cancellation.
- Provides Laravel auto-discovery, a facade, typed DTOs, exceptions, and Artisan commands.
- Includes an idempotent Laravel integration example.
## Important card architecture
Your Laravel application must **not** collect card number, CVV, or expiry data. `SubmitOrderRequest` returns a hosted `redirect_url`; Pesapal presents the available payment methods, including enabled card methods, and handles the sensitive card flow.
## Installation
```bash
composer require shiftechafrica/pesapal-laravel-sdk
php artisan vendor:publish --tag=pesapal-config
```
Add credentials and URLs:
```dotenv
PESAPAL_ENVIRONMENT=sandbox
PESAPAL_CONSUMER_KEY=your-consumer-key
PESAPAL_CONSUMER_SECRET=your-consumer-secret
PESAPAL_NOTIFICATION_ID=your-registered-ipn-id
PESAPAL_IPN_URL=
app.example.com
PESAPAL_CALLBACK_URL=
app.example.com
PESAPAL_CANCELLATION_URL=
app.example.com
PESAPAL_CURRENCY=KES
```
Register an IPN once per environment:
```bash
php artisan pesapal:ipn:register
app.example.com --method=POST
php artisan pesapal:ipn:list
```
Copy the returned IPN ID into `PESAPAL_NOTIFICATION_ID`.
## Create a card checkout
```php
use ShiftechAfrica\Pesapal\Data\BillingAddress;
use ShiftechAfrica\Pesapal\Data\OrderRequest;
use ShiftechAfrica\Pesapal\Http\PesapalClient;
public function pay …