Последняя версия с сервера прошлого разработчика
This commit is contained in:
70
app/Domain/PaymentGateway/Models/PaymentGatewayOrder.php
Executable file
70
app/Domain/PaymentGateway/Models/PaymentGatewayOrder.php
Executable file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
namespace App\Domain\PaymentGateway\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PaymentGatewayOrder extends Model
|
||||
{
|
||||
const TYPE_INTERKASSA_NAME = "interkassa";
|
||||
const TYPE_UNITPAY_NAME = "unitpay";
|
||||
const TYPE_QIWI_NAME = "qiwi";
|
||||
const TYPE_YOO_NAME = "yookassa";
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public static function interkassa($amount)
|
||||
{
|
||||
$paymentGatewayOrder = new PaymentGatewayOrder;
|
||||
$paymentGatewayOrder->user_id = auth()->user()->id;
|
||||
$paymentGatewayOrder->amount = $amount;
|
||||
$paymentGatewayOrder->status = 0; // 0 - created/ 1- success/ 2-error/ 3-pending
|
||||
$paymentGatewayOrder->type = self::TYPE_INTERKASSA_NAME;
|
||||
$paymentGatewayOrder->save();
|
||||
|
||||
return $paymentGatewayOrder;
|
||||
}
|
||||
|
||||
public static function unitpay($amount)
|
||||
{
|
||||
$paymentGatewayOrder = new PaymentGatewayOrder;
|
||||
$paymentGatewayOrder->user_id = auth()->user()->id;
|
||||
$paymentGatewayOrder->amount = $amount;
|
||||
$paymentGatewayOrder->status = 0; // 0 - created/ 1- success/ 2-error/ 3-pending
|
||||
$paymentGatewayOrder->type = self::TYPE_UNITPAY_NAME;
|
||||
$paymentGatewayOrder->save();
|
||||
|
||||
return $paymentGatewayOrder;
|
||||
}
|
||||
|
||||
public static function qiwi($amount)
|
||||
{
|
||||
$paymentGatewayOrder = new PaymentGatewayOrder;
|
||||
$paymentGatewayOrder->user_id = auth()->user()->id;
|
||||
$paymentGatewayOrder->amount = $amount;
|
||||
$paymentGatewayOrder->number = (string) Str::uuid();
|
||||
$paymentGatewayOrder->status = 0; // 0 - created/ 1- success/ 2-error/ 3-pending
|
||||
$paymentGatewayOrder->type = self::TYPE_QIWI_NAME;
|
||||
$paymentGatewayOrder->save();
|
||||
|
||||
return $paymentGatewayOrder;
|
||||
}
|
||||
|
||||
public static function yookassa($amount)
|
||||
{
|
||||
$paymentGatewayOrder = new PaymentGatewayOrder;
|
||||
$paymentGatewayOrder->user_id = auth()->user()->id;
|
||||
$paymentGatewayOrder->amount = $amount;
|
||||
$paymentGatewayOrder->number = (string) Str::uuid();
|
||||
$paymentGatewayOrder->status = 0; // 0 - created/ 1- success/ 2-error/ 3-pending
|
||||
$paymentGatewayOrder->type = self::TYPE_YOO_NAME;
|
||||
$paymentGatewayOrder->save();
|
||||
|
||||
return $paymentGatewayOrder;
|
||||
}
|
||||
|
||||
}
|
||||
25
app/Domain/PaymentGateway/Services/InterkassaService.php
Executable file
25
app/Domain/PaymentGateway/Services/InterkassaService.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\PaymentGateway\Services;
|
||||
|
||||
class InterkassaService
|
||||
{
|
||||
public static function payments_link($amount, $order_id)
|
||||
{
|
||||
$configuration = new \Interkassa\Helper\Config();
|
||||
$configuration->setCheckoutSecretKey(env('INTERKASSA_SECRET_KEY'));
|
||||
$configuration->setAuthorizationKey(env('INTERKASSA_AUTH_KEY'));
|
||||
$configuration->setAccountId(env('INTERKASSA_ACCOUNT_ID'));
|
||||
$SDKClient = new \Interkassa\Interkassa($configuration);
|
||||
|
||||
$invoiceRequest = new \Interkassa\Request\GetInvoiceRequest();
|
||||
$invoiceRequest
|
||||
->setCheckoutId(env('INTERKASSA_ID'))
|
||||
->setPaymentNumber($order_id)
|
||||
->setAmount($amount)
|
||||
->setCurrency('RUB')
|
||||
->setDescription('Пополнение баланса');
|
||||
|
||||
return $SDKClient->makeInvoiceSciLink($invoiceRequest);
|
||||
}
|
||||
}
|
||||
27
app/Domain/PaymentGateway/Services/QiwiService.php
Executable file
27
app/Domain/PaymentGateway/Services/QiwiService.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\PaymentGateway\Services;
|
||||
|
||||
class QiwiService
|
||||
{
|
||||
public static function payments_link($amount, $order, $user)
|
||||
{
|
||||
$publicKey = env('QIWI_PUBLIC');
|
||||
$SECRET_KEY = env('QIWI_SECRET');
|
||||
|
||||
$billPayments = new \Qiwi\Api\BillPayments($SECRET_KEY);
|
||||
$success_url = env('APP_URL') . '/qiwi-to-payments/status/' . $order->number;
|
||||
|
||||
$params = [
|
||||
'publicKey' => $publicKey,
|
||||
'amount' => $amount,
|
||||
'billId' => $order->number,
|
||||
'successUrl' => $success_url,
|
||||
'email' => $user->email,
|
||||
'comment' => 'Пополнение баланса',
|
||||
];
|
||||
|
||||
return $billPayments->createPaymentForm($params);
|
||||
|
||||
}
|
||||
}
|
||||
66
app/Domain/PaymentGateway/Services/UnitpayService.php
Executable file
66
app/Domain/PaymentGateway/Services/UnitpayService.php
Executable file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\PaymentGateway\Services;
|
||||
|
||||
use UnitPay;
|
||||
use CashItem;
|
||||
|
||||
class UnitpayService
|
||||
{
|
||||
public static function payments_link($amount, $order_id)
|
||||
{
|
||||
|
||||
// Project Data
|
||||
$domain = 'unitpay.ru';// Your working domain: unitpay.ru or address provided by unitpay support service
|
||||
$secretKey = '72449d551500fb99bb66499203ed1ccb';// Project secret key
|
||||
$publicId = 'demo';
|
||||
// $publicId = '438925-9eafe';
|
||||
|
||||
// My item Info
|
||||
$itemName = 'Пополнение баланса';
|
||||
|
||||
// My Order Data
|
||||
$orderId = $order_id;
|
||||
$orderSum = $amount;
|
||||
$orderDesc = 'Payment for item "' . $itemName . '"';
|
||||
$orderCurrency = 'RUB';
|
||||
|
||||
$unitpay = new UnitPay($domain, $secretKey);
|
||||
|
||||
// ->setCustomerEmail('customer@domain.com')
|
||||
// ->setCustomerPhone('79001235555')
|
||||
|
||||
|
||||
$unitpay
|
||||
->setBackUrl('https://teeaseer.com')
|
||||
->setCashItems([
|
||||
new CashItem($itemName, 1, $orderSum)
|
||||
]);
|
||||
|
||||
$redirectUrl = $unitpay->form(
|
||||
$publicId,
|
||||
$orderSum,
|
||||
$orderId,
|
||||
$orderDesc,
|
||||
$orderCurrency
|
||||
);
|
||||
return $redirectUrl;
|
||||
|
||||
|
||||
// $configuration = new \Interkassa\Helper\Config();
|
||||
// $configuration->setCheckoutSecretKey(env('INTERKASSA_SECRET_KEY'));
|
||||
// $configuration->setAuthorizationKey(env('INTERKASSA_AUTH_KEY'));
|
||||
// $configuration->setAccountId(env('INTERKASSA_ACCOUNT_ID'));
|
||||
// $SDKClient = new \Interkassa\Interkassa($configuration);
|
||||
|
||||
// $invoiceRequest = new \Interkassa\Request\GetInvoiceRequest();
|
||||
// $invoiceRequest
|
||||
// ->setCheckoutId(env('INTERKASSA_ID'))
|
||||
// ->setPaymentNumber($order_id)
|
||||
// ->setAmount($amount)
|
||||
// ->setCurrency('RUB')
|
||||
// ->setDescription('Пополнение баланса');
|
||||
|
||||
// return $SDKClient->makeInvoiceSciLink($invoiceRequest);
|
||||
}
|
||||
}
|
||||
65
app/Domain/PaymentGateway/Services/YookassaService.php
Executable file
65
app/Domain/PaymentGateway/Services/YookassaService.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\PaymentGateway\Services;
|
||||
|
||||
use YooKassa\Client;
|
||||
|
||||
class YookassaService
|
||||
{
|
||||
public static function payments_link($amount, $order, $user)
|
||||
{
|
||||
|
||||
$YOOKASSA_SHOP_ID = env('YOOKASSA_SHOP_ID');
|
||||
$YOOKASSA_KEY = env('YOOKASSA_KEY');
|
||||
|
||||
$idempotenceKey = $order->number;
|
||||
$client = new Client();
|
||||
$client->setAuth($YOOKASSA_SHOP_ID, $YOOKASSA_KEY);
|
||||
$success_url = env('APP_URL') . '/payments/status/' . $order->number;
|
||||
$response = $client->createPayment(
|
||||
[
|
||||
'amount' => [
|
||||
'value' => $amount,
|
||||
'currency' => 'RUB',
|
||||
],
|
||||
'capture' => true,
|
||||
'payment_method_data' => [
|
||||
'type' => 'sbp',
|
||||
],
|
||||
'confirmation' => [
|
||||
'type' => 'redirect',
|
||||
'return_url' => $success_url,
|
||||
],
|
||||
'receipt' => [
|
||||
'customer' => [
|
||||
'full_name' => $user->name ?? $user->username,
|
||||
'phone' => $user->phone,
|
||||
"email" => $user->email
|
||||
],
|
||||
'items' => [
|
||||
[
|
||||
'description' => 'оплата бонусов тизер',
|
||||
'quantity' => 1.00,
|
||||
'amount' => [
|
||||
'value' => $amount,
|
||||
'currency' => 'RUB',
|
||||
],
|
||||
'vat_code' => 1,
|
||||
'payment_mode' => 'full_payment'
|
||||
]
|
||||
]
|
||||
],
|
||||
'description' => 'Заказ №' . $order->id,
|
||||
],
|
||||
$idempotenceKey
|
||||
);
|
||||
$order->system_payment_id = $response->getId();
|
||||
$order->save();
|
||||
|
||||
|
||||
$confirmationUrl = $response->getConfirmation()->getConfirmationUrl();
|
||||
return $confirmationUrl;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user