Skip to content

Commit

Permalink
Merge pull request #1 from eccubevn/master-create-log
Browse files Browse the repository at this point in the history
Master create log
  • Loading branch information
toannguyen-lockon authored Jan 29, 2019
2 parents cad3f54 + 7548e1f commit 673cf49
Show file tree
Hide file tree
Showing 12 changed files with 493 additions and 128 deletions.
18 changes: 14 additions & 4 deletions Controller/OnepayController.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
namespace Plugin\Onepay\Controller;

use Plugin\Onepay\Entity\PaidLogs;
use Plugin\Onepay\Repository\PaidLogsRepository;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Eccube\Controller\AbstractController;
Expand Down Expand Up @@ -35,26 +36,33 @@ class OnepayController extends AbstractController
*/
protected $orderStateMachine;

/** @var PaidLogsRepository */
protected $paidLogsRepository;

/**
* OnepayController constructor.
*
* @param CartService $cartService
* @param OrderRepository $orderRepository
* @param OrderStatusRepository $orderStatusRepository
* @param OrderStateMachine $orderStateMachine
* @param PaidLogsRepository $paidLogsRepository
*/
public function __construct(
CartService $cartService,
OrderRepository $orderRepository,
OrderStatusRepository $orderStatusRepository,
OrderStateMachine $orderStateMachine
OrderStateMachine $orderStateMachine,
PaidLogsRepository $paidLogsRepository
) {
$this->orderStatusRepository = $orderStatusRepository;
$this->orderStateMachine = $orderStateMachine;
$this->cartService = $cartService;
$this->orderRepository = $orderRepository;
$this->orderStatusRepository = $orderStatusRepository;
$this->orderStateMachine = $orderStateMachine;
$this->paidLogsRepository = $paidLogsRepository;
}


/**
* @Route("/onepay/back", name="onepay_back")
* @param Request $request
Expand All @@ -68,6 +76,8 @@ public function back(Request $request)
throw new NotFoundHttpException();
}

$this->paidLogsRepository->saveLogs($Order, $request);

if ($this->getUser() != $Order->getCustomer()) {
throw new NotFoundHttpException();
}
Expand Down
60 changes: 1 addition & 59 deletions Entity/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* @ORM\Table(name="plg_onepay_config")
* @ORM\Entity(repositoryClass="Plugin\OnepagePayment\Repository\ConfigRepository")
* @ORM\Entity(repositoryClass="Plugin\Onepay\Repository\ConfigRepository")
*/
class Config
{
Expand All @@ -32,13 +32,6 @@ class Config
*/
protected $creditCallUrl;

/**
* @var string
*
* @ORM\Column(name="credit_callback_url", type="string", length=1024, nullable=true)
*/
protected $creditCallbackUrl;

/**
* @var string
*
Expand Down Expand Up @@ -67,13 +60,6 @@ class Config
*/
protected $domesticCallUrl;

/**
* @var string
*
* @ORM\Column(name="domestic_callback_url", type="string", length=1024, nullable=true)
*/
protected $domesticCallbackUrl;

/**
* @var string
*
Expand Down Expand Up @@ -140,28 +126,6 @@ public function setCreditCallUrl($creditCallUrl)
return $this;
}

/**
* Get $creditCallbackUrl
*
* @return string
*/
public function getCreditCallbackUrl()
{
return $this->creditCallbackUrl;
}

/**
* Set $creditCallbackUrl
*
* @param $creditCallbackUrl
* @return $this
*/
public function setCreditCallbackUrl($creditCallbackUrl)
{
$this->creditCallbackUrl = $creditCallbackUrl;
return $this;
}

/**
* Get $creditMerchantId
*
Expand Down Expand Up @@ -250,28 +214,6 @@ public function setDomesticCallUrl($domesticCallUrl)
return $this;
}

/**
* Get $creditCallbackUrl
*
* @return string
*/
public function getDomesticCallbackUrl()
{
return $this->domesticCallbackUrl;
}

/**
* Set $domesticCallbackUrl
*
* @param $domesticCallbackUrl
* @return $this
*/
public function setDomesticCallbackUrl($domesticCallbackUrl)
{
$this->domesticCallbackUrl = $domesticCallbackUrl;
return $this;
}

/**
* Get $domesticMerchantId
*
Expand Down
111 changes: 111 additions & 0 deletions Entity/PaidLogs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php
namespace Plugin\Onepay\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Table(name="plg_onepay_paid_logs")
* @ORM\Entity(repositoryClass="Plugin\Onepay\Repository\PaidLogsRepository")
*/
class PaidLogs
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", options={"unsigned": true})
* @ORM\Id()
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;

/**
* @var \Eccube\Entity\Order
*
* @ORM\ManyToOne(targetEntity="Eccube\Entity\Order", inversedBy="PaidLogs")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="order_id", referencedColumnName="id")
* })
*/
protected $Order;

/**
* @var string
*
* @ORM\Column(name="paid_information", type="text", nullable=true)
*/
protected $paid_information;

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}

