Browse project documentation

Getting Started

Pardakhtv1.0.0-beta.4View sourceEnglish / Persian

Requirements

  • PHP 8.1 or later
  • Extensions: ext-curl, ext-json, ext-openssl, ext-soap

Installation

composer require eram/pardakht

Pardakht has a single Composer dependency — eram/abzar, the shared Persian/Iranian utility library — plus the PHP extensions that ship with most installations.

Quick Example

Here is a complete payment flow using Zarinpal:

1. Create a Gateway

use Eram\Pardakht\Pardakht;
use Eram\Pardakht\Gateway\Zarinpal\ZarinpalConfig;

$pardakht = new Pardakht();
$gateway = $pardakht->create('zarinpal', new ZarinpalConfig(
    merchantId: 'your-merchant-id',
));

2. Initiate a Purchase

use Eram\Pardakht\Money\Amount;
use Eram\Pardakht\Http\PurchaseRequest;

$request = new PurchaseRequest(
    amount: Amount::fromToman(50_000),       // 50,000 Toman
    callbackUrl: 'https://example.com/callback',
    orderId: 'ORDER-123',
    description: 'Premium subscription',
);

$response = $gateway->purchase($request);

3. Redirect the User

// For REST gateways (Zarinpal, IDPay, etc.) — simple redirect
header('Location: ' . $response->getUrl());
exit;

// For SOAP gateways (Mellat, Saman, Parsian) — auto-submit form
echo $response->renderAutoSubmitForm();

4. Handle the Callback

// In your callback URL handler:
$transaction = $gateway->verify();

echo $transaction->getReferenceId();    // Gateway reference
echo $transaction->getTrackingCode();   // User-facing tracking code
echo $transaction->getCardNumber();     // Payer card (masked or full)
echo $transaction->getAmount()->inToman(); // 50000

5. Settlement (if required)

Some bank gateways (Mellat, Parsian) require a separate settlement step after verification. If you skip it, the payment is automatically reversed after 15-30 minutes.

use Eram\Pardakht\Contracts\SupportsSettlement;

if ($gateway instanceof SupportsSettlement) {
    $transaction = $gateway->settle($transaction);
}

Available Gateways

AliasGatewayProtocolSettlement
mellatMellat (Behpardakht)SOAPRequired
samanSaman (Sep)SOAPNo
parsianParsian (Pec)SOAPRequired
sadadSadad (Bank Melli)RESTNo
pasargadPasargadRESTNo
zarinpalZarinpalRESTNo
idpayIDPayRESTNo
zibalZibalRESTNo
payirPay.irRESTNo
nextpayNextPayRESTNo
vandarVandarRESTNo
sizpaySizpayRESTNo

Next Steps

Search documentation

Search across all projects. Close this window to return to your guide.

Tab to navigate · Enter to openEsc to close