Skip to content

Commit b719af6

Browse files
committed
first commit
1 parent 4066fd6 commit b719af6

23 files changed

+17938
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ $RECYCLE.BIN/
4141
Network Trash Folder
4242
Temporary Items
4343
.apdisk
44+
45+
.idea

composer.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "zarinpal/zarinpal",
3+
"description": "transaction request system for zarinpal",
4+
"license": "GPL2",
5+
"authors": [
6+
{
7+
"name": "hooman naghiee",
8+
"email": "[email protected]"
9+
}
10+
],
11+
"minimum-stability": "dev",
12+
"require": {},
13+
"autoload": {
14+
"psr-4": {
15+
"Zarinpal\\": "src/"
16+
}
17+
}
18+
}

src/Drivers/NuSoap.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php namespace Zarinpal\Drivers;
2+
3+
class NuSoap implements SoapDriver
4+
{
5+
/**
6+
* request driver
7+
*
8+
* @param $inputs
9+
* @return array
10+
*/
11+
public function requestDriver($inputs)
12+
{
13+
require_once('lib/nusoap.php');
14+
$client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl');
15+
$client->soap_defencoding = 'UTF-8';
16+
$result = $client->call('PaymentRequest', [$inputs]);
17+
if ($result['Status'] == 100) {
18+
Header('Location: https://www.zarinpal.com/pg/StartPay/' . $result->Authority);
19+
die;
20+
} else {
21+
return ['error' => $result['Status']];
22+
}
23+
}
24+
25+
/**
26+
* verify driver
27+
*
28+
* @param $inputs
29+
* @return array
30+
*/
31+
public function verifyDriver($inputs)
32+
{
33+
$client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl');
34+
$client->soap_defencoding = 'UTF-8';
35+
$result = $client->call('PaymentVerification', [$inputs]);
36+
37+
if ($result['Status'] == 100) {
38+
return ['Status' => 'success', 'RefID' => $result['RefID']];
39+
} else {
40+
return ['Status' => 'error', 'error' => $result['Status']];
41+
}
42+
}
43+
}

src/Drivers/Soap.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php namespace Zarinpal\Drivers;
2+
3+
class Soap implements SoapDriver{
4+
5+
/**
6+
* request driver
7+
*
8+
* @param $inputs
9+
* @return array
10+
*/
11+
public function requestDriver($inputs){
12+
$client = new \SoapClient('https://de.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8'));
13+
$result = $client->PaymentRequest($inputs);
14+
if($result->Status == 100)
15+
{
16+
Header('Location: https://www.zarinpal.com/pg/StartPay/'.$result->Authority);
17+
die;
18+
} else {
19+
return ['error' => $result->Status];
20+
}
21+
}
22+
23+
/**
24+
* verify driver
25+
*
26+
* @param $inputs
27+
* @return array
28+
*/
29+
public function verifyDriver($inputs){
30+
$client = new \SoapClient('https://de.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8'));
31+
$result = $client->PaymentVerification($inputs);
32+
33+
if ($result->Status == 100) {
34+
return ['Status' => 'success', 'RefID' => $result->RefID];
35+
} else {
36+
return ['Status' => 'error', 'error' => $result->Status];
37+
}
38+
}
39+
}

src/Drivers/SoapDriver.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php namespace Zarinpal\Drivers;
2+
3+
interface SoapDriver
4+
{
5+
/**
6+
* @param $inputs
7+
* @return array|redirect
8+
*/
9+
public function requestDriver($inputs);
10+
11+
/**
12+
* @param $inputs
13+
* @return array
14+
*/
15+
public function verifyDriver($inputs);
16+
}

src/Drivers/lib/changelog

+648
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)