Ver código fonte

init

tags/1.0
0nepeop1e 3 anos atrás
commit
c9f75d8d43

+ 1
- 0
.gitignore Ver arquivo

@@ -0,0 +1 @@
1
+/vendor/

+ 21
- 0
.idea/.gitignore Ver arquivo

@@ -0,0 +1,21 @@
1
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
2
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3
+
4
+# User-specific stuff
5
+**/workspace.xml
6
+**/tasks.xml
7
+**/usage.statistics.xml
8
+**/dictionaries
9
+**/shelf
10
+
11
+# Generated files
12
+**/contentModel.xml
13
+
14
+# Sensitive or high-churn files
15
+**/dataSources/
16
+**/dataSources.ids
17
+**/dataSources.local.xml
18
+**/sqlDataSources.xml
19
+**/dynamic.xml
20
+**/uiDesigner.xml
21
+**/dbnavigator.xml

+ 45
- 0
.idea/mirfalah-payment.iml Ver arquivo

@@ -0,0 +1,45 @@
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$/spec" isTestSource="true" />
6
+      <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
7
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="MirfalahTech\Laravel\Payment\" />
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/nesbot/carbon" />
16
+      <excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/random_compat" />
17
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
18
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/event-dispatcher" />
19
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
20
+      <excludeFolder url="file://$MODULE_DIR$/vendor/psr/simple-cache" />
21
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/deprecation-contracts" />
22
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/error-handler" />
23
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher" />
24
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher-contracts" />
25
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/finder" />
26
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-foundation" />
27
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-kernel" />
28
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mime" />
29
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
30
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
31
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
32
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
33
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php70" />
34
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
35
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php73" />
36
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
37
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation" />
38
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation-contracts" />
39
+      <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-dumper" />
40
+      <excludeFolder url="file://$MODULE_DIR$/vendor/voku/portable-ascii" />
41
+    </content>
42
+    <orderEntry type="inheritedJdk" />
43
+    <orderEntry type="sourceFolder" forTests="false" />
44
+  </component>
45
+</module>

+ 8
- 0
.idea/modules.xml Ver arquivo

@@ -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/mirfalah-payment.iml" filepath="$PROJECT_DIR$/.idea/mirfalah-payment.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 41
- 0
.idea/php.xml Ver arquivo

@@ -0,0 +1,41 @@
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/composer" />
6
+      <path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
7
+      <path value="$PROJECT_DIR$/vendor/psr/container" />
8
+      <path value="$PROJECT_DIR$/vendor/nesbot/carbon" />
9
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
10
+      <path value="$PROJECT_DIR$/vendor/illuminate/contracts" />
11
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
12
+      <path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
13
+      <path value="$PROJECT_DIR$/vendor/illuminate/support" />
14
+      <path value="$PROJECT_DIR$/vendor/symfony/translation" />
15
+      <path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
16
+      <path value="$PROJECT_DIR$/vendor/voku/portable-ascii" />
17
+      <path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
18
+      <path value="$PROJECT_DIR$/vendor/psr/log" />
19
+      <path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
20
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php73" />
21
+      <path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
22
+      <path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
23
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
24
+      <path value="$PROJECT_DIR$/vendor/symfony/finder" />
25
+      <path value="$PROJECT_DIR$/vendor/illuminate/session" />
26
+      <path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
27
+      <path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
28
+      <path value="$PROJECT_DIR$/vendor/illuminate/http" />
29
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
30
+      <path value="$PROJECT_DIR$/vendor/illuminate/filesystem" />
31
+      <path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
32
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
33
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-php70" />
34
+      <path value="$PROJECT_DIR$/vendor/symfony/mime" />
35
+      <path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
36
+      <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
37
+      <path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
38
+    </include_path>
39
+  </component>
40
+  <component name="PhpProjectSharedConfiguration" php_language_level="7.1" />
41
+</project>

+ 6
- 0
.idea/vcs.xml Ver arquivo

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+  </component>
6
+</project>

+ 3
- 0
README.md Ver arquivo

