Different gateways.
One payment flow.
Connect Iranian payment gateways through a consistent PHP API. Keep amounts explicit, handle redirects, and verify payments with the gateway you choose.
purchase → verifycomposer require eram/pardakht:^1.0@betaFOLLOW THE PAYMENT
Same order. Two routes.
DEMO-AUTHORITYpurchase()Illustrative order and gateway responseA payment attempt begins.
Start with an amount and an order ID. Save the returned reference with the order and gateway in your database.
use Eram\Abzar\Money\Amount;
use Eram\Pardakht\Http\PurchaseRequest;
$response = $gateway->purchase(new PurchaseRequest(
amount: Amount::fromToman(50_000),
callbackUrl: 'https://example.com/payment/callback',
orderId: '1042',
description: 'Demo order',
));
// Save the reference with your payment attempt.
$response->getReferenceId();GETIllustrative order and gateway responseSend the customer to the gateway.
Zarinpal returns a URL. RedirectResponse tells your app to use a GET redirect.
if ($response->isPost()) {
echo $response->renderAutoSubmitForm();
} else {
header('Location: ' . $response->getUrl());
exit;
}verify()Illustrative order and gateway responseConfirm with the gateway.
A callback alone is not a confirmed payment. Restore the saved attempt, prepare the gateway-specific data, then call verify().
// Restore the saved payment attempt first.
// Amount comes from your database, not the browser.
$callbackData['amount'] = $storedAmount->inRials();
$transaction = $gateway->verify($callbackData);
$transaction->getStatus()->value; // 'verified'
$transaction->getTrackingCode(); // '9001042' (sample)verifiedIllustrative order and gateway responseA verified result for your app.
Zarinpal needs no separate settle() call in this library. Use the verified result to update your order, handling repeated callbacks in your application.
use Eram\Pardakht\Contracts\SupportsSettlement;
if ($gateway instanceof SupportsSettlement) {
$transaction = $gateway->settle($transaction);
}
$transaction->getStatus()->value; // 'verified'DEMO-REFpurchase()Illustrative order and gateway responseA payment attempt begins.
Start with an amount and an order ID. Save the returned reference with the order and gateway in your database.
use Eram\Abzar\Money\Amount;
use Eram\Pardakht\Http\PurchaseRequest;
$response = $gateway->purchase(new PurchaseRequest(
amount: Amount::fromToman(50_000),
callbackUrl: 'https://example.com/payment/callback',
orderId: '1042',
description: 'Demo order',
));
// Save the reference with your payment attempt.
$response->getReferenceId();POSTIllustrative order and gateway responseSend a form to the bank.
Mellat returns a POST form. The same RedirectResponse API gives you the method and fields to send.
if ($response->isPost()) {
echo $response->renderAutoSubmitForm();
} else {
header('Location: ' . $response->getUrl());
exit;
}verify()Settlement comes nextConfirm with the gateway.
A callback alone is not a confirmed payment. Restore the saved attempt, prepare the gateway-specific data, then call verify().
// Restore the saved payment attempt first.
// Amount comes from your database, not the browser.
$callbackData['FinalAmount'] = $storedAmount->inRials();
$transaction = $gateway->verify($callbackData);
$transaction->getStatus()->value; // 'verified'
$transaction->getTrackingCode(); // '9001042' (sample)settle()Illustrative order and gateway responseOne more call: settlement.
Mellat implements SupportsSettlement. Call settle() after verification; its returned transaction has the settled status.
use Eram\Pardakht\Contracts\SupportsSettlement;
if ($gateway instanceof SupportsSettlement) {
$transaction = $gateway->settle($transaction);
}
$transaction->getStatus()->value; // 'settled'What changes in the gateway setup?
The methods are shared; credentials and callback fields belong to each gateway. Configure your gateway first, then follow the stages above. Keep credentials on the server.
use Eram\Pardakht\Pardakht;
use Eram\Pardakht\Gateway\Zarinpal\ZarinpalConfig;
use Eram\Pardakht\Gateway\Mellat\MellatConfig;
$pardakht = new Pardakht();
// Choose a gateway with your own credentials.
$gateway = $pardakht->create('zarinpal',
new ZarinpalConfig(merchantId: $merchantId)
);
// Or use your Mellat terminal.
$gateway = $pardakht->create('mellat',
new MellatConfig(
terminalId: $terminalId,
username: $username,
password: $password,
)
);Recorded with Pardakht 1.0.0-beta.4 and simulated gateway responses. These controls reveal saved examples; they do not run PHP, contact a bank, or make a payment.
THE UNIT IS PART OF THE VALUE
Toman in your app.
Rial when the gateway needs it.
Create Amount with the unit you mean. It stores an integer Rial value; each adapter reads the unit its gateway expects. Arithmetic returns a new amount.
Working with amountsAmount::fromToman(50_000)$amount->inRials()GATEWAY CATALOG
Choose your connection.
Mellat
SOAP · Separate settlement
Saman
SOAP
Parsian
SOAP · Separate settlement
Sadad
REST
Pasargad
REST
Zarinpal
REST
IDPay
REST
Zibal
REST
Jibit
Adapter source
Paystar
Adapter source
Pay.ir
REST
NextPay
REST
Vandar
REST
Sizpay
REST
Adapter availability reflects this library release. Merchant approval, credentials, and gateway-specific requirements still apply. Jibit and Paystar link to source because this release has no dedicated guides for them.
FITS INTO YOUR APPLICATION
Shared plumbing.
Your order logic.
Use plain PHP or the framework you already work with. Pardakht handles the gateway calls; your app owns the order and its lifecycle.
Restore the right payment attempt
Store the reference, gateway, order and amount. Match the callback to that record and prevent duplicate order fulfillment.
Handle outcomes deliberately
Handle connection failures, gateway errors and verification failures through the library’s exception types.
Connect your own infrastructure
Inject a transport, logger or event dispatcher for your application and tests.
Start with one gateway.
Install the beta, configure your credentials, and follow the guide for your provider. Test the integration before accepting real payments.
- Runtime
- PHP 8.1+
- PHP extensions
- curl · json · openssl · soap
- Composer dependency
- eram/abzar
- License
- MIT