first upload all files
This commit is contained in:
41
Modules/Payment/Responses/AuthorizenetResponse.php
Normal file
41
Modules/Payment/Responses/AuthorizenetResponse.php
Normal 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,
|
||||
];
|
||||
}
|
||||
}
|
||||
41
Modules/Payment/Responses/FlutterwaveResponse.php
Normal file
41
Modules/Payment/Responses/FlutterwaveResponse.php
Normal 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;
|
||||
}
|
||||
}
|
||||
35
Modules/Payment/Responses/InstamojoResponse.php
Normal file
35
Modules/Payment/Responses/InstamojoResponse.php
Normal 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'];
|
||||
}
|
||||
}
|
||||
44
Modules/Payment/Responses/MercadoPagoResponse.php
Normal file
44
Modules/Payment/Responses/MercadoPagoResponse.php
Normal 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,
|
||||
];
|
||||
}
|
||||
}
|
||||
21
Modules/Payment/Responses/NullResponse.php
Normal file
21
Modules/Payment/Responses/NullResponse.php
Normal 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;
|
||||
}
|
||||
}
|
||||
35
Modules/Payment/Responses/PayPalResponse.php
Normal file
35
Modules/Payment/Responses/PayPalResponse.php
Normal 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];
|
||||
}
|
||||
}
|
||||
40
Modules/Payment/Responses/PaystackResponse.php
Normal file
40
Modules/Payment/Responses/PaystackResponse.php
Normal 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,
|
||||
];
|
||||
}
|
||||
}
|
||||
41
Modules/Payment/Responses/PaytmResponse.php
Normal file
41
Modules/Payment/Responses/PaytmResponse.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
32
Modules/Payment/Responses/RazorpayResponse.php
Normal file
32
Modules/Payment/Responses/RazorpayResponse.php
Normal 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();
|
||||
}
|
||||
}
|
||||
35
Modules/Payment/Responses/StripeResponse.php
Normal file
35
Modules/Payment/Responses/StripeResponse.php
Normal 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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user