Skip to content

Commit b6fa724

Browse files
authored
Merge pull request #37 from D3lph1/dev
Integration of the shop with the payment aggregator Interkassa is added.
2 parents 4516476 + 1ed8456 commit b6fa724

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1508
-520
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* The store itself is assynchronous a little less than completely.
3333
* Sale of in-game blocks, items, grafts.
3434
* The delivery of goods occurs through the means of the plug-in shopping cart reloaded.
35-
* Integration with the payment aggregator robokassa.
35+
* Integration with the payment aggregator **robokassa** and **interkassa**.
3636
* Multiserver.
3737
* Multi language (English and russian).
3838
* Separation of goods on each server by category.
@@ -92,6 +92,13 @@ Success Url: http://example.ru/payment/success/robokassa
9292
Fail Url: http://example.ru/payment/error/robokassa
9393
Method of sending data: any.
9494

95+
Information for interkassa:
96+
Interaction url: http://example.ru/payment/result/interkassa
97+
Success Url: http://example.ru/payment/success/interkassa
98+
Fail Url: http://example.ru/payment/error/interkassa
99+
Wait Url: http://example.ru/payment/wait/interkassa
100+
Method of sending data: any.
101+
95102
If you plan to use the L-Shop API, be sure to change the secret key. You can do this in the Administration> Management> API section.
96103

97104
After the performed operations, we recommend installing the Directory root of your web server in the public folder.

README_RU.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Сам магазин ассинхронен чуть менее, чем полностью.
3131
* Продажа внутриигровых блоков, предметов, привилегей.
3232
* Выдача товаров происходит по средствам плагина shopping cart reloaded.
33-
* Интеграция с платежным агрегатором robokassa.
33+
* Интеграция с платежными агрегаторами **Robokassa** и **Interkassa**.
3434
* Мультисерверность.
3535
* Мультиязычность (Английский и русский)
3636
* Разделение товаров на каждом сервере по категориям.
@@ -84,12 +84,19 @@
8484
11) Перейти в Администрирование > Управление > Платежи и указать данные от сервиса ROBOKASSA.
8585
12) Перейти в Администрирование > Управление > Оптимизация и обновить кэш маршрутов и конфигов. Это должно положительно сказаться на производительности приложения.
8686

87-
Информация для robokassa:
87+
Информация для Robokassa:
8888
Result URL: http://example.ru/payment/result/robokassa
8989
Success Url: http://example.ru/payment/success/robokassa
9090
Fail Url: http://example.ru/payment/error/robokassa
9191
Метод отсылки данных: любой.​
9292

93+
Информация для Interkassa:
94+
Url взаимодействия: http://example.ru/payment/result/interkassa
95+
URL успешной оплаты: http://example.ru/payment/success/interkassa
96+
URL неуспешной оплаты: http://example.ru/payment/error/interkassa
97+
URL ожидания проведения платежа: http://example.ru/payment/wait/interkassa
98+
Метод отсылки данных: любой.​
99+
93100
Если вы планируете использовать API L-Shop обязательно смените секретный ключ. Сделать это можно в разделе Администрирование > Управление > API.
94101

