Browse Source

update 2.0

tags/2.0
0nepeop1e 4 years ago
parent
commit
60971cbdcb

+ 3
- 0
.idea/php.xml View File

@@ -35,6 +35,9 @@
35 35
       <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
36 36
       <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
37 37
       <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
38
+      <path value="$PROJECT_DIR$/vendor/symfony/http-client-contracts" />
39
+      <path value="$PROJECT_DIR$/vendor/illuminate/macroable" />
40
+      <path value="$PROJECT_DIR$/vendor/illuminate/collections" />
38 41
     </include_path>
39 42
   </component>
40 43
   <component name="PhpProjectSharedConfiguration" php_language_level="7.1" />

+ 2
- 2
composer.json View File

@@ -6,8 +6,8 @@
6 6
     "readme": "README.md",
7 7
     "require": {
8 8
         "php": ">=7.1",
9
-        "illuminate/support": ">=5.0 <8.0",
10
-        "illuminate/http": ">=5.0 <8.0"
9
+        "illuminate/support": ">=5.0 <9.0",
10
+        "illuminate/http": ">=5.0 <9.0"
11 11
     },
12 12
     "suggest": {
13 13
         "mirfalah/laravel-payment-senangpay": "^1.0",

+ 9
- 1
src/Contracts/PaymentGatewayDriver.php View File

@@ -15,5 +15,13 @@ interface PaymentGatewayDriver
15 15
 
16 16
     public function verifyGatewayCallback(Request $request, Response &$response = null): bool;
17 17
 
18
-    public function getBillIdFromRequest(Request $request);
18
+    public function getBillIdFromRequest(Request $request): string;
19
+
20
+    public function getBillStatus(Request $request): int;
21
+
22
+    public function isBillSuccess(Request $request): bool;
23
+
24
+    public function isBillFailed(Request $request): bool;
25
+
26
+    public function isBillPending(Request $request): bool;
19 27
 }

+ 10
- 0
src/Events/CallbackVerifiedEvent.php View File

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Events;
5
+
6
+
7
+class CallbackVerifiedEvent extends PaymentGatewayEvent
8
+{
9
+
10
+}

+ 10
- 0
src/Events/PaymentFailedEvent.php View File

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Events;
5
+
6
+
7
+class PaymentFailedEvent extends PaymentGatewayEvent
8
+{
9
+
10
+}

+ 46
- 0
src/Events/PaymentGatewayEvent.php View File

@@ -0,0 +1,46 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Events;
5
+
6
+
7
+use Illuminate\Http\Request;
8
+use MirfalahTech\Laravel\Payment\Contracts\PaymentGatewayDriver;
9
+
10
+abstract class PaymentGatewayEvent
11
+{
12
+    protected $gateway;
13
+    protected $gatewayDriver;
14
+    protected $request;
15
+
16
+    public function __construct(string $gateway, PaymentGatewayDriver $gatewayDriver, Request $request)
17
+    {
18
+        $this->gateway = $gateway;
19
+        $this->gatewayDriver = $gatewayDriver;
20
+        $this->request = $request;
21
+    }
22
+
23
+    /**
24
+     * @return string
25
+     */
26
+    public function getGateway(): string
27
+    {
28
+        return $this->gateway;
29
+    }
30
+
31
+    /**
32
+     * @return PaymentGatewayDriver
33
+     */
34
+    public function getDriver(): PaymentGatewayDriver
35
+    {
36
+        return $this->gatewayDriver;
37
+    }
38
+
39
+    /**
40
+     * @return Request
41
+     */
42
+    public function getRequest(): Request
43
+    {
44
+        return $this->request;
45
+    }
46
+}

+ 10
- 0
src/Events/PaymentPendingEvent.php View File

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Events;
5
+
6
+
7
+class PaymentPendingEvent extends PaymentGatewayEvent
8
+{
9
+
10
+}

+ 10
- 0
src/Events/PaymentSuccessEvent.php View File

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Events;
5
+
6
+
7
+class PaymentSuccessEvent extends PaymentGatewayEvent
8
+{
9
+
10
+}

+ 10
- 0
src/Events/ReturnVerifiedEvent.php View File

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Events;
5
+
6
+
7
+class ReturnVerifiedEvent extends PaymentGatewayEvent
8
+{
9
+
10
+}

+ 4
- 0
src/Facade/Payment.php View File

@@ -22,6 +22,10 @@ use Symfony\Component\HttpFoundation\Response;
22 22
  */
23 23
 class Payment extends Facade
24 24
 {
25
+    const SUCCESS = 1;
26
+    const FAILED = -1;
27
+    const PENDING = 0;
28
+
25 29
     protected static function getFacadeAccessor()
26 30
     {
27 31
         return 'payment';

+ 25
- 0
src/Traits/BillStatusBoolean.php View File

@@ -0,0 +1,25 @@
1
+<?php
2
+/** @noinspection PhpUndefinedMethodInspection */
3
+
4
+namespace MirfalahTech\Laravel\Payment\Traits;
5
+
6
+
7
+use Illuminate\Http\Request;
8
+
9
+trait BillStatusBoolean
10
+{
11
+    public function isBillSuccess(Request $request): bool
12
+    {
13
+        return $this->getBillStatus($request) > 0;
14
+    }
15
+
16
+    public function isBillFailed(Request $request): bool
17
+    {
18
+        return $this->getBillStatus($request) < 0;
19
+    }
20
+
21
+    public function isBillPending(Request $request): bool
22
+    {
23
+        return $this->getBillStatus($request) == 0;
24
+    }
25
+}

Loading…
Cancel
Save