Initial import
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user