first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace Modules\Payment\Responses;
use Modules\Order\Entities\Order;
use Modules\Payment\GatewayResponse;
use Modules\Payment\HasTransactionReference;
class AuthorizenetResponse extends GatewayResponse implements HasTransactionReference
{
private $order;
private $clientResponse;
public function __construct(Order $order,object $clientResponse)
{
$this->order = $order;
$this->clientResponse = $clientResponse;
}
public function getOrderId()
{
return $this->order->id;
}
public function getTransactionReference()
{
return $this->clientResponse->query('reference');
}
public function toArray()
{
return $this->order->toArray() + [
'token' => $this->clientResponse->token,
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Modules\Payment\Responses;
use Modules\Order\Entities\Order;
use Modules\Payment\Gateways\MercadoPago;
use Modules\Payment\ShouldRedirect;
use Modules\Payment\GatewayResponse;
use Modules\Payment\HasTransactionReference;
class FlutterwaveResponse extends GatewayResponse implements ShouldRedirect, HasTransactionReference
{
private $order;
private $clientResponse;
public function __construct(Order $order, array|object $clientResponse)
{
$this->order = $order;
$this->clientResponse = $clientResponse;
}
public function getOrderId()
{
return $this->order->id;
}
public function getRedirectUrl()
{
return $this->clientResponse['redirect_url'];
}
public function getTransactionReference()
{
return $this->clientResponse['tx_ref'];
}
public function toArray()
{
return (array) $this->clientResponse;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Modules\Payment\Responses;
use Modules\Order\Entities\Order;
use Modules\Payment\ShouldRedirect;
use Modules\Payment\GatewayResponse;
use Modules\Payment\HasTransactionReference;
class InstamojoResponse extends GatewayResponse implements ShouldRedirect, HasTransactionReference
{
private $order;
private $clientResponse;
public function __construct(Order $order, array $clientResponse)
{
$this->order = $order;
$this->clientResponse = $clientResponse;
}
public function getOrderId()
{
return $this->order->id;
}
public function getRedirectUrl()
{
return $this->clientResponse['redirectUrl'];
}
public function getTransactionReference()
{
return $this->clientResponse['payment_id'];
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Modules\Payment\Responses;
use Modules\Order\Entities\Order;
use Modules\Payment\ShouldRedirect;
use Modules\Payment\GatewayResponse;
use Modules\Payment\HasTransactionReference;
class MercadoPagoResponse extends GatewayResponse implements ShouldRedirect, HasTransactionReference
{
private $order;
private $clientResponse;
public function __construct(Order $order, object $clientResponse)
{
$this->order = $order;
$this->clientResponse = $clientResponse;
}
public function getOrderId()
{
return $this->order->id;
}
public function getRedirectUrl()
{
return $this->clientResponse->back_urls->success;
}
public function getTransactionReference()
{
return $this->clientResponse->external_reference;
}
public function toArray()
{
return [
'publicKey' => setting('mercadopago_public_key'),
'currentLocale' => locale(),
'preferenceId' => $this->clientResponse->id,
];
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Modules\Payment\Responses;
use Modules\Order\Entities\Order;
use Modules\Payment\GatewayResponse;
class NullResponse extends GatewayResponse
{
private $order;
public function __construct(Order $order)
{
$this->order = $order;
}
public function getOrderId()
{
return $this->order->id;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Modules\Payment\Responses;
use PayPalHttp\HttpResponse;
use Modules\Order\Entities\Order;
use Modules\Payment\GatewayResponse;
use Modules\Payment\HasTransactionReference;
class PayPalResponse extends GatewayResponse implements HasTransactionReference
{
private $order;
private $httpResponse;
public function __construct(Order $order, HttpResponse $httpResponse)
{
$this->order = $order;
$this->httpResponse = $httpResponse;
}
public function getOrderId()
{
return $this->order->id;
}
public function getTransactionReference()
{
return $this->httpResponse->result->purchase_units[0]->payments->captures[0]->id;
}
public function toArray()
{
return parent::toArray() + ['resourceId' => $this->httpResponse->result->id];
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Modules\Payment\Responses;
use Modules\Order\Entities\Order;
use Modules\Payment\ShouldRedirect;
use Modules\Payment\GatewayResponse;
use Modules\Payment\HasTransactionReference;
class PaystackResponse extends GatewayResponse implements HasTransactionReference
{
private $order;
public function __construct(Order $order)
{
$this->order = $order;
}
public function getOrderId()
{
return $this->order->id;
}
public function getTransactionReference()
{
return request('reference');
}
public function toArray()
{
return [
'key' => setting('paystack_public_key'),
'email' => $this->order->customer_email,
'amount' => $this->order->total->convertToCurrentCurrency()->subunit(),
'ref' => 'ref' . time(),
'currency' => currency(),
'order_id' => $this->order->id,
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Modules\Payment\Responses;
use Modules\Order\Entities\Order;
use Modules\Payment\GatewayResponse;
use Modules\Payment\HasTransactionReference;
class PaytmResponse extends GatewayResponse implements HasTransactionReference
{
private $order;
private $clientResponse;
public function __construct(Order $order, $clientResponse)
{
$this->order = $order;
$this->clientResponse = $clientResponse;
}
public function getOrderId()
{
return $this->order->id;
}
public function getTransactionReference()
{
return 'ref' . time();
}
public function toArray()
{
return parent::toArray() + [
'amount' => $this->order->total->convertToCurrentCurrency()->round()->amount(),
'txnToken' => $this->clientResponse['txnToken'],
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Modules\Payment\Responses;
use Modules\Payment\GatewayResponse;
use Razorpay\Api\Order as RazorpayOrder;
use Modules\Payment\HasTransactionReference;
class RazorpayResponse extends GatewayResponse implements HasTransactionReference
{
private $razorpayOrder;
public function __construct(RazorpayOrder $razorpayOrder)
{
$this->razorpayOrder = $razorpayOrder;
}
public function getOrderId()
{
return $this->razorpayOrder->receipt;
}
public function getTransactionReference()
{
return $this->razorpayOrder->razorpay_payment_id;
}
public function toArray()
{
return $this->razorpayOrder->toArray();
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Modules\Payment\Responses;
use Stripe\PaymentIntent;
use Modules\Order\Entities\Order;
use Modules\Payment\GatewayResponse;
use Modules\Payment\HasTransactionReference;
class StripeResponse extends GatewayResponse implements HasTransactionReference
{
private $order;
private $intent;
public function __construct(Order $order, PaymentIntent $intent)
{
$this->order = $order;
$this->intent = $intent;
}
public function getOrderId()
{
return $this->order->id;
}
public function getTransactionReference()
{
return $this->intent->id;
}
public function toArray()
{
return parent::toArray() + ['clientSecret' => $this->intent->client_secret];
}
}