浏览代码

init

tags/1.0
0nepeop1e 4 年前
当前提交
cd2062124d
共有 10 个文件被更改,包括 336 次插入0 次删除
  1. 2
    0
      .gitignore
  2. 5
    0
      .idea/codeStyles/codeStyleConfig.xml
  3. 46
    0
      .idea/laravel-payment-dummy.iml
  4. 8
    0
      .idea/modules.xml
  5. 47
    0
      .idea/php.xml
  6. 78
    0
      .idea/workspace.xml
  7. 17
    0
      README.md
  8. 36
    0
      composer.json
  9. 58
    0
      src/DummyPayDriver.php
  10. 39
    0
      src/DummyPayServiceProvider.php

+ 2
- 0
.gitignore 查看文件

@@ -0,0 +1,2 @@
1
+/vendor/
2
+composer.lock

+ 5
- 0
.idea/codeStyles/codeStyleConfig.xml 查看文件

@@ -0,0 +1,5 @@
1
+<component name="ProjectCodeStyleConfiguration">
2
+  <state>
3
+    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+  </state>
5
+</component>

+ 46
- 0
.idea/laravel-payment-dummy.iml 查看文件

@@ -0,0 +1,46 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module type="WEB_MODULE" version="4">
3
+  <component name="NewModuleRootManager">
4
+    <content url="file://$MODULE_DIR$">
5
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="MirfalahTech\Laravel\Payment\Gateway\DummyPay\" />
6
+      <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
7
+      <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
8
+      <excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
9
+      <excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/inflector" />
10
+      <excludeFolder url="file://$MODULE_DIR$/vendor/illuminate/contracts" />
11
+      <excludeFolder url="file://$MODULE_DIR$/vendor/illuminate/filesystem" />
12
+      <excludeFolder url="file://$MODULE_DIR$/vendor/illuminate/http" />
13
+      <excludeFolder url="file://$MODULE_DIR$/vendor/illuminate/session" />
14
+      <excludeFolder url="file://$MODULE_DIR$/vendor/illuminate/support" />
15
+      <excludeFolder url="file://$MODULE_DIR$/vendor/mirfalah/laravel-payment" />
16
+      <excludeFolder url="file://$MODULE_DIR$/vendor/nesbot/carbon" />
17
+      <excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/random_compat" />
18
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
19
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/event-dispatcher" />
20
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
21
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/simple-cache" />
22
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/deprecation-contracts" />
23
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/error-handler" />
24
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher" />
25
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher-contracts" />
26
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/finder" />
27
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-foundation" />
28
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-kernel" />
29
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mime" />
30
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
31
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
32
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
33
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
34
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php70" />
35
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
36
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php73" />
37
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
38
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation" />
39
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation-contracts" />
40
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-dumper" />
41
+      <excludeFolder url="file://$MODULE_DIR$/vendor/voku/portable-ascii" />
42
+    </content>
43
+    <orderEntry type="inheritedJdk" />
44
+    <orderEntry type="sourceFolder" forTests="false" />
45
+  </component>
46
+</module>

+ 8
- 0
.idea/modules.xml 查看文件

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/laravel-payment-dummy.iml" filepath="$PROJECT_DIR$/.idea/laravel-payment-dummy.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 47
- 0
.idea/php.xml 查看文件

@@ -0,0 +1,47 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="PhpIncludePathManager">
4
+    <include_path>
5
+      <path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
6
+      <path value="$PROJECT_DIR$/vendor/mirfalah/laravel-payment" />
7
+      <path value="$PROJECT_DIR$/vendor/psr/log" />
8
+      <path value="$PROJECT_DIR$/vendor/psr/container" />
9
+      <path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
10
+      <path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
11
+      <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
12
+      <path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
13
+      <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
14
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
15
+      <path value="$PROJECT_DIR$/vendor/symfony/translation" />
16
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
17
+      <path value="$PROJECT_DIR$/vendor/symfony/mime" />
18
+      <path value="$PROJECT_DIR$/vendor/nesbot/carbon" />
19
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php73" />
20
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
21
+      <path value="$PROJECT_DIR$/vendor/composer" />
22
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
23
+      <path value="$PROJECT_DIR$/vendor/voku/portable-ascii" />
24
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
25
+      <path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
26
+      <path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
27
+      <path value="$PROJECT_DIR$/vendor/symfony/finder" />
28
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php70" />
29
+      <path value="$PROJECT_DIR$/vendor/illuminate/http" />
30
+      <path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
31
+      <path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
32
+      <path value="$PROJECT_DIR$/vendor/illuminate/filesystem" />
33
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
34
+      <path value="$PROJECT_DIR$/vendor/illuminate/support" />
35
+      <path value="$PROJECT_DIR$/vendor/illuminate/session" />
36
+      <path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
37
+      <path value="$PROJECT_DIR$/vendor/illuminate/contracts" />
38
+      <path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
39
+    </include_path>
40
+  </component>
41
+  <component name="PhpProjectSharedConfiguration" php_language_level="7.1" />
42
+  <component name="PhpUnit">
43
+    <phpunit_settings>
44
+      <PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
45
+    </phpunit_settings>
46
+  </component>
47
+</project>

