Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83c2492
commit a91998e
Showing
23 changed files
with
632 additions
and
705 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Lone\SystempayBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
class Configuration implements ConfigurationInterface | ||
{ | ||
|
||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder('systempay'); | ||
$treeBuilder | ||
->getRootNode() | ||
->children() | ||
->scalarNode('hash_method')->end() | ||
->scalarNode('key_dev')->defaultNull()->end() | ||
->scalarNode('key_prod')->defaultNull()->end() | ||
->arrayNode('vads')->children() | ||
->scalarNode('debug')->defaultValue('ON')->end() | ||
->scalarNode('site_id')->isRequired()->defaultValue('xxxxx')->end() | ||
->scalarNode('url_return')->isRequired()->defaultValue('https://xxxx.xxxx')->end() | ||
->scalarNode('return_mode')->defaultValue('POST')->end() | ||
->scalarNode('ctx_mode')->defaultValue('TEST')->end() | ||
->scalarNode('page_action')->defaultValue('PAYMENT')->end() | ||
->scalarNode('action_mode')->defaultValue('INTERACTIVE')->end() | ||
->scalarNode('payment_config')->defaultValue('SINGLE')->end() | ||
->scalarNode('version')->defaultValue('V2')->end() | ||
->scalarNode('language')->defaultValue('fr')->end() | ||
->end() | ||
->end() | ||
; | ||
|
||
/** | ||
* Do not change the following values | ||
* page_action: PAYMENT | ||
* action_mode: INTERACTIVE | ||
* payment_config: SINGLE | ||
* version: V2 | ||
**/ | ||
|
||
return $treeBuilder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Lone\SystempayBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
class LoneSystempayExtension extends ConfigurableExtension | ||
{ | ||
|
||
protected function loadInternal(array $mergedConfig, ContainerBuilder $container) | ||
{ | ||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
$loader->load('services.yml'); | ||
|
||
$this->setConfigAsParameter($mergedConfig, $container); | ||
} | ||
|
||
private function setConfigAsParameter(array $config, ContainerBuilder $container, string $prefix = null) { | ||
foreach ($config as $field => $value) { | ||
if (is_array($value)) { | ||
$this->setConfigAsParameter($value, $container, $field); | ||
} else { | ||
$key = sprintf('%s.%s%s', $this->getAlias(), $prefix ? $prefix.'.' : '', $field); | ||
$container->setParameter($key, $value); | ||
} | ||
} | ||
} | ||
|
||
function getAlias() | ||
{ | ||
return 'systempay'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<?php | ||
|
||
namespace Lone\SystempayBundle\Entity; | ||
|
||
use Lone\SystempayBundle\Model\TransactionStatus; | ||
use \DateTime; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\HasLifecycleCallbacks() | ||
*/ | ||
abstract class AbstractTransaction | ||
{ | ||
/** | ||
* @var | ||
* @ORM\Column(name="id", type="integer") | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* @var string | ||
* @ORM\Column(name="systempay_transaction_id", length=10, type="string") | ||
*/ | ||
protected $systempayTransactionId; | ||
|
||
/** | ||
* @var string | ||
* @ORM\Column(name="systempay_transaction_id", type="string", nullable=true) | ||
*/ | ||
protected $transactionUuid; | ||
|
||
/** | ||
* @var string | ||
* @ORM\Column(name="status_code", type="string", length=255, nullable=true) | ||
*/ | ||
protected $status = TransactionStatus::PENDING; | ||
|
||
/** | ||
* @var int | ||
* @ORM\Column(name="amount", type="integer") | ||
*/ | ||
protected $amount; | ||
|
||
/** | ||
* @var int | ||
* @ORM\Column(name="currency", type="integer") | ||
*/ | ||
protected $currency; | ||
|
||
/** | ||
* @var DateTime | ||
* @ORM\Column(name="created_at", type="datetime") | ||
*/ | ||
protected $createdAt; | ||
|
||
/** | ||
* @var DateTime | ||
* @ORM\Column(name="updated_at", type="datetime") | ||
*/ | ||
protected $updatedAt; | ||
|
||
/** | ||
* @var string | ||
* @ORM\Column(name="log_response", type="text", nullable=true) | ||
*/ | ||
protected $logResponse; | ||
|
||
/** | ||
* @var bool | ||
* @ORM\Column(name="paid", type="boolean") | ||
*/ | ||
protected $paid = false; | ||
|
||
/** | ||
* @var bool | ||
* @ORM\Column(name="refunded", type="boolean") | ||
*/ | ||
protected $refunded = false; | ||
|
||
/** | ||
* Create a new transaction, default currency is 978 => EUR. | ||
* @param int $amount | ||
* @param int $currency | ||
*/ | ||
public function __construct(string $systempayTransactionId, int $amount, int $currency = 978) | ||
{ | ||
$this->systempayTransactionId = $systempayTransactionId; | ||
$this->amount = $amount; | ||
$this->currency = $currency; | ||
} | ||
|
||
/** | ||
* @ORM\PrePersist() | ||
* @ORM\PreUpdate() | ||
*/ | ||
public function updateTimestamps() { | ||
if (!$this->createdAt) { | ||
$this->createdAt = new DateTime(); | ||
} | ||
$this->updatedAt = new DateTime(); | ||
} | ||
|
||
public function amount(): int | ||
{ | ||
return $this->amount; | ||
} | ||
|
||
public function createdAt(): DateTime | ||
{ | ||
return $this->createdAt; | ||
} | ||
|
||
public function currency(): int | ||
{ | ||
return $this->currency; | ||
} | ||
|
||
public function id(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function logResponse(): string | ||
{ | ||
return $this->logResponse; | ||
} | ||
|
||
public function setLogResponse($logResponse) | ||
{ | ||
$this->logResponse = $logResponse; | ||
} | ||
|
||
public function paid(): bool | ||
{ | ||
return $this->paid; | ||
} | ||
|
||
public function pay(): void | ||
{ | ||
$this->paid = true; | ||
} | ||
|
||
public function refunded(): bool | ||
{ | ||
return $this->refunded; | ||
} | ||
|
||
public function refund(): void | ||
{ | ||
$this->refunded = true; | ||
} | ||
|
||
public function getStatus(): string | ||
{ | ||
return $this->status; | ||
} | ||
|
||
public function changeStatus(string $status) | ||
{ | ||
$this->status = $status; | ||
} | ||
|
||
public function updatedAt(): DateTime | ||
{ | ||
return $this->updatedAt; | ||
} | ||
|
||
public function systempayTransactionId(): ?string | ||
{ | ||
return $this->systempayTransactionId; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Lone\SystempayBundle; | ||
|
||
use Lone\SystempayBundle\DependencyInjection\LoneSystempayExtension; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class LoneSystempayBundle extends Bundle { | ||
|
||
public function getContainerExtension() | ||
{ | ||
if (null === $this->extension) { | ||
$this->extension = new LoneSystempayExtension(); | ||
} | ||
return $this->extension; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Lone\SystemPayBundle\Model; | ||
|
||
class AbstractCustomer { | ||
// TODO : Implement customer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Lone\SystempayBundle\Model; | ||
|
||
class AbstractOrder { | ||
// TODO : implement abstract order | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Lone\SystempayBundle\Model; | ||
|
||
class PaymentStatus { | ||
|
||
const AUTHORISED = 'authorised'; | ||
const REFUNDED = 'refunded'; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Lone\SystempayBundle\Model; | ||
|
||
class TransactionStatus { | ||
|
||
const PENDING = 'pending'; | ||
const PAID = 'paid'; | ||
|
||
} |
Oops, something went wrong.