/**
* @return \Eccube\Entity\Order
*/
public function getOrder()
{
return $this->Order;
}

/**
* @param \Eccube\Entity\Order $Order
*/
public function setOrder($Order)
{
$this->Order = $Order;
}

/**
* @param bool $assoc
* @return mixed
*/
public function getPaidInformation($assoc = false)
{
return json_decode($this->paid_information, $assoc);
}

/**
* @param string $paid_information
*/
public function setPaidInformation($paid_information)
{
$this->paid_information = $paid_information;
}

/**
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->created_at;
}

/**
* @param \DateTime $created_at
*/
public function setCreatedAt($created_at)
{
$this->created_at = $created_at;
}

/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetimetz")
*/
protected $created_at;


}
74 changes: 60 additions & 14 deletions Form/Type/Admin/ConfigType.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
<?php
namespace Plugin\Onepay\Form\Type\Admin;

use Eccube\Common\EccubeConfig;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Plugin\Onepay\Entity\Config;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Url;

class ConfigType extends AbstractType
{
/** @var EccubeConfig */
private $eccubeConfig;
/**
* ConfigType constructor.
*
* @param EccubeConfig $eccubeConfig
*/
public function __construct(EccubeConfig $eccubeConfig)
{
$this->eccubeConfig = $eccubeConfig;
}

/**
* {@inheritdoc}
*
Expand All @@ -19,34 +35,64 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('credit_call_url', TextType::class, [
'label' => trans('onepay.config.call_url.label')
])
->add('credit_callback_url', TextType::class, [
'label' => trans('onepay.config.callback_url.label')
'label' => trans('onepay.config.call_url.label'),
'constraints' => [
new NotBlank(),
new Length(['max' => $this->eccubeConfig->get('eccube_stext_len')]),
new Url(),
],
])
->add('credit_merchant_id', TextType::class, [
'label' => trans('onepay.config.merchant_id.label')
'label' => trans('onepay.config.merchant_id.label'),
'constraints' => [
new NotBlank(),
new Length(['max' => $this->eccubeConfig->get('eccube_stext_len')]),
],
])
->add('credit_merchant_access_code', TextType::class, [
'label' => trans('onepay.config.merchant_access_code.label')
'label' => trans('onepay.config.merchant_access_code.label'),
'constraints' => [
new NotBlank(),
new Length(['max' => $this->eccubeConfig->get('eccube_stext_len')]),
],
])
->add('credit_secret', TextType::class, [
'label' => trans('onepay.config.secret.label')
'label' => trans('onepay.config.secret.label'),
'constraints' => [
new NotBlank(),
new Length(['max' => $this->eccubeConfig->get('eccube_stext_len')]),
],
])

// Domestic
->add('domestic_call_url', TextType::class, [
'label' => trans('onepay.config.call_url.label')
])
->add('domestic_callback_url', TextType::class, [
'label' => trans('onepay.config.callback_url.label')
'label' => trans('onepay.config.call_url.label'),
'constraints' => [
new NotBlank(),
new Length(['max' => $this->eccubeConfig->get('eccube_stext_len')]),
new Url(),
],
])
->add('domestic_merchant_id', TextType::class, [
'label' => trans('onepay.config.merchant_id.label')
'label' => trans('onepay.config.merchant_id.label'),
'constraints' => [
new NotBlank(),
new Length(['max' => $this->eccubeConfig->get('eccube_stext_len')]),
],
])
->add('domestic_merchant_access_code', TextType::class, [
'label' => trans('onepay.config.merchant_access_code.label')
'label' => trans('onepay.config.merchant_access_code.label'),
'constraints' => [
new NotBlank(),
new Length(['max' => $this->eccubeConfig->get('eccube_stext_len')]),
],
])
->add('domestic_secret', TextType::class, [
'label' => trans('onepay.config.secret.label')
'label' => trans('onepay.config.secret.label'),
'constraints' => [
new NotBlank(),
new Length(['max' => $this->eccubeConfig->get('eccube_stext_len')]),
],
]);
}

Expand Down
Loading

0 comments on commit 673cf49

Please sign in to comment.