+ 78
- 0
.idea/workspace.xml 查看文件

@@ -0,0 +1,78 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="d34cafd0-eade-4b43-97b9-dd7f3a1eae86" name="Default Changelist" comment="" />
5
+    <option name="SHOW_DIALOG" value="false" />
6
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
7
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
8
+    <option name="LAST_RESOLUTION" value="IGNORE" />
9
+  </component>
10
+  <component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
11
+    <pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
12
+    <execution />
13
+  </component>
14
+  <component name="PhpWorkspaceProjectConfiguration">
15
+    <include_path>
16
+      <path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
17
+      <path value="$PROJECT_DIR$/vendor/mirfalah/laravel-payment" />
18
+      <path value="$PROJECT_DIR$/vendor/psr/log" />
19
+      <path value="$PROJECT_DIR$/vendor/psr/container" />
20
+      <path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
21
+      <path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
22
+      <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
23
+      <path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
24
+      <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
25
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
26
+      <path value="$PROJECT_DIR$/vendor/symfony/translation" />
27
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
28
+      <path value="$PROJECT_DIR$/vendor/symfony/mime" />
29
+      <path value="$PROJECT_DIR$/vendor/nesbot/carbon" />
30
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php73" />
31
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
32
+      <path value="$PROJECT_DIR$/vendor/composer" />
33
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
34
+      <path value="$PROJECT_DIR$/vendor/voku/portable-ascii" />
35
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
36
+      <path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
37
+      <path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
38
+      <path value="$PROJECT_DIR$/vendor/symfony/finder" />
39
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php70" />
40
+      <path value="$PROJECT_DIR$/vendor/illuminate/http" />
41
+      <path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
42
+      <path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
43
+      <path value="$PROJECT_DIR$/vendor/illuminate/filesystem" />
44
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
45
+      <path value="$PROJECT_DIR$/vendor/illuminate/support" />
46
+      <path value="$PROJECT_DIR$/vendor/illuminate/session" />
47
+      <path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
48
+      <path value="$PROJECT_DIR$/vendor/illuminate/contracts" />
49
+      <path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
50
+    </include_path>
51
+  </component>
52
+  <component name="ProjectId" id="1htW5VaFbIHUzp9eSpkWJUVlqhl" />
53
+  <component name="ProjectViewState">
54
+    <option name="hideEmptyMiddlePackages" value="true" />
55
+    <option name="showLibraryContents" value="true" />
56
+  </component>
57
+  <component name="PropertiesComponent">
58
+    <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
59
+    <property name="WebServerToolWindowFactoryState" value="false" />
60
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
61
+    <property name="vue.rearranger.settings.migration" value="true" />
62
+  </component>
63
+  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
64
+  <component name="TaskManager">
65
+    <task active="true" id="Default" summary="Default task">
66
+      <changelist id="d34cafd0-eade-4b43-97b9-dd7f3a1eae86" name="Default Changelist" comment="" />
67
+      <created>1600830685900</created>
68
+      <option name="number" value="Default" />
69
+      <option name="presentableId" value="Default" />
70
+      <updated>1600830685900</updated>
71
+      <workItem from="1600830687029" duration="621000" />
72
+    </task>
73
+    <servers />
74
+  </component>
75
+  <component name="TypeScriptGeneratedFilesManager">
76
+    <option name="version" value="3" />
77
+  </component>
78
+</project>

+ 17
- 0
README.md 查看文件

@@ -0,0 +1,17 @@
1
+# mirfalah/laravel-payment-dummy
2
+
3
+## Installation
4
+Add the following repository to composer.json
5
+```json
6
+{
7
+    "repositories": [
8
+        {
9
+            "type": "composer",
10
+            "url": "https://composer.mirfalah.my"
11
+        }
12
+    ]
13
+}
14
+```
15
+```shell script
16
+composer install mirfalah/laravel-payment-dummy ^1.0
17
+```

+ 36
- 0
composer.json 查看文件

