Files
Admin Nasledstvo ac168868ee Initial import
2026-05-01 20:52:04 +03:00

63 lines
2.0 KiB
PHP
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\services\payment;
use app\models\Order;
use app\models\OrderPayment;
use app\services\payment\providers\epay\EPay;
class Payment
{
public static function getCheckOut(Order $order, $payment_method)
{
$payment = new OrderPayment();
$payment->order_id = $order->id;
$payment->payment_method = $payment_method;
$payment->amount = $order->total_price;
if ($order->user)
$payment->client_email = $order->user->email;
$payment->save();
switch ($payment->payment_method) {
case 'epay':
case 'card':
$directCard = $payment_method == 'card' ? true : false;
/** [ 3 February 2023 10:59 ] TodoR: Nasl
* [ 3 February 2023 11:00 ] TodoR: Naslk
* [ 3 February 2023 11:00 ] TodoR: 123456
*/
$epay = new EPay();
$epay->setData(EPay::API_MODE_LIVE, 'https://demo.epay.bg/', 'https://www.epay.bg/', $payment->client_email,
[
// DEMO DATA
'client_secret' => 'C6OCA0SZ8LYJN5E3UOE6PJD0ELMW9JL9BRNHEO1TI6M54H9K7JI69H4YZELASABA',
'client_identifier' => 'D727935809'
],
[
//REAL DATA
'client_secret' => 'HPLP2D7MA15NGXR5ZL85Y05P90VGW6S3XB6XBV2Q3UQ3V2HDIZB3Q6EYL0XFHNDD',
'client_identifier' => '1921938405'
]);
$epay->prepareEPayPaymentFormFields($epay->getEpayPaymentDetails($payment), $directCard);
$epay->postSubmit();
break;
}
return '';
}
public static function setPaymentNotification()
{
if (!empty($_GET['type'])) {
switch ($_GET['type']) {
case 'epay':
$epay = new EPay();
$epay->setNotification();
break;
}
}
exit;
}
}