-
Notifications
You must be signed in to change notification settings - Fork 0
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
7c2dd11
commit 1b155ba
Showing
40 changed files
with
1,447 additions
and
309 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,36 +1,65 @@ | ||
<?php | ||
namespace Ecpay\General\Api; | ||
|
||
use Magento\Framework\Controller\Result\Json; | ||
|
||
interface InvoiceInterface { | ||
|
||
/** | ||
* | ||
* @param string $barcode | ||
* @return Json | ||
*/ | ||
public function checkBarcode($barcode); | ||
|
||
/** | ||
* | ||
* @param string $loveCode | ||
* @return Json | ||
*/ | ||
public function checkLoveCode($loveCode); | ||
|
||
/** | ||
* | ||
* @param string $carrierNumber | ||
* @return Json | ||
*/ | ||
public function checkCitizenDigitalCertificate($carrierNumber); | ||
|
||
/** | ||
* | ||
* @param string $businessNumber | ||
* @return Json | ||
*/ | ||
public function checkBusinessNumber($businessNumber); | ||
|
||
/** | ||
* | ||
* @param string $orderId | ||
* @param string $protectCode | ||
* @return [] | ||
* @return Json | ||
*/ | ||
public function createInvoice($orderId, $protectCode); | ||
|
||
/** | ||
* | ||
* @param string $orderId | ||
* @param string $protectCode | ||
* @return [] | ||
* @return Json | ||
*/ | ||
public function invalidInvoice($orderId, $protectCode); | ||
|
||
/** | ||
* | ||
* @param string $orderId | ||
* @param string $protectCode | ||
* @return [] | ||
* @return Json | ||
*/ | ||
public function getInvoiceTag($orderId, $protectCode); | ||
|
||
/** | ||
* | ||
* @return [] | ||
* @return Json | ||
*/ | ||
public function getInvoiceMainConfig(); | ||
} |
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
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,74 @@ | ||
<?php | ||
|
||
namespace Ecpay\General\Block\Adminhtml\Order; | ||
|
||
use Magento\Sales\Block\Adminhtml\Order\View\Tab\Info; | ||
use Magento\Shipping\Helper\Data as ShippingHelper; | ||
use Magento\Tax\Helper\Data as TaxHelper; | ||
use Ecpay\General\Helper\Services\Common\OrderService; | ||
use Ecpay\General\Helper\Services\Config\PaymentService; | ||
|
||
class PaymentInfo extends Info | ||
{ | ||
protected $_orderService; | ||
protected $_paymentService; | ||
protected $_orderRepository; | ||
|
||
protected $orderId; | ||
|
||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Registry $registry, | ||
\Magento\Sales\Helper\Admin $adminHelper, | ||
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository, | ||
OrderService $orderService, | ||
PaymentService $paymentService, | ||
array $data = [], | ||
?ShippingHelper $shippingHelper = null, | ||
?TaxHelper $taxHelper = null | ||
) { | ||
parent::__construct($context, $registry, $adminHelper, $data, $shippingHelper, $taxHelper); | ||
|
||
$this->_orderService = $orderService; | ||
$this->_paymentService = $paymentService; | ||
$this->_orderRepository = $orderRepository; | ||
|
||
$this->orderId = $this->getOrder()->getId(); | ||
$this->_logger->debug('Admin PaymentInfo Block $this->orderId : ' . $this->getOrder()->getIdFieldName() . ' ' . $this->orderId); | ||
} | ||
|
||
/** | ||
* 是否顯示綠界付款資訊 | ||
* | ||
* @return bool | ||
*/ | ||
public function isShowEcpayPaymentInfo() | ||
{ | ||
$allowedPaymentInfoList = ['ecpay_atm_gateway', 'ecpay_cvs_gateway', 'ecpay_barcode_gateway', 'ecpay_credit_installment_gateway']; | ||
$paymentMethod = $this->_orderService->getPaymentMethod($this->orderId); | ||
|
||
if (in_array($paymentMethod, $allowedPaymentInfoList)) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* 取得綠界付款資訊 | ||
* | ||
* @return array $paymentInfo | ||
*/ | ||
public function getEcpayPaymentInfo() | ||
{ | ||
$paymentInfo = []; | ||
|
||
$paymentMethod = $this->_orderService->getPaymentMethod($this->orderId); | ||
|
||
if ($this->_paymentService->isEcpayPayment($paymentMethod)) { | ||
$paymentInfo = $this->_orderService->getEcpayPaymentInfoContent($this->orderId, $paymentMethod); | ||
} | ||
|
||
return $paymentInfo; | ||
} | ||
} |
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,85 @@ | ||
<?php | ||
|
||
namespace Ecpay\General\Block\Frontend\Order; | ||
|
||
use Magento\Sales\Block\Order\Info; | ||
use Magento\Framework\View\Element\Template\Context as TemplateContext; | ||
use Magento\Framework\Registry; | ||
use Magento\Payment\Helper\Data as PaymentHelper; | ||
use Magento\Sales\Model\Order\Address\Renderer as AddressRenderer; | ||
use Ecpay\General\Helper\Services\Common\OrderService; | ||
use Ecpay\General\Helper\Services\Config\PaymentService; | ||
|
||
class PaymentInfo extends Info | ||
{ | ||
protected $_orderService; | ||
protected $_paymentService; | ||
|
||
protected $orderId; | ||
|
||
/** | ||
* @param TemplateContext $context | ||
* @param Registry $registry | ||
* @param PaymentHelper $paymentHelper | ||
* @param AddressRenderer $addressRenderer | ||
* @param OrderService $orderService | ||
* @param PaymentService $paymentService | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
TemplateContext $context, | ||
Registry $registry, | ||
PaymentHelper $paymentHelper, | ||
AddressRenderer $addressRenderer, | ||
OrderService $orderService, | ||
PaymentService $paymentService, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $registry, $paymentHelper, $addressRenderer, $data); | ||
|
||
$this->_orderService = $orderService; | ||
$this->_paymentService = $paymentService; | ||
|
||
$this->orderId = $this->getOrder()->getId(); | ||
$this->_logger->debug('Frontend PaymentInfo Block $this->orderId : ' . $this->getOrder()->getIdFieldName() . ' ' . $this->orderId); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPaymentInfoHtml() | ||
{ | ||
return parent::getPaymentInfoHtml() . $this->getEcpayPaymentInfoHtml(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEcpayPaymentInfoHtml() | ||
{ | ||
$html = '<dl class="ecpay-payment-method">'; | ||
foreach ($this->getEcpayPaymentInfo() as $info) { | ||
$html .= ' <dt class="title">' . $info['key'] . ':' . $info['val'] . '</dt>'; | ||
} | ||
$html .= '</dl>'; | ||
|
||
return $html; | ||
} | ||
|
||
/** | ||
* 取得綠界付款資訊 | ||
* | ||
* @return array $paymentInfo | ||
*/ | ||
public function getEcpayPaymentInfo() | ||
{ | ||
$paymentInfo = []; | ||
$paymentMethod = $this->_orderService->getPaymentMethod($this->orderId); | ||
|
||
if ($this->_paymentService->isEcpayPayment($paymentMethod)) { | ||
$paymentInfo = $this->_orderService->getEcpayPaymentInfoContent($this->orderId, $paymentMethod); | ||
} | ||
|
||
return $paymentInfo; | ||
} | ||
} |
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,66 @@ | ||
<?php | ||
namespace Ecpay\General\Block\Onepage; | ||
|
||
use Magento\Checkout\Model\Session as CheckoutSession; | ||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Psr\Log\LoggerInterface; | ||
|
||
use Ecpay\General\Helper\Services\Common\EncryptionsService; | ||
use Ecpay\General\Helper\Services\Common\OrderService; | ||
use Ecpay\General\Helper\Services\Common\ToEcpayService; | ||
use Ecpay\General\Helper\Services\Config\PaymentService; | ||
use Ecpay\General\Helper\Services\Config\LogisticService; | ||
|
||
class RedirectToEcpay extends Template | ||
{ | ||
protected $_checkoutSession; | ||
|
||
protected $_loggerInterface; | ||
|
||
protected $_encryptionsService; | ||
protected $_orderService; | ||
protected $_toEcpayService; | ||
|
||
protected $_paymentService; | ||
protected $_logisticService; | ||
|
||
protected $orderId; | ||
|
||
public function __construct( | ||
Context $context, | ||
CheckoutSession $checkoutSession, | ||
LoggerInterface $loggerInterface, | ||
EncryptionsService $encryptionsService, | ||
OrderService $orderService, | ||
ToEcpayService $toEcpayService, | ||
PaymentService $paymentService, | ||
LogisticService $logisticService, | ||
array $data = [] | ||
) { | ||
$this->_checkoutSession = $checkoutSession; | ||
$this->_loggerInterface = $loggerInterface; | ||
|
||
$this->_encryptionsService = $encryptionsService; | ||
$this->_orderService = $orderService; | ||
$this->_toEcpayService = $toEcpayService; | ||
|
||
$this->_paymentService = $paymentService; | ||
$this->_logisticService = $logisticService; | ||
|
||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* 產生綠界金、物流表單後至前端 echo | ||
*/ | ||
public function getFormHtml() { | ||
$enctyOrderId = $this->getRequest()->getParam('id'); | ||
$formType = $this->getRequest()->getParam('type'); | ||
|
||
if ($formType == 'payment') $form = $this->_toEcpayService->preparePayment($enctyOrderId); | ||
else $form = $this->_toEcpayService->prepareLogistic($enctyOrderId); | ||
|
||
return $form; | ||
} | ||
} |
Oops, something went wrong.