Skip to content

Commit

Permalink
Add support for Google pay for version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondra Votava committed Feb 1, 2019
1 parent d2620ce commit 8b1dd22
Show file tree
Hide file tree
Showing 14 changed files with 1,183 additions and 1,100 deletions.
27 changes: 14 additions & 13 deletions src/Pixidos/GPWebPay/Components/GPWebPayControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ public function __construct(IOperation $operation, IProvider $provider, IContain
$this->operation = $operation;
$this->provider = $provider;
}

/**
* @throws GPWebPayException
* @throws \Nette\Application\AbortException
*/

/**
* @throws GPWebPayException
* @throws UI\InvalidLinkException
* @throws \Nette\Application\AbortException
*/
public function handleCheckout()
{
try {
Expand Down Expand Up @@ -133,11 +134,13 @@ public function setTemplateFile($templateFile)
{
$this->templateFile = $templateFile;
}

/**
* @param array $attrs
* @param string $text
*/

/**
* @param array $attrs
* @param string $text
*
* @throws UI\InvalidLinkException
*/
public function render($attrs = array(), $text = "Pay")
{
/** @var Template $template */
Expand All @@ -154,9 +157,7 @@ public function render($attrs = array(), $text = "Pay")
*/
public function getTemplateFilePath()
{
return ($this->templateFile)
? $this->templateFile
: $this->getDefaultTemplateFilePath();
return $this->templateFile ?: $this->getDefaultTemplateFilePath();
}

/**
Expand Down
29 changes: 15 additions & 14 deletions src/Pixidos/GPWebPay/Components/GPWebPayControlFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,42 @@

namespace Pixidos\GPWebPay\Components;

use Pixidos\GPWebPay\Intefaces\IProvider;
use Pixidos\GPWebPay\Intefaces\IOperation;
use Pixidos\GPWebPay\Intefaces\IProvider;

/**
* Class GPWebPayControlFactory
* @package Pixidos\GPWebPay\Componets
* @author Ondra Votava <[email protected]>
*/

class GPWebPayControlFactory
{

/**
* @var IProvider $provider
*/
private $provider;

/**
* GPWebPayControlFactory constructor.
*
* @param IProvider $provider
*/
public function __construct(IProvider $provider)
{
$this->provider = $provider;
}

/**
* @param IOperation $operation
* @param \Nette\ComponentModel\IContainer|null $control
* @param null $name
* @return GPWebPayControl
*/
public function create(IOperation $operation, \Nette\ComponentModel\IContainer $control = NULL, $name = NULL )

/**
* @param IOperation $operation
* @param \Nette\ComponentModel\IContainer|null $control
* @param null $name
*
* @return GPWebPayControl
*/
public function create(IOperation $operation, \Nette\ComponentModel\IContainer $control = null, $name = null)
{
return new GPWebPayControl($operation, $this->provider, $control, $name);
}

}
}
19 changes: 12 additions & 7 deletions src/Pixidos/GPWebPay/DI/GPWebPayExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
namespace Pixidos\GPWebPay\DI;
use Nette;
use Nette\Utils\Validators;
use Pixidos\GPWebPay\Settings;
use Pixidos\GPWebPay\Components\GPWebPayControlFactory;
use Pixidos\GPWebPay\Provider;

/**
* Class GPWebPayExtension
Expand Down Expand Up @@ -43,21 +46,23 @@ public function loadConfiguration()
$builder = $this->getContainerBuilder();

$builder->addDefinition($this->prefix('settings'))
->setClass('Pixidos\GPWebPay\Settings', array(
"privateKey" => $config["privateKey"],
"privateKeyPassword" => $config['privateKeyPassword'],
->setClass(
Settings::class, [
'privateKey' => $config['privateKey'],
'privateKeyPassword' => $config['privateKeyPassword'],
'publicKey' => $config['publicKey'],
'url' => $config['url'],
'merchantNumber' => $config['merchantNumber'],
'depositFlag' => $config['depositFlag'],
'gatewayKey' => $config['gatewayKey']
));
]
);

$builder->addDefinition($this->prefix('provider'))
->setClass('Pixidos\GPWebPay\Provider', array($this->prefix('@settings')));
->setClass(Provider::class, [$this->prefix('@settings')]);

$builder->addDefinition($this->prefix('controlFactory'))
->setClass('Pixidos\GPWebPay\Components\GPWebPayControlFactory', array($this->prefix('@provider')));
->setClass(GPWebPayControlFactory::class, array($this->prefix('@provider')));

}

Expand All @@ -67,4 +72,4 @@ public static function register(Nette\Configurator $configurator)
$compiler->addExtension('gpwebpay', new GPWebPayExtension());
};
}
}
}
39 changes: 26 additions & 13 deletions src/Pixidos/GPWebPay/Intefaces/IOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getResponseUrl();

/**
* @param string $url max. lenght is 300
* @return $this
* @return IOperation
*/
public function setResponseUrl($url);

Expand All @@ -51,7 +51,7 @@ public function getMd();

/**
* @param string $md max. length is 255!
* @return $this
* @return IOperation
* @throws InvalidArgumentException
*/
public function setMd($md);
Expand All @@ -64,7 +64,7 @@ public function getDescription();

/**
* @param string $description max. length is 255
* @return $this
* @return IOperation
* @throws InvalidArgumentException
*/
public function setDescription($description);
Expand All @@ -76,7 +76,7 @@ public function getMerOrderNum();

/**
* @param string $merordernum max. length is 30
* @return $this
* @return IOperation
*/
public function setMerOrderNum($merordernum);

Expand All @@ -88,7 +88,7 @@ public function getGatewayKey();
/**
*
* @param string $lang max. length is 2
* @return \Pixidos\GPWebPay\Intefaces\IOperation
* @return IOperation
*/
public function setLang($lang);

Expand Down Expand Up @@ -117,7 +117,14 @@ public function setUserParam1($userParam1);
public function getPayMethod();

/**
* @param string $payMethod supported val: CRD – payment card | MCM – MasterCard Mobile | MPS – MasterPass | BTNCS - PLATBA 24
* Supported Values:
* CRD – payment card
* MCM – MasterCard Mobile
* MPS – MasterPass
* BTNCS - PLATBA 24
* GPAY - Google pay
*
* @param string $payMethod supported val: CRD, MCM, MPS, BTNCS, GPAY
* @return IOperation
* @throws InvalidArgumentException
*/
Expand All @@ -134,13 +141,16 @@ public function getDisablePayMethod();
* MCM – MasterCard Mobile
* MPS – MasterPass
* BTNCS - PLATBA 24
* @param string $disablePayMethod supported val: CRD, MCM, MPS, BTNCS
* GPAY - Google pay
*
* @param string $disablePayMethod supported val: CRD, MCM, MPS, BTNCS, GPAY
* @return IOperation
* @throws InvalidArgumentException
*/
public function setDisablePayMethod($disablePayMethod);

/**
* @return mixed
* @return array
*/
public function getPayMethods();

Expand All @@ -151,18 +161,21 @@ public function getPayMethods();
* MCM – MasterCard Mobile
* MPS – MasterPass
* BTNCS - PLATBA 24
* @param array $payMethods supported val: [CRD, MCM, MPS, BTNCS]
* @return $this
* GPAY - Google pay
*
* @param array $payMethods supported val: [CRD, MCM, MPS, BTNCS, GPAY]
* @return IOperation
* @throws InvalidArgumentException
*/
public function setPayMethods($payMethods);
public function setPayMethods(array $payMethods);

/**
* @return string
*/
public function getEmail();

/**
* @param $value
* @param string $value
* @return bool
*/
public function isEmail($value);
Expand Down Expand Up @@ -196,4 +209,4 @@ public function getFastPayId();
* @throws InvalidArgumentException
*/
public function setFastPayId($fastPayId);
}
}
81 changes: 42 additions & 39 deletions src/Pixidos/GPWebPay/Intefaces/IProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,45 @@

