forked from bitpay/magento2-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added template project from magento-plugin as a guide.
- Loading branch information
Chris Kleeschulte
committed
Jul 5, 2016
1 parent
e47de1c
commit 2269b17
Showing
57 changed files
with
4,352 additions
and
0 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,33 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2011-2014 BitPay, Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
# These files/directories are not included when making | ||
# an archive of this repository. | ||
/build export-ignore | ||
/scripts export-ignore | ||
/tests export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.travis.yml export-ignore | ||
build.xml export-ignore | ||
composer.json export-ignore | ||
modman export-ignore |
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,33 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2011-2014 BitPay | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
*.swp | ||
lib/bitpay/bp_config.php | ||
/bin/ | ||
/build/cache/ | ||
/build/dist/ | ||
/build/docs/ | ||
/build/logs/ | ||
/build/magento/ | ||
/vendor/ | ||
composer.lock | ||
composer.phar |
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,38 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2011-2015 BitPay | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
language: php | ||
php: | ||
- 5.6 | ||
- 5.5 | ||
- 5.4 | ||
install: | ||
- composer install | ||
#script: ./bin/phing -verbose -propertyfile build/travis.properties build-travis | ||
script: phpunit -c build/ | ||
cache: | ||
directories: | ||
- bin/ | ||
- build/cache/ | ||
- build/magento/ | ||
- vendor/ | ||
matrix: | ||
fast_finish: true |
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 @@ | ||
# Using the BitPay plugin for Magento | ||
|
||
## Prerequisites | ||
You must have a BitPay merchant account to use this plugin. It's free to [sign-up for a BitPay merchant account](https://bitpay.com/start). | ||
|
||
|
||
## Server Requirements | ||
|
||
* Last Cart Version Tested: 2.0.5 | ||
* [Magento CE](http://magento.com/resources/system-requirements) 2.0.0 or higher. Older versions might work, however this plugin has been validated to work against the 2.0.5 Community Edition release. | ||
* [GMP](http://us2.php.net/gmp) or [BC Math](http://us2.php.net/manual/en/book.bc.php) PHP extensions. GMP is preferred for performance reasons but you may have to install this as most servers do not come with it installed by default. BC Math is commonly installed however and the plugin will fall back to this method if GMP is not found. | ||
* [OpenSSL](http://us2.php.net/openssl) Must be compiled with PHP and is used for certain cryptographic operations. | ||
* [PHP](http://us2.php.net/downloads.php) 5.4 or higher. This plugin will not work on PHP 5.3 and below. This plugin was tested with PHP 5.5.35 | ||
|
||
|
||
## Installation | ||
|
||
**From the Magento Connect Manager:** | ||
|
||
Goto [http://www.magentocommerce.com/magento-connect/bitpay-payment-method.html](http://www.magentocommerce.com/magento-connect/bitpay-payment-method.html) and click the *Install Now* link which will give you the *Extension Key* needed for the next step. | ||
|
||
Once you have the key, log into you Magento Store's Admin Panel and navigate to **System > Magento Connect > Magento Connect Manager**. | ||
|
||
**NOTE:** It may ask you to log in again using the same credentials that you use to log into the Admin Panel. | ||
|
||
All you need to do is paste the extension key and click on the *Install* button. | ||
|
||
**WARNING:** It is good practice to backup your database before installing extensions. Please make sure you Create Backups. | ||
|
||
|
||
**From the Releases Page:** | ||
|
||
Visit the [Releases](https://github.com/bitpay/magento2-plugin/releases) page of this repository and download the latest version. Once this is done, you can just unzip the contents and use any method you want to put them on your server. The contents will mirror the Magento directory structure. | ||
|
||
**NOTE:** These files can also up uploaded using the *Magento Connect Manager* that comes with your Magento Store | ||
|
||
**WARNING:** It is good practice to backup your database before installing extensions. Please make sure you Create Backups. | ||
|
||
|
||
**Using Modman:** | ||
|
||
Using [modman](https://github.com/colinmollenhour/modman) you can install the BitPay Magento Plugin. Once you have modman installed, run `modman init` if you have not already done so. Next just run `modman clone https://github.com/bitpay/magento2-plugin.git` in the root of the Magento installation. In this case it is `/var/www/magento`. | ||
|
||
|
||
## Configuration | ||
|
||
Configuration can be done using the Administrator section of your Magento store. Once Logged in, you will find the configuration settings under **Stores > Configuration > Sales > Payment Methods**. | ||
|
||
![BitPay Magento Settings](https://raw.githubusercontent.com/bitpay/magento2-plugin/master/docs/MagentoSettings.png "BitPay Magento Settings") | ||
|
||
Here your will need to create a [pairing code](https://bitpay.com/api-tokens) using your BitPay merchant account. Once you have a Pairing Code, put the code in the Pairing Code field. This will take care of the rest for you. | ||
|
||
**NOTE:** Pairing Codes are only valid for a short period of time. If it expires before you get to use it, you can always create a new one an use the new one. | ||
|
||
**NOTE:** You will only need to do this once since each time you do this, the extension will generate public and private keys that are used to identify you when using the API. | ||
|
||
You are also able to configure how BitPay's IPN (Instant Payment Notifications) changes the order in your Magento store. | ||
|
||
![BitPay Invoice Settings](https://raw.githubusercontent.com/bitpay/magento2-plugin/master/docs/MagentoInvoiceSettings.png "BitPay Invoice Settings") | ||
|
||
|
||
## Usage | ||
|
||
Once enabled, your customers will be given the option to pay with Bitcoins. Once they checkout they are redirected to a full screen BitPay invoice to pay for the order. | ||
|
||
As a merchant, the orders in your Magento store can be treated as any other order. You may need to adjust the Invoice Settings depending on your order fulfillment. |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2011-2014 BitPay, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
39 changes: 39 additions & 0 deletions
39
app/code/Bitpay/Core/Block/Adminhtml/System/Config/Form/Field/Extension.php
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,39 @@ | ||
<?php | ||
/** | ||
* @license Copyright 2011-2014 BitPay Inc., MIT License | ||
* | ||
*/ | ||
|
||
/** | ||
* This is used to display php extensions and if they are installed or not | ||
*/ | ||
namespace Bitpay\Core\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
|
||
class Extension extends \Magento\Config\Block\System\Config\Form\Field | ||
{ | ||
/** | ||
* Render element html | ||
* | ||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element | ||
* @return string | ||
*/ | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
if (false === isset($element) || true === empty($element)) { | ||
$helper = \Magento\Framework\App\ObjectManager::getInstance()->get('Bitpay\Core\Helper\Data'); | ||
$helper->debugData('[ERROR] In Bitpay_Core_Block_Adminhtml_System_Config_Form_Field_Extension::_getElementHtml(): Missing or invalid $element parameter passed to function.'); | ||
throw new \Exception('In Bitpay_Core_Block_Adminhtml_System_Config_Form_Field_Extension::_getElementHtml(): Missing or invalid $element parameter passed to function.'); | ||
} | ||
|
||
$config = $element->getFieldConfig(); | ||
$phpExtension = isset($config['php_extension']) ? $config['php_extension'] : 'null'; | ||
|
||
if (true === in_array($phpExtension, get_loaded_extensions())) { | ||
return 'Installed'; | ||
} | ||
|
||
return 'Not Installed'; | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
/** | ||
* @license Copyright 2011-2014 BitPay Inc., MIT License | ||
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE | ||
*/ | ||
namespace Bitpay\Core\Block\Form; | ||
|
||
use Magento\Customer\Helper\Session\CurrentCustomer; | ||
use Magento\Framework\Locale\ResolverInterface; | ||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use \Bitpay\Core\Helper\Data; | ||
|
||
class Bitpay extends \Magento\Payment\Block\Form | ||
{ | ||
|
||
/** | ||
* Payment method code | ||
* | ||
* @var string | ||
*/ | ||
protected $_methodCode = 'bitpay'; | ||
|
||
/** | ||
* @var null | ||
*/ | ||
protected $_config; | ||
|
||
|
||
/** | ||
* @var CurrentCustomer | ||
*/ | ||
protected $currentCustomer; | ||
|
||
protected function _construct() | ||
{ | ||
|
||
$template = 'Bitpay_Core::bitpay/form/bitpay.phtml'; | ||
$this->setTemplate($template); | ||
parent::__construct(); | ||
} | ||
|
||
|
||
} |
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,83 @@ | ||
<?php | ||
/** | ||
* @license Copyright 2011-2014 BitPay Inc., MIT License | ||
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE | ||
* | ||
* TODO: Finish this iFrame implemenation... :/ | ||
*/ | ||
|
||
namespace Bitpay\Core\Block; | ||
|
||
class Iframe extends \Magento\Framework\View\Element\Template | ||
{ | ||
|
||
protected $_bitpayModel; | ||
/** | ||
* @var \Bitpay\Core\Helper\Data | ||
*/ | ||
protected $_dataHelper; | ||
|
||
|
||
|
||
/** | ||
* @param \Magento\Framework\View\Element\Template\Context $context | ||
* @param \Bitpay\Core\Model\Invoice $_bitpayModel | ||
* @param \Bitpay\Core\Helper\Data $_dataHelper | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Bitpay\Core\Model\Invoice $_bitpayModel, | ||
\Bitpay\Core\Helper\Data $_dataHelper, | ||
array $data = [] | ||
) { | ||
|
||
$this->_bitpayModel = $_bitpayModel; | ||
$this->_dataHelper = $_dataHelper; | ||
parent::__construct($context,$data); | ||
} | ||
|
||
|
||
|
||
/** | ||
* | ||
* | ||
**/ | ||
protected function getHelper() | ||
{ | ||
$bitpayHelper = $this->_dataHelper; | ||
return $bitpayHelper; | ||
} | ||
|
||
/** | ||
* create an invoice and return the url so that iframe.phtml can display it | ||
* | ||
* @return string | ||
*/ | ||
public function getFrameActionUrl() | ||
{ | ||
$last_success_quote_id = $this->getLastQuoteId(); | ||
$invoiceFactory = $this->_bitpayModel; | ||
$invoice = $invoiceFactory->load($last_success_quote_id,'quote_id'); | ||
return $invoice->getData('url').'&view=iframe'; | ||
} | ||
|
||
public function getLastQuoteId() | ||
{ | ||
$objectmanager = \Magento\Framework\App\ObjectManager::getInstance(); | ||
$quote = $objectmanager->get('\Magento\Checkout\Model\Session'); | ||
return $quote->getData('last_success_quote_id'); | ||
} | ||
|
||
public function getValidateUrl() | ||
{ | ||
$validateUrl = $this->getUrl('bitpay/index/index'); | ||
return $validateUrl; | ||
} | ||
|
||
public function getSuccessUrl() | ||
{ | ||
$successUrl = $this->getUrl('checkout/onepage/success'); | ||
return $successUrl; | ||
} | ||
} |
Oops, something went wrong.