95102
После проделанных операций, рекомендуем установить Directory root вашего веб-сервера в папку public.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Exceptions\Payment\Interkassa;
4+
5+
use Throwable;
6+
7+
class EmptyDescriptionException extends \RuntimeException
8+
{
9+
public function __construct($message = "", $code = 0, Throwable $previous = null)
10+
{
11+
parent::__construct('Invoice description is required and cannot be empty.', $code, $previous);
12+
}
13+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Exceptions\Payment\Interkassa;
4+
5+
use Throwable;
6+
7+
/**
8+
* Class UnexpectedStatusException
9+
*
10+
* @author D3lph1 <d3lph1.contact@gmail.com>
11+
*
12+
* @package App\Exceptions\Payment\Interkassa
13+
*/
14+
class UnexpectedStatusException extends \RuntimeException
15+
{
16+
public function __construct($status, $code = 0, Throwable $previous = null)
17+
{
18+
$message = "Expected \"success\" invoice status, \"$status\" given";
19+
20+
parent::__construct($message, $code, $previous);
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Exceptions\Payment\Interkassa;
4+
5+
use Throwable;
6+
7+
/**
8+
* Class UnknownCheckoutException
9+
*
10+
* @author D3lph1 <d3lph1.contact@gmail.com>
11+
*
12+
* @package App\Exceptions\Payment\Interkassa
13+
*/
14+
class UnknownCheckoutException extends \RuntimeException
15+
{
16+
public function __construct($checkoutId, $code = 0, Throwable $previous = null)
17+
{
18+
$expected = s_get('payment.method.interkassa.checkout_id');
19+
$message = "Checkout $expected expected, $checkoutId given";
20+
21+
parent::__construct($message, $code, $previous);
22+
}
23+
}

app/Services/Payments/Robokassa/Exception/EmptyDescriptionException.php renamed to app/Exceptions/Payment/Robokassa/EmptyDescriptionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace App\Services\Payments\Robokassa\Exception;
12+
namespace App\Exceptions\Payment\Robokassa;
1313

1414
/**
1515
* Class EmptyDescriptionException

app/Services/Payments/Robokassa/Exception/InvalidInvoiceIdException.php renamed to app/Exceptions/Payment/Robokassa/InvalidInvoiceIdException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace App\Services\Payments\Robokassa\Exception;
12+
namespace App\Exceptions\Payment\Robokassa;
1313

1414
/**
1515
* Class InvalidInvoiceIdException

app/Services/Payments/Robokassa/Exception/InvalidSumException.php renamed to app/Exceptions/Payment/Robokassa/InvalidSumException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace App\Services\Payments\Robokassa\Exception;
12+
namespace App\Exceptions\Payment\Robokassa;
1313

1414
/**
1515
* Class InvalidSumException

app/Services/Payments/Robokassa/Exception/PaymentException.php renamed to app/Exceptions/Payment/Robokassa/PaymentException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace App\Services\Payments\Robokassa\Exception;
12+
namespace App\Exceptions\Payment\Robokassa;
1313

1414
/**
1515
* Class PaymentException

app/Http/Controllers/Admin/Control/PaymentsController.php

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class PaymentsController extends Controller
2929
'sha512'
3030
];
3131

32+
private $interkassaAlgos = [
33+
'md5',
34+
'sha256'
35+
];
36+
3237
/**
3338
* Render payments settings page.
3439
*
@@ -43,12 +48,24 @@ public function render(Request $request)
4348
'minSum' => s_get('payment.fillupbalance.minsum'),
4449
'currency' => s_get('shop.currency'),
4550
'currencyHtml' => s_get('shop.currency_html'),
51+
52+
'robokassaEnable' => s_get('payment.method.robokassa.enabled'),
4653
'robokassaLogin' => s_get('payment.method.robokassa.login'),
4754
'robokassaPassword1' => s_get('payment.method.robokassa.password1'),
4855
'robokassaPassword2' => s_get('payment.method.robokassa.password2'),
4956
'robokassaAlgo' => s_get('payment.method.robokassa.algo'),
5057
'robokassaIsTest' => (bool)s_get('payment.method.robokassa.test'),
51-
'robokassaAlgos' => $this->robokassaAlgos
58+
'robokassaAlgos' => $this->robokassaAlgos,
59+
60+
'interkassaEnable' => s_get('payment.method.interkassa.enabled'),
61+
'interkassaLogin' => s_get('payment.method.interkassa.checkout_id'),
62+
'interkassaKey' => s_get('payment.method.interkassa.key'),
63+
'interkassaTestKey' => s_get('payment.method.interkassa.test_key'),
64+
'interkassaAlgo' => s_get('payment.method.interkassa.algo'),
65+
'interkassaIsTest' => (bool)s_get('payment.method.interkassa.test'),
66+
'interkassaCurrency' => s_get('payment.method.interkassa.currency'),
67+
68+
'interkassaAlgos' => $this->interkassaAlgos,
5269
];
5370

5471
return view('admin.control.payments', $data);
@@ -72,6 +89,15 @@ public function save(SavePaymentsRequest $request)
7289

7390
return back();
7491
}
92+
93+
try {
94+
$this->interkassa($request);
95+
} catch (\UnexpectedValueException $e) {
96+
$this->msg->danger(__('messages.admin.control.payments.interkassa.unknowns_algo'));
97+
98+
return back();
99+
}
100+
75101
$this->msg->success(__('messages.admin.changes_saved'));
76102

77103
return back();
@@ -95,6 +121,7 @@ private function all(Request $request)
95121
*/
96122
private function robokassa(Request $request)
97123
{
124+
$enabled = $request->get('robokassa_enabled');
98125
$login = $request->get('robokassa_login');
99126
$password1 = $request->get('robokassa_password1');
100127
$password2 = $request->get('robokassa_password2');
@@ -106,6 +133,7 @@ private function robokassa(Request $request)
106133
}
107134

108135
s_set([
136+
'payment.method.robokassa.enabled' => (bool)$enabled,
109137
'payment.method.robokassa.login' => $login,
110138
'payment.method.robokassa.password1' => $password1,
111139
'payment.method.robokassa.password2' => $password2,
@@ -115,6 +143,37 @@ private function robokassa(Request $request)
115143
s_save();
116144
}
117145

146+
/**
147+
* Save settings for interkassa.
148+
*
149+
* @param Request $request
150+
*/
151+
private function interkassa(Request $request)
152+
{
153+
$enabled = $request->get('interkassa_enabled');
154+
$login = $request->get('interkassa_checkout_id');
155+
$key = $request->get('interkassa_key');
156+
$testKey = $request->get('interkassa_test_key');
157+
$currency = $request->get('interkassa_currency');
158+
$algo = $request->get('interkassa_algo');
159+
$isTest = (bool)$request->get('interkassa_test');
160+
161+
if (!$this->checkAlgo($algo, 'interkassa')) {
162+
throw New \UnexpectedValueException();
163+
}
164+
165+
s_set([
166+
'payment.method.interkassa.enabled' => (bool)$enabled,
167+
'payment.method.interkassa.checkout_id' => $login,
168+
'payment.method.interkassa.key' => $key,
169+
'payment.method.interkassa.test_key' => $testKey,
170+
'payment.method.interkassa.currency' => (string)$currency,
171+
'payment.method.interkassa.algo' => $algo,
172+
'payment.method.interkassa.test' => $isTest,
173+
]);
174+
s_save();
175+
}
176+
118177
/**
119178
* Check algo on correct name.
120179
*

0 commit comments

Comments
 (0)