IDPay payment gateway for Laravel (https://idpay.ir)
IDPay gateway in Laravel.
- Installation
- Request new payment
- Handle callback result
- Verify payment
- Inquiry an old payment
- Contributors
- License
$ composer require mastani/laravel-idpay
The package will automatically register itself.
$ composer require mastani/laravel-idpay
Next up, the service provider must be registered:
// config/app.php
'providers' => [
...
mastani\IDPay\IDPayServiceProvider::class,
];
Another way is install the component through composer.
Either run
$ composer require mastani/laravel-idpay
or add
"mastani/laravel-idpay": "dev-master"
to the require section of your composer.json.
$pay = new IDPayPayment();
$response = $pay->setApiKey('IDPay API Key')
->setSandbox(true)
->setOrderID('10000') // Locally generated
->setCallback('https://my-website.com/callback')
->setPrice(50000)
->setName("Amin") // optional
->setPhone("09353361569") // optional
->setMail("amin@mail.com") // optional
->setDesc("Pay for bronze account") // optional
->request();
if ($response->is_successful) {
// save payment details to database here
return redirect()->to($response->link);
} else {
// handle error
}
[response_code] => 201
[is_successful] => true
[id] => 91cb30a55598f6dbdd0d4d7ad9613d88
[link] => https://idpay.ir/p/ws-sandbox/91cb30a55598f6dbdd0d4d7ad9613d88
[response_code] => 406
[is_successful] => false
[error_code] => 34
[error_message] => مبلغ `amount` باید بیشتر از 10,000 ریال باشد
$callback = new IDPayPaymentCallback($_POST);
if ($callback->is_successful) {
echo 'Order: ' . $callback->orderId;
echo 'Card Number: ' . $callback->cardNO;
// verify payment with next method
} else {
// handle error
}
[is_successful] => false
[result] => "در انتظار تایید پرداخت"
[status] => "10"
[trackID] => "46868"
[ID] => "91cb30a55598f6dbdd0d4d7ad9613d88"
[orderID] => "10000"
[amount] => "50000"
[cardNO] => "123456******1234"
[date] => "1553961021"
$verify = new IDPayVerify();
$response = $verify->setApiKey('IDPay API Key')
->setSandbox(true)
->setID('91cb30a55598f6dbdd0d4d7ad9613d88')
->setOrderID('10000')
->request();
if ($response->is_successful) {
echo 'Order: ' . $response->order_id;
echo 'Card Number: ' . $response->payment->card_no;
// handle user credit here
} else {
// handle error
}
[response_code] => 200
[is_successful] => true
[status] => 101
[track_id] => 46826
[id] => 91cb30a55598f6dbdd0d4d7ad9613d88
[order_id] => 10000
[amount] => 50000
[date] => 1553954369
[payment] => stdClass Object
(
[track_id] => 59670764
[amount] => 50000
[card_no] => 123456******1234
[date] => 1553954369
)
[verify] => stdClass Object
(
[date] => 1553954623
)
[response_code] => 405
[is_successful] => false
[error_code] => 53
[error_message] => تایید پرداخت امکان پذیر نیست.
$inquiry = new IDPayInquiry();
$response = $inquiry->setApiKey('IDPay API Key')
->setSandbox(true)
->setID('91cb30a55598f6dbdd0d4d7ad9613d88')
->setOrderID('10000')
->request();
if ($response->is_successful) {
// handle success here
echo 'Order: ' . $response->order_id;
echo 'Card Number: ' . $response->payment->card_no;
} else {
// handle error
}
[response_code] => 200
[is_successful] => true
[status] => 100
[track_id] => 46826
[id] => 91cb30a55598f6dbdd0d4d7ad9613d88
[order_id] => 10000
[amount] => 50000
[wage] => stdClass Object
(
[by] => payee
[type] => percent
[amount] => 1000
)
[date] => 1553954369
[payer] => stdClass Object
(
[name] => Amin
[phone] => 09353361569
[mail] => amin@mail.com
[desc] => Pay for bronze account
)
[payment] => stdClass Object
(
[track_id] => 59670764
[amount] => 50000
[card_no] => 123456******1234
[date] => 1553954369
)
[verify] => stdClass Object
(
[date] => 1553954623
)
[settlement] => stdClass Object
(
[track_id] => 13040079970
[amount] => 47000
[date] => 1553984280
)
[response_code] => 400
[is_successful] => false
[error_code] => 52
[error_message] => استعلام نتیجه ای نداشت.
- Amin Mastani https://mastani.app
The MIT License (MIT). Please see License File for more information.