allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
704
vendor/omnipay/common/src/Common/Message/AbstractRequest.php
vendored
Normal file
704
vendor/omnipay/common/src/Common/Message/AbstractRequest.php
vendored
Normal file
@@ -0,0 +1,704 @@
|
||||
<?php
|
||||
/**
|
||||
* Abstract Request
|
||||
*/
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
use Money\Currencies\ISOCurrencies;
|
||||
use Money\Currency;
|
||||
use Money\Formatter\DecimalMoneyFormatter;
|
||||
use Money\Money;
|
||||
use Money\Number;
|
||||
use Money\Parser\DecimalMoneyParser;
|
||||
use Omnipay\Common\CreditCard;
|
||||
use Omnipay\Common\Exception\InvalidRequestException;
|
||||
use Omnipay\Common\Exception\RuntimeException;
|
||||
use Omnipay\Common\Helper;
|
||||
use Omnipay\Common\Http\Client;
|
||||
use Omnipay\Common\Http\ClientInterface;
|
||||
use Omnipay\Common\ItemBag;
|
||||
use Omnipay\Common\ParametersTrait;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
use Symfony\Component\HttpFoundation\Request as HttpRequest;
|
||||
|
||||
/**
|
||||
* Abstract Request
|
||||
*
|
||||
* This abstract class implements RequestInterface and defines a basic
|
||||
* set of functions that all Omnipay Requests are intended to include.
|
||||
*
|
||||
* Requests of this class are usually created using the createRequest
|
||||
* function of the gateway and then actioned using methods within this
|
||||
* class or a class that extends this class.
|
||||
*
|
||||
* Example -- creating a request:
|
||||
*
|
||||
* <code>
|
||||
* class MyRequest extends \Omnipay\Common\Message\AbstractRequest {};
|
||||
*
|
||||
* class MyGateway extends \Omnipay\Common\AbstractGateway {
|
||||
* function myRequest($parameters) {
|
||||
* $this->createRequest('MyRequest', $parameters);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // Create the gateway object
|
||||
* $gw = Omnipay::create('MyGateway');
|
||||
*
|
||||
* // Create the request object
|
||||
* $myRequest = $gw->myRequest($someParameters);
|
||||
* </code>
|
||||
*
|
||||
* Example -- validating and sending a request:
|
||||
*
|
||||
* <code>
|
||||
* try {
|
||||
* $myRequest->validate();
|
||||
* $myResponse = $myRequest->send();
|
||||
* } catch (InvalidRequestException $e) {
|
||||
* print "Something went wrong: " . $e->getMessage() . "\n";
|
||||
* }
|
||||
* // now do something with the $myResponse object, test for success, etc.
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
abstract class AbstractRequest implements RequestInterface
|
||||
{
|
||||
use ParametersTrait {
|
||||
setParameter as traitSetParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* The request client.
|
||||
*
|
||||
* @var ClientInterface
|
||||
*/
|
||||
protected $httpClient;
|
||||
|
||||
/**
|
||||
* The HTTP request object.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected $httpRequest;
|
||||
|
||||
/**
|
||||
* An associated ResponseInterface.
|
||||
*
|
||||
* @var ResponseInterface
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @var ISOCurrencies
|
||||
*/
|
||||
protected $currencies;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $zeroAmountAllowed = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $negativeAmountAllowed = false;
|
||||
|
||||
/**
|
||||
* Create a new Request
|
||||
*
|
||||
* @param ClientInterface $httpClient A HTTP client to make API calls with
|
||||
* @param HttpRequest $httpRequest A Symfony HTTP request object
|
||||
*/
|
||||
public function __construct(ClientInterface $httpClient, HttpRequest $httpRequest)
|
||||
{
|
||||
$this->httpClient = $httpClient;
|
||||
$this->httpRequest = $httpRequest;
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the object with parameters.
|
||||
*
|
||||
* If any unknown parameters passed, they will be ignored.
|
||||
*
|
||||
* @param array $parameters An associative array of parameters
|
||||
*
|
||||
* @return $this
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function initialize(array $parameters = array())
|
||||
{
|
||||
if (null !== $this->response) {
|
||||
throw new RuntimeException('Request cannot be modified after it has been sent!');
|
||||
}
|
||||
|
||||
$this->parameters = new ParameterBag;
|
||||
|
||||
Helper::initialize($this, $parameters);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a single parameter
|
||||
*
|
||||
* @param string $key The parameter key
|
||||
* @param mixed $value The value to set
|
||||
* @return $this
|
||||
* @throws RuntimeException if a request parameter is modified after the request has been sent.
|
||||
*/
|
||||
protected function setParameter($key, $value)
|
||||
{
|
||||
if (null !== $this->response) {
|
||||
throw new RuntimeException('Request cannot be modified after it has been sent!');
|
||||
}
|
||||
|
||||
return $this->traitSetParameter($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the test mode of the request from the gateway.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getTestMode()
|
||||
{
|
||||
return $this->getParameter('testMode');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the test mode of the request.
|
||||
*
|
||||
* @param boolean $value True for test mode on.
|
||||
* @return $this
|
||||
*/
|
||||
public function setTestMode($value)
|
||||
{
|
||||
return $this->setParameter('testMode', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the card.
|
||||
*
|
||||
* @return CreditCard
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->getParameter('card');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the card.
|
||||
*
|
||||
* @param CreditCard $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setCard($value)
|
||||
{
|
||||
if ($value && !$value instanceof CreditCard) {
|
||||
$value = new CreditCard($value);
|
||||
}
|
||||
|
||||
return $this->setParameter('card', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the card token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
return $this->getParameter('token');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the card token.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setToken($value)
|
||||
{
|
||||
return $this->setParameter('token', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the card reference.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCardReference()
|
||||
{
|
||||
return $this->getParameter('cardReference');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the card reference.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setCardReference($value)
|
||||
{
|
||||
return $this->setParameter('cardReference', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ISOCurrencies
|
||||
*/
|
||||
protected function getCurrencies()
|
||||
{
|
||||
if ($this->currencies === null) {
|
||||
$this->currencies = new ISOCurrencies();
|
||||
}
|
||||
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|int|null $amount
|
||||
* @return null|Money
|
||||
* @throws InvalidRequestException
|
||||
*/
|
||||
private function getMoney($amount = null)
|
||||
{
|
||||
$currencyCode = $this->getCurrency() ?: 'USD';
|
||||
$currency = new Currency($currencyCode);
|
||||
|
||||
$amount = $amount !== null ? $amount : $this->getParameter('amount');
|
||||
|
||||
if ($amount === null) {
|
||||
return null;
|
||||
} elseif ($amount instanceof Money) {
|
||||
$money = $amount;
|
||||
} elseif (is_integer($amount)) {
|
||||
$money = new Money($amount, $currency);
|
||||
} else {
|
||||
$moneyParser = new DecimalMoneyParser($this->getCurrencies());
|
||||
|
||||
$number = Number::fromString($amount);
|
||||
|
||||
// Check for rounding that may occur if too many significant decimal digits are supplied.
|
||||
$decimal_count = strlen($number->getFractionalPart());
|
||||
$subunit = $this->getCurrencies()->subunitFor($currency);
|
||||
if ($decimal_count > $subunit) {
|
||||
throw new InvalidRequestException('Amount precision is too high for currency.');
|
||||
}
|
||||
|
||||
$money = $moneyParser->parse((string) $number, $currency);
|
||||
}
|
||||
|
||||
// Check for a negative amount.
|
||||
if (!$this->negativeAmountAllowed && $money->isNegative()) {
|
||||
throw new InvalidRequestException('A negative amount is not allowed.');
|
||||
}
|
||||
|
||||
// Check for a zero amount.
|
||||
if (!$this->zeroAmountAllowed && $money->isZero()) {
|
||||
throw new InvalidRequestException('A zero amount is not allowed.');
|
||||
}
|
||||
|
||||
return $money;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and returns the formatted amount.
|
||||
*
|
||||
* @throws InvalidRequestException on any validation failure.
|
||||
* @return string The amount formatted to the correct number of decimal places for the selected currency.
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
$money = $this->getMoney();
|
||||
|
||||
if ($money !== null) {
|
||||
$moneyFormatter = new DecimalMoneyFormatter($this->getCurrencies());
|
||||
|
||||
return $moneyFormatter->format($money);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the payment amount.
|
||||
*
|
||||
* @param string|null $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmount($value)
|
||||
{
|
||||
return $this->setParameter('amount', $value !== null ? (string) $value : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the payment amount as an integer.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAmountInteger()
|
||||
{
|
||||
$money = $this->getMoney();
|
||||
|
||||
if ($money !== null) {
|
||||
return (int) $money->getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the payment amount as integer.
|
||||
*
|
||||
* @param int $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmountInteger($value)
|
||||
{
|
||||
return $this->setParameter('amount', (int) $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the payment amount as integer.
|
||||
*
|
||||
* @param Money $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setMoney(Money $value)
|
||||
{
|
||||
$currency = $value->getCurrency()->getCode();
|
||||
|
||||
$this->setCurrency($currency);
|
||||
|
||||
return $this->setParameter('amount', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the payment currency code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency()
|
||||
{
|
||||
return $this->getParameter('currency');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the payment currency code.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurrency($value)
|
||||
{
|
||||
if ($value !== null) {
|
||||
$value = strtoupper($value);
|
||||
}
|
||||
return $this->setParameter('currency', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the payment currency number.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCurrencyNumeric()
|
||||
{
|
||||
if (! $this->getCurrency()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$currency = new Currency($this->getCurrency());
|
||||
|
||||
if ($this->getCurrencies()->contains($currency)) {
|
||||
return (string) $this->getCurrencies()->numericCodeFor($currency);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of decimal places in the payment currency.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getCurrencyDecimalPlaces()
|
||||
{
|
||||
if ($this->getCurrency()) {
|
||||
$currency = new Currency($this->getCurrency());
|
||||
if ($this->getCurrencies()->contains($currency)) {
|
||||
return $this->getCurrencies()->subunitFor($currency);
|
||||
}
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format an amount for the payment currency.
|
||||
*
|
||||
* @param string $amount
|
||||
* @return string
|
||||
*/
|
||||
public function formatCurrency($amount)
|
||||
{
|
||||
$money = $this->getMoney((string) $amount);
|
||||
$formatter = new DecimalMoneyFormatter($this->getCurrencies());
|
||||
|
||||
return $formatter->format($money);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->getParameter('description');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request description.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($value)
|
||||
{
|
||||
return $this->setParameter('description', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transaction ID.
|
||||
*
|
||||
* The transaction ID is the identifier generated by the merchant website.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTransactionId()
|
||||
{
|
||||
return $this->getParameter('transactionId');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transaction ID.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setTransactionId($value)
|
||||
{
|
||||
return $this->setParameter('transactionId', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transaction reference.
|
||||
*
|
||||
* The transaction reference is the identifier generated by the remote
|
||||
* payment gateway.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTransactionReference()
|
||||
{
|
||||
return $this->getParameter('transactionReference');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transaction reference.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setTransactionReference($value)
|
||||
{
|
||||
return $this->setParameter('transactionReference', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of items in this order
|
||||
*
|
||||
* @return ItemBag|null A bag containing items in this order
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
return $this->getParameter('items');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the items in this order
|
||||
*
|
||||
* @param ItemBag|array $items An array of items in this order
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems($items)
|
||||
{
|
||||
if ($items && !$items instanceof ItemBag) {
|
||||
$items = new ItemBag($items);
|
||||
}
|
||||
|
||||
return $this->setParameter('items', $items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the client IP address.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClientIp()
|
||||
{
|
||||
return $this->getParameter('clientIp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client IP address.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setClientIp($value)
|
||||
{
|
||||
return $this->setParameter('clientIp', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request return URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnUrl()
|
||||
{
|
||||
return $this->getParameter('returnUrl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request return URL.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setReturnUrl($value)
|
||||
{
|
||||
return $this->setParameter('returnUrl', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request cancel URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCancelUrl()
|
||||
{
|
||||
return $this->getParameter('cancelUrl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request cancel URL.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setCancelUrl($value)
|
||||
{
|
||||
return $this->setParameter('cancelUrl', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request notify URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNotifyUrl()
|
||||
{
|
||||
return $this->getParameter('notifyUrl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request notify URL.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setNotifyUrl($value)
|
||||
{
|
||||
return $this->setParameter('notifyUrl', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the payment issuer.
|
||||
*
|
||||
* This field is used by some European gateways, and normally represents
|
||||
* the bank where an account is held (separate from the card brand).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIssuer()
|
||||
{
|
||||
return $this->getParameter('issuer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the payment issuer.
|
||||
*
|
||||
* This field is used by some European gateways, and normally represents
|
||||
* the bank where an account is held (separate from the card brand).
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setIssuer($value)
|
||||
{
|
||||
return $this->setParameter('issuer', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the payment issuer.
|
||||
*
|
||||
* This field is used by some European gateways, which support
|
||||
* multiple payment providers with a single API.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPaymentMethod()
|
||||
{
|
||||
return $this->getParameter('paymentMethod');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the payment method.
|
||||
*
|
||||
* This field is used by some European gateways, which support
|
||||
* multiple payment providers with a single API.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function setPaymentMethod($value)
|
||||
{
|
||||
return $this->setParameter('paymentMethod', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the request
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$data = $this->getData();
|
||||
|
||||
return $this->sendData($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated Response.
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
if (null === $this->response) {
|
||||
throw new RuntimeException('You must call send() before accessing the Response!');
|
||||
}
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
266
vendor/omnipay/common/src/Common/Message/AbstractResponse.php
vendored
Normal file
266
vendor/omnipay/common/src/Common/Message/AbstractResponse.php
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
/**
|
||||
* Abstract Response
|
||||
*/
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
use Omnipay\Common\Exception\RuntimeException;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse as HttpRedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response as HttpResponse;
|
||||
|
||||
/**
|
||||
* Abstract Response
|
||||
*
|
||||
* This abstract class implements ResponseInterface and defines a basic
|
||||
* set of functions that all Omnipay Requests are intended to include.
|
||||
*
|
||||
* Objects of this class or a subclass are usually created in the Request
|
||||
* object (subclass of AbstractRequest) as the return parameters from the
|
||||
* send() function.
|
||||
*
|
||||
* Example -- validating and sending a request:
|
||||
*
|
||||
* <code>
|
||||
* $myResponse = $myRequest->send();
|
||||
* // now do something with the $myResponse object, test for success, etc.
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
abstract class AbstractResponse implements ResponseInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* The embodied request object.
|
||||
*
|
||||
* @var RequestInterface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The data contained in the response.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param RequestInterface $request the initiating request.
|
||||
* @param mixed $data
|
||||
*/
|
||||
public function __construct(RequestInterface $request, $data)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the initiating request object.
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the response successful?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPending()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the response require a redirect?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isRedirect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the response a transparent redirect?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTransparentRedirect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the transaction cancelled by the user?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isCancelled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response data.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response Message
|
||||
*
|
||||
* @return null|string A response message from the payment gateway
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response code
|
||||
*
|
||||
* @return null|string A response code from the payment gateway
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gateway Reference
|
||||
*
|
||||
* @return null|string A reference provided by the gateway to represent this transaction
|
||||
*/
|
||||
public function getTransactionReference()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transaction ID as generated by the merchant website.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTransactionId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the redirect target url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRedirectUrl()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the required redirect method (either GET or POST).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRedirectMethod()
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the redirect form data array, if the redirect method is POST.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRedirectData()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically perform any required redirect
|
||||
*
|
||||
* This method is meant to be a helper for simple scenarios. If you want to customize the
|
||||
* redirection page, just call the getRedirectUrl() and getRedirectData() methods directly.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function redirect()
|
||||
{
|
||||
$this->getRedirectResponse()->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HttpRedirectResponse|HttpResponse
|
||||
*/
|
||||
public function getRedirectResponse()
|
||||
{
|
||||
$this->validateRedirect();
|
||||
|
||||
if ('GET' === $this->getRedirectMethod()) {
|
||||
return new HttpRedirectResponse($this->getRedirectUrl());
|
||||
}
|
||||
|
||||
$hiddenFields = '';
|
||||
foreach ($this->getRedirectData() as $key => $value) {
|
||||
$hiddenFields .= sprintf(
|
||||
'<input type="hidden" name="%1$s" value="%2$s" />',
|
||||
htmlentities($key, ENT_QUOTES, 'UTF-8', false),
|
||||
htmlentities((string) $value, ENT_QUOTES, 'UTF-8', false)
|
||||
)."\n";
|
||||
}
|
||||
|
||||
$output = '<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Redirecting...</title>
|
||||
</head>
|
||||
<body onload="document.forms[0].submit();">
|
||||
<form action="%1$s" method="post">
|
||||
<p>Redirecting to payment page...</p>
|
||||
<p>
|
||||
%2$s
|
||||
<input type="submit" value="Continue" />
|
||||
</p>
|
||||
</form>
|
||||
</body>
|
||||
</html>';
|
||||
$output = sprintf(
|
||||
$output,
|
||||
htmlentities($this->getRedirectUrl(), ENT_QUOTES, 'UTF-8', false),
|
||||
$hiddenFields
|
||||
);
|
||||
|
||||
return new HttpResponse($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the current Response is a valid redirect.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function validateRedirect()
|
||||
{
|
||||
if (!$this instanceof RedirectResponseInterface || !$this->isRedirect()) {
|
||||
throw new RuntimeException('This response does not support redirection.');
|
||||
}
|
||||
|
||||
if (empty($this->getRedirectUrl())) {
|
||||
throw new RuntimeException('The given redirectUrl cannot be empty.');
|
||||
}
|
||||
|
||||
if (!in_array($this->getRedirectMethod(), ['GET', 'POST'])) {
|
||||
throw new RuntimeException('Invalid redirect method "'.$this->getRedirectMethod().'".');
|
||||
}
|
||||
}
|
||||
}
|
||||
29
vendor/omnipay/common/src/Common/Message/FetchIssuersResponseInterface.php
vendored
Normal file
29
vendor/omnipay/common/src/Common/Message/FetchIssuersResponseInterface.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Fetch Issuers Response interface
|
||||
*/
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
/**
|
||||
* Fetch Issuers Response interface
|
||||
*
|
||||
* This interface class defines the functionality of a response
|
||||
* that is a "fetch issuers" response. It extends the ResponseInterface
|
||||
* interface class with some extra functions relating to the
|
||||
* specifics of a response to fetch the issuers from the gateway.
|
||||
* This happens when the gateway needs the customer to choose a
|
||||
* card issuer.
|
||||
*
|
||||
*/
|
||||
interface FetchIssuersResponseInterface extends ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Get the returned list of issuers.
|
||||
*
|
||||
* These represent banks which the user must choose between.
|
||||
*
|
||||
* @return \Omnipay\Common\Issuer[]
|
||||
*/
|
||||
public function getIssuers();
|
||||
}
|
||||
29
vendor/omnipay/common/src/Common/Message/FetchPaymentMethodsResponseInterface.php
vendored
Normal file
29
vendor/omnipay/common/src/Common/Message/FetchPaymentMethodsResponseInterface.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Fetch Payment Methods Response interface
|
||||
*/
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
/**
|
||||
* Fetch Payment Methods Response interface
|
||||
*
|
||||
* This interface class defines the functionality of a response
|
||||
* that is a "fetch payment method" response. It extends the ResponseInterface
|
||||
* interface class with some extra functions relating to the
|
||||
* specifics of a response to fetch the payment method from the gateway.
|
||||
* This happens when the gateway needs the customer to choose a
|
||||
* payment method.
|
||||
*
|
||||
*/
|
||||
interface FetchPaymentMethodsResponseInterface extends ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Get the returned list of payment methods.
|
||||
*
|
||||
* These represent separate payment methods which the user must choose between.
|
||||
*
|
||||
* @return \Omnipay\Common\PaymentMethod[]
|
||||
*/
|
||||
public function getPaymentMethods();
|
||||
}
|
||||
23
vendor/omnipay/common/src/Common/Message/MessageInterface.php
vendored
Normal file
23
vendor/omnipay/common/src/Common/Message/MessageInterface.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Message Interface
|
||||
*/
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
/**
|
||||
* Message Interface
|
||||
*
|
||||
* This interface class defines the standard functions that any Omnipay message
|
||||
* interface needs to be able to provide.
|
||||
*/
|
||||
interface MessageInterface
|
||||
{
|
||||
/**
|
||||
* Get the raw data array for this message. The format of this varies from gateway to
|
||||
* gateway, but will usually be either an associative array, or a SimpleXMLElement.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData();
|
||||
}
|
||||
35
vendor/omnipay/common/src/Common/Message/NotificationInterface.php
vendored
Normal file
35
vendor/omnipay/common/src/Common/Message/NotificationInterface.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
/**
|
||||
* Incoming notification
|
||||
*/
|
||||
interface NotificationInterface extends MessageInterface
|
||||
{
|
||||
const STATUS_COMPLETED = 'completed';
|
||||
const STATUS_PENDING = 'pending';
|
||||
const STATUS_FAILED = 'failed';
|
||||
|
||||
/**
|
||||
* Gateway Reference
|
||||
*
|
||||
* @return string A reference provided by the gateway to represent this transaction
|
||||
*/
|
||||
public function getTransactionReference();
|
||||
|
||||
/**
|
||||
* Was the transaction successful?
|
||||
*
|
||||
* @return string Transaction status, one of {@link NotificationInterface::STATUS_COMPLETED},
|
||||
* {@link NotificationInterface::STATUS_PENDING}, or {@link NotificationInterface::STATUS_FAILED}.
|
||||
*/
|
||||
public function getTransactionStatus();
|
||||
|
||||
/**
|
||||
* Response Message
|
||||
*
|
||||
* @return string A response message from the payment gateway
|
||||
*/
|
||||
public function getMessage();
|
||||
}
|
||||
46
vendor/omnipay/common/src/Common/Message/RedirectResponseInterface.php
vendored
Normal file
46
vendor/omnipay/common/src/Common/Message/RedirectResponseInterface.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Redirect Response interface
|
||||
*/
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
/**
|
||||
* Redirect Response interface
|
||||
*
|
||||
* This interface class defines the functionality of a response
|
||||
* that is a redirect response. It extends the ResponseInterface
|
||||
* interface class with some extra functions relating to the
|
||||
* specifics of a redirect response from the gateway.
|
||||
*
|
||||
*/
|
||||
interface RedirectResponseInterface extends ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Gets the redirect target url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRedirectUrl();
|
||||
|
||||
/**
|
||||
* Get the required redirect method (either GET or POST).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRedirectMethod();
|
||||
|
||||
/**
|
||||
* Gets the redirect form data array, if the redirect method is POST.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRedirectData();
|
||||
|
||||
/**
|
||||
* Perform the required redirect.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function redirect();
|
||||
}
|
||||
51
vendor/omnipay/common/src/Common/Message/RequestInterface.php
vendored
Normal file
51
vendor/omnipay/common/src/Common/Message/RequestInterface.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Request Interface
|
||||
*/
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
/**
|
||||
* Request Interface
|
||||
*
|
||||
* This interface class defines the standard functions that any Omnipay request
|
||||
* interface needs to be able to provide. It is an extension of MessageInterface.
|
||||
*
|
||||
*/
|
||||
interface RequestInterface extends MessageInterface
|
||||
{
|
||||
/**
|
||||
* Initialize request with parameters
|
||||
* @param array $parameters The parameters to send
|
||||
*/
|
||||
public function initialize(array $parameters = array());
|
||||
|
||||
/**
|
||||
* Get all request parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters();
|
||||
|
||||
/**
|
||||
* Get the response to this request (if the request has been sent)
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getResponse();
|
||||
|
||||
/**
|
||||
* Send the request
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function send();
|
||||
|
||||
/**
|
||||
* Send the request with specified data
|
||||
*
|
||||
* @param mixed $data The data to send
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function sendData($data);
|
||||
}
|
||||
65
vendor/omnipay/common/src/Common/Message/ResponseInterface.php
vendored
Normal file
65
vendor/omnipay/common/src/Common/Message/ResponseInterface.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Response interface
|
||||
*/
|
||||
|
||||
namespace Omnipay\Common\Message;
|
||||
|
||||
/**
|
||||
* Response Interface
|
||||
*
|
||||
* This interface class defines the standard functions that any Omnipay response
|
||||
* interface needs to be able to provide. It is an extension of MessageInterface.
|
||||
*
|
||||
*/
|
||||
interface ResponseInterface extends MessageInterface
|
||||
{
|
||||
/**
|
||||
* Get the original request which generated this response
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function getRequest();
|
||||
|
||||
/**
|
||||
* Is the response successful?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSuccessful();
|
||||
|
||||
/**
|
||||
* Does the response require a redirect?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isRedirect();
|
||||
|
||||
/**
|
||||
* Is the transaction cancelled by the user?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isCancelled();
|
||||
|
||||
/**
|
||||
* Response Message
|
||||
*
|
||||
* @return null|string A response message from the payment gateway
|
||||
*/
|
||||
public function getMessage();
|
||||
|
||||
/**
|
||||
* Response code
|
||||
*
|
||||
* @return null|string A response code from the payment gateway
|
||||
*/
|
||||
public function getCode();
|
||||
|
||||
/**
|
||||
* Gateway Reference
|
||||
*
|
||||
* @return null|string A reference provided by the gateway to represent this transaction
|
||||
*/
|
||||
public function getTransactionReference();
|
||||
}
|
||||
Reference in New Issue
Block a user