This repository has been archived by the owner on Jun 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pmclain/feature/save-payment-info
Feature/save payment info
- Loading branch information
Showing
49 changed files
with
2,659 additions
and
78 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Pmclain_Stripe extension | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the GPL v3 License | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://www.gnu.org/licenses/gpl.txt | ||
* | ||
* @category Pmclain | ||
* @package Pmclain_Stripe | ||
* @copyright Copyright (c) 2017 | ||
* @license https://www.gnu.org/licenses/gpl.txt GPL v3 License | ||
*/ | ||
namespace Pmclain\Stripe\Block\Customer; | ||
|
||
use Pmclain\Stripe\Model\Ui\ConfigProvider; | ||
use Magento\Vault\Api\Data\PaymentTokenInterface; | ||
use Magento\Vault\Block\AbstractCardRenderer; | ||
|
||
class CardRenderer extends AbstractCardRenderer | ||
{ | ||
/** | ||
* Can render specified token | ||
* | ||
* @param PaymentTokenInterface $token | ||
* @return boolean | ||
*/ | ||
public function canRender(PaymentTokenInterface $token) | ||
{ | ||
return $token->getPaymentMethodCode() === ConfigProvider::CODE; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getNumberLast4Digits() | ||
{ | ||
return $this->getTokenDetails()['maskedCC']; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getExpDate() | ||
{ | ||
return $this->getTokenDetails()['expirationDate']; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getIconUrl() | ||
{ | ||
return $this->getIconForType($this->getTokenDetails()['type'])['url']; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getIconHeight() | ||
{ | ||
return $this->getIconForType($this->getTokenDetails()['type'])['height']; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getIconWidth() | ||
{ | ||
return $this->getIconForType($this->getTokenDetails()['type'])['width']; | ||
} | ||
} |
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,67 @@ | ||
<?php | ||
/** | ||
* Pmclain_Stripe extension | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the GPL v3 License | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://www.gnu.org/licenses/gpl.txt | ||
* | ||
* @category Pmclain | ||
* @package Pmclain_Stripe | ||
* @copyright Copyright (c) 2017 | ||
* @license https://www.gnu.org/licenses/gpl.txt GPL v3 License | ||
*/ | ||
|
||
namespace Pmclain\Stripe\Block; | ||
|
||
use Pmclain\Stripe\Model\Ui\ConfigProvider; | ||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
|
||
/** | ||
* Class Payment | ||
*/ | ||
class Payment extends Template | ||
{ | ||
/** | ||
* @var ConfigProvider | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param Context $context | ||
* @param ConfigProvider $config | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
ConfigProvider $config, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPaymentConfig() | ||
{ | ||
$payment = $this->config->getConfig()['payment']; | ||
$config = $payment[$this->getCode()]; | ||
$config['code'] = $this->getCode(); | ||
return json_encode($config, JSON_UNESCAPED_SLASHES); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCode() | ||
{ | ||
return ConfigProvider::CODE; | ||
} | ||
} |
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
Oops, something went wrong.