@@ -0,0 +1,3 @@
1
+# mirfalah/laravel-payment
2
+
3
+This library is not complete yet, this is just placeholder

+ 29
- 0
composer.json Ver arquivo

@@ -0,0 +1,29 @@
1
+{
2
+    "name": "mirfalah/laravel-payment",
3
+    "description": "Laravel payment service provider",
4
+    "type": "library",
5
+    "require": {
6
+        "php": ">=7.1",
7
+        "illuminate/support": ">=5.0 <8.0",
8
+        "illuminate/http": ">=5.0 <8.0"
9
+    },
10
+    "license": "Mirfalah-Tech",
11
+    "authors": [
12
+        {
13
+            "name": "Lim Eng Shun",
14
+            "email": "engshun@mirfalah.my"
15
+        }
16
+    ],
17
+    "autoload": {
18
+        "psr-4": {
19
+            "MirfalahTech\\Laravel\\Payment\\": "src/"
20
+        }
21
+    },
22
+    "extra": {
23
+        "laravel": {
24
+            "providers": [
25
+                "MirfalahTech\\Laravel\\Payment\\PaymentServiceProvider"
26
+            ]
27
+        }
28
+    }
29
+}

+ 2277
- 0
composer.lock
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 7
- 0
config/payment.php Ver arquivo

@@ -0,0 +1,7 @@
1
+<?php
2
+
3
+return [
4
+    'default' => env('PAYMENT_GATEWAY'),
5
+
6
+    'gateway' => [],
7
+];

+ 66
- 0
src/Contracts/PayableEntity.php Ver arquivo

@@ -0,0 +1,66 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Contracts;
5
+
6
+
7
+interface PayableEntity
8
+{
9
+    /**
10
+     * A unique id which represent the order.
11
+     *
12
+     * @return string
13
+     */
14
+    public function getBillId(): string;
15
+
16
+    /**
17
+     * Decimal number without any currency symbol, payment gateway need to convert
18
+     * if different standard is used.
19
+     *
20
+     * @return string
21
+     */
22
+    public function getBillAmount(): string;
23
+
24
+    /**
25
+     * Get buyer's name.
26
+     * @return string
27
+     */
28
+    public function getBillName(): string;
29
+
30
+    /**
31
+     * Get buyer's email.
32
+     *
33
+     * @return string
34
+     */
35
+    public function getBillEmail(): string;
36
+
37
+    /**
38
+     * Get buyer's phone number.
39
+     *
40
+     * @return string
41
+     */
42
+    public function getBillPhoneNumber(): string;
43
+
44
+    /**
45
+     * Get description for payment.
46
+     *
47
+     * @return string
48
+     */
49
+    public function getBillDescription(): string;
50
+
51
+    /**
52
+     * Get ISO 4214 currency code, payment gateway driver need to
53
+     * convert if different standard is used.
54
+     *
55
+     * @return string
56
+     */
57
+    public function getBillCurrency(): string;
58
+
59
+    /**
60
+     * Get ISO 3166 country code, payment gateway driver need to
61
+     * convert if different standard is used.
62
+     *
63
+     * @return string
64
+     */
65
+    public function getBillCountry(): string;
66
+}

+ 10
- 0
src/Contracts/PaymentFactory.php Ver arquivo

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Contracts;
5
+
6
+
7
+interface PaymentFactory
8
+{
9
+    public function via(string $gateway = null): PaymentGatewayDriver;
10
+}

+ 17
- 0
src/Contracts/PaymentGatewayDriver.php Ver arquivo

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Contracts;
5
+
6
+
7
+use Illuminate\Http\Request;
8
+use Symfony\Component\HttpFoundation\Response;
9
+
10
+interface PaymentGatewayDriver
11
+{
12
+    public function createPaymentURL(PayableEntity $payable, array $options = []): string;
13
+
14
+    public function verifyGatewayReturn(Request $request): bool;
15
+
16
+    public function verifyGatewayCallback(Request $request, Response &$response = null): bool;
17
+}