interface IProvider
{

/**
* @param IOperation $operation
* @return $this
* @throws \Pixidos\GPWebPay\Exceptions\SignerException
* @throws \Pixidos\GPWebPay\Exceptions\InvalidArgumentException
*/
public function createRequest(IOperation $operation);

/**
* @return IRequest
*/
public function getRequest();

/**
* @return ISigner
*/
public function getSigner();

/**
*
* @return string
*/
public function getRequestUrl();

/**
* @param $params
* @return IResponse
*/
public function createResponse($params);

/**
* @param IResponse $response
* @return bool
* @throws \Pixidos\GPWebPay\Exceptions\GPWebPayException
* @throws \Pixidos\GPWebPay\Exceptions\GPWebPayResultException
*/
public function verifyPaymentResponse(IResponse $response);
}

/**
* @param IOperation $operation
*
* @return $this
* @throws \Pixidos\GPWebPay\Exceptions\SignerException
* @throws \Pixidos\GPWebPay\Exceptions\InvalidArgumentException
*/
public function createRequest(IOperation $operation);

/**
* @return IRequest
*/
public function getRequest();

/**
* @return ISigner
*/
public function getSigner();

/**
*
* @return string
*/
public function getRequestUrl();

/**
* @param $params
*
* @return IResponse
*/
public function createResponse($params);

/**
* @param IResponse $response
*
* @return bool
* @throws \Pixidos\GPWebPay\Exceptions\GPWebPayException
* @throws \Pixidos\GPWebPay\Exceptions\GPWebPayResultException
*/
public function verifyPaymentResponse(IResponse $response);
}
28 changes: 14 additions & 14 deletions src/Pixidos/GPWebPay/Intefaces/IRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

interface IRequest
{

/**
* Return all parameters
* @return array
*/
public function getParams();

/**
* Return only parameters what are included in digest
* @return array
*/
public function getDigestParams();

}
/**
* Return all parameters
* @return array
*/
public function getParams();
/**
* Return only parameters what are included in digest
* @return array
*/
public function getDigestParams();
}
Loading

0 comments on commit 8b1dd22

Please sign in to comment.