@@ -0,0 +1,36 @@
1
+{
2
+    "name": "mirfalah/laravel-payment-dummy",
3
+    "description": "Laravel payment dummy driver, a dummy payment gateway for development.",
4
+    "type": "library",
5
+    "homepage": "https://git.mirfalah.my/mirfalah-tech/laravel-payment-dummy.git",
6
+    "readme": "README.md",
7
+    "require": {
8
+        "php": ">=7.1",
9
+        "mirfalah/laravel-payment": "^1.0"
10
+    },
11
+    "license": "Mirfalah-Tech",
12
+    "authors": [
13
+        {
14
+            "name": "Lim Eng Shun",
15
+            "email": "engshun@mirfalah.my"
16
+        }
17
+    ],
18
+    "autoload": {
19
+        "psr-4": {
20
+            "MirfalahTech\\Laravel\\Payment\\Gateway\\DummyPay\\": "src/"
21
+        }
22
+    },
23
+    "extra": {
24
+        "laravel": {
25
+            "providers": [
26
+                "MirfalahTech\\Laravel\\Payment\\Gateway\\DummyPay\\DummyPayPayServiceProvider"
27
+            ]
28
+        }
29
+    },
30
+    "repositories": [
31
+        {
32
+            "type": "composer",
33
+            "url": "https://composer.mirfalah.my"
34
+        }
35
+    ]
36
+}

+ 58
- 0
src/DummyPayDriver.php 查看文件

@@ -0,0 +1,58 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Gateway\DummyPay;
5
+
6
+
7
+use Illuminate\Http\Request;
8
+use Illuminate\Support\Facades\Response as Res;
9
+use MirfalahTech\Laravel\Payment\Contracts\PayableEntity;
10
+use MirfalahTech\Laravel\Payment\Contracts\PaymentGatewayDriver;
11
+use Symfony\Component\HttpFoundation\Response;
12
+
13
+class DummyPayDriver implements PaymentGatewayDriver
14
+{
15
+    /**
16
+     * @var string
17
+     */
18
+    protected $callback_url;
19
+
20
+    /**
21
+     * @var string
22
+     */
23
+    protected $return_url;
24
+
25
+    public function __construct(string $callback_url, string $return_url){
26
+        $this->callback_url = rtrim($callback_url, '/');
27
+        $this->return_url = rtrim($return_url, '/');
28
+    }
29
+
30
+    public function createPaymentURL(PayableEntity $payable, array $options = []): string
31
+    {
32
+        $order_id = $payable->getBillId();
33
+        return "$this->callback_url?'".http_build_query(compact('order_id'));
34
+    }
35
+
36
+    public function verifyGatewayReturn(Request $request): bool
37
+    {
38
+        return true;
39
+    }
40
+
41
+    public function verifyGatewayCallback(Request $request, Response &$response = null): bool
42
+    {
43
+        if($request->query->has('status')){
44
+            Res::redirectTo($this->return_url);
45
+            return $request->query->get('status') == 'success';
46
+        } else {
47
+            $order_id = $request->query->get('order_id');
48
+            /** @noinspection HtmlUnknownTarget */
49
+            $html = sprintf(
50
+                '<a href="%s">Click Here for Positive Response</a><br/><br/><a href="%s">Click Here for Negative Response</a>',
51
+                $this->callback_url.'?'.http_build_query(['order_id' => $order_id, 'status' => 'success']),
52
+                $this->callback_url.'?'.http_build_query(['order_id' => $order_id, 'status' => 'failed'])
53
+            );
54
+            Res::make($html);
55
+            return false;
56
+        }
57
+    }
58
+}

+ 39
- 0
src/DummyPayServiceProvider.php 查看文件

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Gateway\DummyPay;
5
+
6
+
7
+use Illuminate\Contracts\Config\Repository;
8
+use Illuminate\Contracts\Container\BindingResolutionException;
9
+use Illuminate\Support\ServiceProvider;
10
+use MirfalahTech\Laravel\Payment\Manager\PaymentManager;
11
+
12
+class DummyPayServiceProvider extends ServiceProvider
13
+{
14
+    /**
15
+     * @throws BindingResolutionException
16
+     */
17
+    public function boot()
18
+    {
19
+        /** @var Repository $config */
20
+        $config = $this->app->make('config');
21
+
22
+        $config->set('payment.gateway.dummy', array_merge(
23
+            [
24
+                'callback_url' => env('DUMMYPAY_CALLBACK'),
25
+                'return_url' => env('DUMMYPAY_RETURN'),
26
+            ],
27
+            $config->get('payment.gateway.dummy', [])
28
+        ));
29
+
30
+        $this->app->afterResolving('payment', function (PaymentManager $manager) use ($config) {
31
+            $manager->extend('dummy', function () use ($config) {
32
+                return new DummyPayDriver(
33
+                    $config->get('payment.gateway.dummy.callback_url'),
34
+                    $config->get('payment.gateway.dummy.return_url')
35
+                );
36
+            });
37
+        });
38
+    }
39
+}

正在加载...
取消
保存