Browse project documentation

Zarinpal

Pardakhtv1.0.0-beta.4View sourceEnglish / Persian

The most popular Iranian online payment gateway. REST-based with sandbox support.

Configuration

use Eram\Pardakht\Gateway\Zarinpal\ZarinpalConfig;

$config = new ZarinpalConfig(
    merchantId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    sandbox: false, // Set true for testing
);
ParameterTypeRequiredDefaultDescription
merchantIdstringYes—Your Zarinpal merchant ID
sandboxboolNofalseUse sandbox environment

Purchase

$gateway = $pardakht->create('zarinpal', $config);

$response = $gateway->purchase(new PurchaseRequest(
    amount: Amount::fromToman(50_000),
    callbackUrl: 'https://example.com/callback',
    orderId: 'ORDER-123',
    description: 'Premium plan',
    mobile: '09123456789',
    email: 'user@example.com',
));

// GET redirect
header('Location: ' . $response->getUrl());

Verify

$transaction = $gateway->verify();

$transaction->getReferenceId();  // Authority
$transaction->getTrackingCode(); // RefID
$transaction->getCardNumber();   // Masked card number

Sandbox

Set sandbox: true to use Zarinpal’s test environment. No real money is charged.

$config = new ZarinpalConfig(
    merchantId: 'test',
    sandbox: true,
);

Settlement

Not required. Payments are settled automatically.

Notes

  • Amount is sent in Rials (converted automatically from Amount)
  • Mobile and email are optional but improve UX on the payment page
  • The description field is shown to the user on the payment page

Search documentation

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

Tab to navigate · Enter to openEsc to close