+ 28
- 0
src/Facade/Payment.php Ver arquivo

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Facade;
5
+
6
+
7
+use Illuminate\Http\Request;
8
+use Illuminate\Support\Facades\Facade;
9
+use MirfalahTech\Laravel\Payment\Contracts\PayableEntity;
10
+use MirfalahTech\Laravel\Payment\Contracts\PaymentGatewayDriver;
11
+use Symfony\Component\HttpFoundation\Response;
12
+
13
+/**
14
+ * Class Payment
15
+ * @package MirfalahTech\Laravel\Payment\Facade
16
+ *
17
+ * @method static PaymentGatewayDriver via(string $gateway = null)
18
+ * @method static string createPaymentURL(PayableEntity $payable, array $options = [])
19
+ * @method static bool verifyGatewayReturn(Request $request)
20
+ * @method static bool verifyGatewayCallback(Request $request, Response &$response = null)
21
+ */
22
+class Payment extends Facade
23
+{
24
+    protected static function getFacadeAccessor()
25
+    {
26
+        return 'payment';
27
+    }
28
+}

+ 46
- 0
src/Manager/PaymentManager.php Ver arquivo

@@ -0,0 +1,46 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment\Manager;
5
+
6
+
7
+use Illuminate\Contracts\Container\Container;
8
+use Illuminate\Http\Request;
9
+use Illuminate\Support\Manager;
10
+use MirfalahTech\Laravel\Payment\Contracts\PayableEntity;
11
+use MirfalahTech\Laravel\Payment\Contracts\PaymentFactory;
12
+use MirfalahTech\Laravel\Payment\Contracts\PaymentGatewayDriver;
13
+use Symfony\Component\HttpFoundation\Response;
14
+
15
+/**
16
+ * Class PaymentManager
17
+ * @package MirfalahTech\Laravel\Payment\Manager
18
+ *
19
+ * @method PaymentGatewayDriver driver($driver = null)
20
+ * @method string createPaymentURL(PayableEntity $payable, array $options = [])
21
+ * @method bool verifyGatewayReturn(Request $request)
22
+ * @method bool verifyGatewayCallback(Request $request, Response &$response = null)
23
+ */
24
+class PaymentManager extends Manager implements PaymentFactory
25
+{
26
+    /**
27
+     * @var string
28
+     */
29
+    protected $defaultGateway;
30
+
31
+    public function __construct(Container $container, string $defaultGateway)
32
+    {
33
+        parent::__construct($container);
34
+        $this->defaultGateway = $defaultGateway;
35
+    }
36
+
37
+    public function via(string $gateway = null): PaymentGatewayDriver
38
+    {
39
+        return $this->driver($gateway);
40
+    }
41
+
42
+    public function getDefaultDriver()
43
+    {
44
+        return $this->defaultGateway;
45
+    }
46
+}

+ 37
- 0
src/PaymentServiceProvider.php Ver arquivo

@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+
4
+namespace MirfalahTech\Laravel\Payment;
5
+
6
+
7
+use Illuminate\Contracts\Config\Repository;
8
+use Illuminate\Contracts\Foundation\Application;
9
+use Illuminate\Support\ServiceProvider;
10
+use MirfalahTech\Laravel\Payment\Manager\PaymentManager;
11
+
12
+class PaymentServiceProvider extends ServiceProvider
13
+{
14
+    public function boot()
15
+    {
16
+        $config_path = realpath(__DIR__ . '/../config/payment.php');
17
+
18
+        /** @var Repository $config */
19
+        $config = $this->app->make('config');
20
+
21
+        /** @noinspection PhpIncludeInspection */
22
+        $config->set('payment', array_merge(
23
+            require $config_path,
24
+            $config->get('payment')
25
+        ));
26
+
27
+        $this->app->singleton('payment', function (Application $app) use ($config) {
28
+            return new PaymentManager($app, $config->get('payment.default'));
29
+        });
30
+
31
+        $this->app->alias('payment', PaymentManager::class);
32
+
33
+        $this->publishes([
34
+            $config_path => $this->app->configPath('payment.php')
35
+        ], 'config');
36
+    }
37
+}

Carregando…
Cancelar
Salvar